# NOT RUN {
library(lodr)
## Using example dataset provided in lodr package: lod_data_ex
## 3 covariates: x1, x2, x3 with x2 and x3 subject to a lower limit of
## detection of 0
# Replace values marked as under limit of detection using 0 with NA,
# add column of ones for intercept
lod_data_with_int <-
as.matrix(cbind("Intercept"=rep(1, dim(lod_data_ex)[1]), lod_data_ex))
lod_data_ex_edit <-
apply(lod_data_with_int, MARGIN = 2, FUN=function(x){ifelse(x==0, NA, x)})
# Fit model with bootstrap procedure, report regression parameter estimate standard errors
LOD_matrix <- cbind(c(NA, NA, -100, -100), c(NA, NA, 0, 0))
## no_of_samples set to 50 for computational speed/illustration purposes only.
## At least 250 is recommended.
## Same for num_of_boots=5; at least 25 is recommended
bootstrap_fit_object <-
LOD_bootstrap_fit(num_of_boots=5, y_data=lod_data_ex_edit[,2],
x_data=lod_data_ex_edit[,-2],
no_of_samples=50,
threshold=0.001, max_iterations=100, LOD_u_l=LOD_matrix)
boot_SEs <- apply(do.call("rbind", bootstrap_fit_object), 2, sd)
names(boot_SEs) <- names(lod_data_with_int[,-2])
boot_SEs
# }
Run the code above in your browser using DataLab