# NOT RUN {
## measurement error in a covariate:
# internal covariate-validation study
data(icvs)
out <-
mecor(Y ~ MeasError(X_star, reference = X) + Z,
data = icvs,
method = "standard",
B = 999)
# replicates study
data(rs)
mecor(Y ~ MeasError(X_star_1, replicate = cbind(X_star_2, X_star_3)) + Z1 + Z2,
data = rs,
method = "mle")
# covariate-calibration study
data(ccs)
mecor(Y ~ MeasError(X_star, replicate = cbind(X_star_1, X_star_2)) + Z,
data = ccs,
method = "efficient")
# external covariate-validation study
data(ecvs)
calmod_fit <- lm(X ~ X_star + Z, data = ecvs)
data(icvs) # suppose reference X is not available
mecor(Y ~ MeasErrorExt(X_star, model = calmod_fit) + Z,
data = icvs)
# sensitivity analyses
data(icvs) # suppose reference X is not available
# guesstimate the coefficients of the calibration model:
mecor(Y ~ MeasErrorExt(X_star, model = list(coef = c(0, 0.9, 0.2))) + Z,
data = icvs)
# assume random measurement error in X_star of magnitude 0.25:
mecor(Y ~ MeasErrorRandom(X_star, variance = 0.25) + Z,
data = icvs)
data(rs) # suppose replicates X_star_2 and X_star_2 are not available
mecor(Y ~ MeasErrorRandom(X_star_1, variance = 0.25) + Z1 + Z2,
data = rs)
## measurement error in the outcome:
# internal outcome-validation study
data(iovs)
mecor(MeasError(Y_star, reference = Y) ~ X + Z,
data = iovs,
method = "standard")
# external outcome-validation study
data(eovs)
memod_fit <- lm(Y_star ~ Y, data = eovs)
data(iovs) # suppose reference Y is not available
mecor(MeasErrorExt(Y_star, model = memod_fit) ~ X + Z,
data = iovs,
method = "standard")
# sensitivity analyses
data(iovs) # suppose reference Y is not available
# guesstimate the coefficients of the measurement error model:
mecor(MeasErrorExt(Y_star, model = list(coef = c(0, 0.5))) ~ X + Z,
data = iovs,
method = "standard")
## differential measurement error in the outcome:
# internal outcome-validation study
data(iovs_diff)
mecor(MeasError(Y_star, reference = Y, differential = X) ~ X,
data = iovs_diff,
method = "standard")
# sensitivity analysis
data(iovs_diff) # suppose reference Y is not available
# guesstimate the coefficients of the measurement error model:
mecor(MeasErrorExt(Y_star, model = list(coef = c(0, 0.5, 1, 1))) ~ X,
data = iovs_diff,
method = "standard")
# }
Run the code above in your browser using DataLab