provides bootstrap estimates of the parameters of the model estimated via the msel function. Function bootstrap_combine_msel allows to combine several objects of class 'bootstrap_msel'.
opt_type: the same as opt_type argument of the msel function.
opt_args: the same as opt_args argument of the msel functions.
is_ind: logical; if TRUE then the function also returns a numeric matrix of indexes of observations used in the bootstrap samples.
n_sim: the same as n_sim argument of the msel function.
n_cores: the same as n_cores argument of the msel function.
...: objects returned by function bootstrap_msel to be combined into a single object.
Returns
Function bootstrap_msel
returns an object of class "bootstrap_msel". This object is a list which may contain the following elements:
par - a numeric matrix such that par[b, ] is a vector of the estimates of the parameters of the model estimated via msel function on the b-th bootstrap sample.
iter - the number of the bootstrap iterations.
cov - bootstrap estimate of the covariance matrix which equals to cov(par).
ind - a numeric matrix such that ind[, b] stores the indexes of the observations from object$data included into the b-th bootstrap sample.
Function bootstrap_combine_msel returns the object which combines several objects returned by the bootstrap_msel function into a single object.
Details
The function generates iter bootstrap samples and estimates the parameters θ of the model by using each of these samples. Estimate θ^(b) from the b-th of these samples is stored as the b-th row of the numeric matrix par which is an element of the returned object.
Use update_msel function to transfer the bootstrap estimates to the object of class 'msel'.
Examples
# -------------------------------# Bootstrap for the probit model# -------------------------------# ---# Step 1# Simulation of data# ---# Load required packagelibrary("mnorm")# Set seed for reproducibilityset.seed(123)# The number of observationsn <-100# Regressors (covariates)w1 <- runif(n = n, min =-1, max =1)w2 <- runif(n = n, min =-1, max =1)# Random errorsu <- rnorm(n = n, mean =0, sd =1)# Coefficientsgamma <- c(-1,2)# Linear indexli <- gamma[1]* w1 + gamma[2]* w2
# Latent variablez_star <- li + u
# Cutscuts <- c(-1,0.5,2)# Observable ordered outcomez <- rep(0, n)z[(z_star > cuts[1])&(z_star <= cuts[2])]<-1z[(z_star > cuts[2])&(z_star <= cuts[3])]<-2z[z_star > cuts[3]]<-3table(z)# Datadata <- data.frame(w1 = w1, w2 = w2, z = z)# ---# Step 2# Estimation of the parameters# ---# Estimationmodel <- msel(formula = z ~ w1 + w2, data = data)summary(model)# ---# Step 3# Bootstrap# ---# Perform bootstrapbootstrap <- bootstrap_msel(model)# Test the hypothesis that H0: gamma[2] = -2gamma[1]# by using the t-test and with bootstrap p-valuesfn_test <-function(object){ gamma <- coef(object, eq =1) return(gamma[2]+2* gamma[1])}b <- test_msel(object = model, fn = fn_test, test ="t", method ="bootstrap", ci ="percentile", se_type ="bootstrap", bootstrap = bootstrap)summary(b)# Replicate the analysis with the additional 20 bootstrap iterationsbootstrap2 <- bootstrap_msel(model, iter =20)bootstrap_new <- bootstrap_combine_msel(bootstrap, bootstrap2)b2 <- test_msel(object = model, fn = fn_test, test ="t", method ="bootstrap", ci ="percentile", se_type ="bootstrap", bootstrap = bootstrap)summary(b2)