mecor: mecor: a measurement error correction package

Description Usage Arguments Value Author(s) References Examples

Description

mecor provides correction methods for measurement errors in a continuous covariate.

Usage

1
mecor(formula, data, method = "rc", alpha = 0.05, B = 0)

Arguments

formula

an object of class formula (or one that is coerced to that class): a symbolic description of the model containing a MeasError object.

data

a data.frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model

method

a character string indicating the method used to correct for measurement error, either "rc" (regression calibration), "rc_pooled1" (efficient regression calibration using delta variance for pooling) or "rc_pooled2" (efficient regression calibration using bootstrap variance for pooling).

alpha

alpha level used to construct confidence intervals

B

number of bootstrap samples

Value

mecor returns an object of class "mecor"

An object of class mecor is a list containing the following components:

naivefit

a lm.fit object of the uncorrected fit

corfit

a lm.fit object of the corrected fit (if method = "rc") and a matrix containing the corrected coefficients else

corvar

the corrected variance using the delta method

ci.fieller

fieller confidence interval (if method = "rc") else NA

ci.b

bootstrap confidence interval (if B != 0)

Author(s)

Linda Nab, [email protected]

References

L.Nab, R.H.H. Groenwold, P.M.J. Welsing, M. van Smeden. Measurement error in continuous endpoints in randomised trials: an exploration of problems and solutions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
##data generation
#measurement error in exposure
nobs <- 1e3
Z <- rnorm(nobs, 0, 1)
X <- Z + rnorm(nobs, 0, 1)
Y <- 0.5 * X + 2 * Z + rnorm(nobs, 0, 1)
W <- X + rnorm(nobs, 0, 0.5)
X <- ifelse(rbinom(nobs, 0, 0.9) == 1, NA, X)
data <- data.frame(Z, X, W, Y)
W2 <- X + rnorm(nobs, 0, 0.5)
W2 <- ifelse(rbinom(nobs, 0, 0.8) == 1, NA, W2)
data2 <- data.frame(Z, W, W2, Y)

mecor(Y ~ MeasError(W, X) + Z, data)
mecor(Y ~ MeasError(W, X) + Z, data, method = "rc_pooled1")
mecor(Y ~ MeasError(W, X) + Z, data, method = "rc_pooled2")
mecor(Y ~ MeasError(cbind(W, W2), NA) + Z, data2)

LindaNab/mecor documentation built on June 13, 2019, 2:18 a.m.