Type: | Package |
Title: | Measurement Error Correction in Linear Models with a Continuous Outcome |
Version: | 1.0.0 |
Author: | Linda Nab |
Maintainer: | Linda Nab <lindanab4@gmail.com> |
Description: | Covariate measurement error correction is implemented by means of regression calibration by Carroll RJ, Ruppert D, Stefanski LA & Crainiceanu CM (2006, ISBN:1584886331), efficient regression calibration by Spiegelman D, Carroll RJ & Kipnis V (2001) <doi:10.1002/1097-0258(20010115)20:1%3C139::AID-SIM644%3E3.0.CO;2-K> and maximum likelihood estimation by Bartlett JW, Stavola DBL & Frost C (2009) <doi:10.1002/sim.3713>. Outcome measurement error correction is implemented by means of the method of moments by Buonaccorsi JP (2010, ISBN:1420066560) and efficient method of moments by Keogh RH, Carroll RJ, Tooze JA, Kirkpatrick SI & Freedman LS (2014) <doi:10.1002/sim.7011>. Standard error estimation of the corrected estimators is implemented by means of the Delta method by Rosner B, Spiegelman D & Willett WC (1990) <doi:10.1093/oxfordjournals.aje.a115715> and Rosner B, Spiegelman D & Willett WC (1992) <doi:10.1093/oxfordjournals.aje.a116453>, the Fieller method described by Buonaccorsi JP (2010, ISBN:1420066560), and the Bootstrap by Carroll RJ, Ruppert D, Stefanski LA & Crainiceanu CM (2006, ISBN:1584886331). |
Depends: | R (≥ 2.10) |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
URL: | https://github.com/LindaNab/mecor |
Imports: | lme4, lmerTest, numDeriv |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
RoxygenNote: | 7.1.2 |
NeedsCompilation: | no |
Packaged: | 2021-12-01 18:59:49 UTC; lindanab |
Repository: | CRAN |
Date/Publication: | 2021-12-01 21:30:02 UTC |
Create a Measurement Error Object
Description
This function creates a measurement error object, usually used as a covariate
or the outcome in the formula
argument of mecor if one
wants to correct for the measurement error in that variable using a reference
variable or a replicate measure.
Usage
MeasError(substitute, reference, replicate, differential)
Arguments
substitute |
a vector containing the error-prone measure |
reference |
a vector containing the reference measure assumed without measurement error |
replicate |
a vector or matrix with replicates of the error-prone measure with classical measurement error. This can either be replicates obtained by using the same measurement method as the substitute measure (replicates study) or replicates using a different measurement method than the substitute measure (calibration study). |
differential |
a vector containing the variable to which the measurement error is differential. |
Value
MeasError
returns an object of class "MeasError".
An object of class MeasError
is a list containing the substitute and
reference (and replicate or differential if applicable) variables and has
attributes input (the name of the substitute and reference or replicate
and differential (if applicable) variables) and call (the matched call).
Author(s)
Linda Nab, l.nab@lumc.nl
Examples
## measurement error in a covariate:
# internal covariate-validation study
data(vat)
with (vat, MeasError(substitute = wc,
reference = vat))
# replicates study
data(bloodpressure)
with (bloodpressure, MeasError(substitute = sbp30,
replicate = cbind(sbp60, sbp120)))
# outcome-calibration study
data(sodium)
with(sodium, MeasError(substitute = recall,
replicate = cbind(urinary1, urinary2)))
## measurement error in the outcome:
# internal outcome-validation study
data(haemoglobin)
with(haemoglobin, MeasError(substitute = capillary,
reference = venous))
# internal outcome- validation study with differential measurement error in
# the dependent variable
data(haemoglobin)
with(haemoglobin, MeasError(substitute = capillary,
reference = venous,
differential = supplement))
Create an External Measurement Error Object
Description
This function creates an external measurement error object, usually used as
a covariate or the outcome in the formula
argument of
mecor if one wants to correct for the measurement error in that
variable using external data or externally estimated coefficients of the
calibration model (covariate-measurement error) or measurement error model
(outcome-measurement error)
Usage
MeasErrorExt(substitute, model)
Arguments
substitute |
a vector containing the error-prone measure |
model |
a fitted linear model of class lm or a named
list. The list contains a vector named |
Value
MeasErrorExt
returns an object of class
"MeasErrorExt".
An object of class MeasErrorExt
is a list containing the substitute
variable and the fitted calibration model or measurement error model and has
attributes input (the name of the substitute variable) and call (the matched
call).
Author(s)
Linda Nab, l.nab@lumc.nl
Examples
## measurement error in a outcome:
# external outcome-validation study
data(haemoglobin_ext)
# calibration model
calmod_fit <- lm(capillary ~ venous, data = haemoglobin)
# the external covariate-validation study can be used to correct for the
# measurement error in X_star in the dataset 'icvs', using the fitted
# calibration model
data(haemoglobin)
with (haemoglobin, MeasErrorExt(substitute = capillary,
model = calmod_fit))
# identical to:
calmod_coef <- coefficients(calmod_fit)
calmod_vcov <- vcov(calmod_fit)
with (haemoglobin, MeasErrorExt(substitute = capillary,
model = list(coef = calmod_coef,
vcov = calmod_vcov)))
# when no external data is available, guesstimations of the coefficients of
# the calibration model can be used instead:
with (haemoglobin, MeasErrorExt(substitute = capillary,
model = list(coef = c('(Intercept)' = -7,
'venous' = 1.1))))
Create a Random Measurement Error Object
Description
This function creates a random measurement error object, usually used as
a covariate in the formula
argument of mecor if one
wants to correct for random measurement error in that variable
Usage
MeasErrorRandom(substitute, variance)
Arguments
substitute |
a vector containing the error-prone measure |
variance |
a numeric quantifying the assumed variance of the random measurement error |
Value
MeasErrorRandom
returns an object of class
"MeasErrorRandom".
An object of class MeasErrorRandom
is a list containing the substitute
variable, the assumed variance of the random measurement error in that variable and, the
attributes input (the name of the substitute variable) and call (the matched
call).
Author(s)
Linda Nab, l.nab@lumc.nl
Examples
## random measurement error in a covariate:
# internal covariate-validation study
data(bloodpressure)
with(bloodpressure, MeasErrorRandom(sbp30, variance = 0.25))
PDAC blood pressure data [replicates study]
Description
Blood pressure, age and creatinine levels of 450 pregnant women from the Pregnancy Day Assessment Clinic.
Usage
bloodpressure
Format
A data frame with 450 rows and 6 variables:
- creatinine
Serum creatinine (umol/L)
- age
Age (years)
- sbp30
Systolic blood pressure at 30 minutes (mm Hg)
- sbp60
Systolic blood pressure at 60 minutes (mm Hg)
- sbp90
Systolic blood pressure at 90 minutes (mm Hg)
- sbp120
Systolic blood pressure at 120 minutes (mm Hg)
Details
This is a simulated dataset inspired by data that was originally published at the Dryad Digital Repository: <doi:10.5061/dryad.0bq15>
References
Elizabeth Anne McCarthy, Thomas A Carins, Yolanda Hannigan, Nadia Bardien, Alexis Shub, and Susan P Walker. Data from: Effectiveness and safety of 1 vs 4h blood pressure profile with clinical and laboratory assessment for the exclusion of gestational hypertension and pre-eclampsia: a retrospective study in a university affiliated maternity hospital. Dryad (2015). <doi:10.5061/dryad.0bq15>.
Examples
data("bloodpressure", package = "mecor")
Low-dose iron supplements haemoglobin data [internal outcome-validation study]
Description
Capillary haemoglobin and venous haemoglobin levels of 400 subjects of a trial investigating the efficacy of low-dose iron supplements during pregnancy. Venous haemoglobin levels were observed of approximately 25% of the subjects included in the trial.
Usage
haemoglobin
Format
A data frame with 400 rows and 3 variables:
- capillary
Haemoglobin levels measured in capillary blood (g/L)
- supplement
Low-dose iron supplement (20 mg/d) (0 = no, 1 = yes)
- venous
Haemoglobin levels measured in venous blood (g/L)
Details
This is a simulated data set inspired by a trial investigating low-dose iron supplements <doi:10.1093/ajcn/78.1.145>. A motivating example using the example data can be found here: <doi:10.1002/sim.8359>
References
Maria Makrides, Caroline A Crowther, Robert A Gibson, Rosalind S Gibson, and C Murray Skeaff. Efficacy and tolerability of low-dose iron supplements during pregnancy: a randomized controlled trial. The American Journal of Clinical Nutrition (2003). <doi:10.1093/ajcn/78.1.145>
Linda Nab, Rolf HH Groenwold, Paco MJ Welsing, and Maarten van Smeden. Measurement error in continuous endpoints in randomised trials: Problems and solutions. Statistics in Medicine (2019). <doi:10.1002/sim.8359>
Examples
data("haemoglobin", package = "mecor")
Haemoglobin external data [external outcome-validation study]
Description
Capillary haemoglobin and venous haemoglobin levels of 100 individuals.
Usage
haemoglobin_ext
Format
A data frame with 100 rows and 2 variables:
- capillary
Haemoglobin levels measured in capillary blood (g/L)
- venous
Haemoglobin levels measured in venous blood (g/L)
Details
This is a simulated data set accompanying the dataset "haemoglobin", that is inspired by a trial investigating low-dose iron supplements <doi:10.1093/ajcn/78.1.145>. A motivating example using the example data can be found here: <doi:10.1002/sim.8359>
References
Maria Makrides, Caroline A Crowther, Robert A Gibson, Rosalind S Gibson, and C Murray Skeaff. Efficacy and tolerability of low-dose iron supplements during pregnancy: a randomized controlled trial. The American Journal of Clinical Nutrition (2003). <doi:10.1093/ajcn/78.1.145>
Linda Nab, Rolf HH Groenwold, Paco MJ Welsing, and Maarten van Smeden. Measurement error in continuous endpoints in randomised trials: Problems and solutions. Statistics in Medicine (2019). <doi:10.1002/sim.8359>
Examples
data("haemoglobin_ext", package = "mecor")
Weighting for Confounding and Joint Misclassification of Exposure and Outcome
Description
ipwm
implements a method for estimating the marginal causal odds ratio by constructing weights (modified inverse probability weights) that address both confounding and joint misclassification of exposure and outcome.
Usage
ipwm(
formulas,
data,
outcome_true,
outcome_mis = NULL,
exposure_true,
exposure_mis = NULL,
nboot = 1000,
conf_level = 0.95,
fix_nNAs = FALSE,
semiparametric = FALSE,
optim_args = list(method = "BFGS"),
force_optim = FALSE,
sp = Inf,
print = TRUE
)
Arguments
formulas |
a list of objects of class |
data |
|
outcome_true |
a character string specifying the name of the true outcome variable that is free of misclassification but possibly unknown ( |
outcome_mis |
a character string specifying the name of the counterpart of |
exposure_true |
a character string specifying the name of the true exposure variable that is free of misclassification but possibly unknown ( |
exposure_mis |
a character string specifying the name of the counterpart of |
nboot |
number of bootstrap samples. Setting |
conf_level |
the desired confidence level of the confidence interval |
fix_nNAs |
logical indicator specifying whether or not to fix the joint distribution of |
semiparametric |
logical indicator specifying whether or not to parametrically sample |
optim_args |
arguments passed onto |
force_optim |
logical indicator specifying whether or not to force the |
sp |
scalar shrinkage parameter in the interval |
print |
logical indicator specifying whether or not to print the output. |
Details
This function is an implementation of the weighting method described by Penning de Vries et al. (2018). The method defaults to the estimator proposed by Gravel and Platt (2018) in the absence of exposure misclassification.
The function assumes that the exposure or the outcome has a misclassified version. An error is issued when both outcome_mis
and exposure_mis
are set to NULL
.
Provided force_optim = FALSE
, ipwm
is considerably more efficient when the optim
function is not invoked; i.e., when (1) exposure_mis = NULL
and the formula for outcome_true
does not contain stats::terms involving outcome_mis
or exposure_true
, (2) outcome_mis = NULL
and the formula for exposure_true
does not contain stats::terms involving exposure_mis
or outcome_true
, or (3) all(is.na(data[, exposure_true]) == is.na(data[, outcome_true]))
and the formulas for exposure_true
and outcome_true
do not contain stats::terms involving exposure_mis
or outcome_mis
. In these cases, ipwm
uses iteratively reweighted least squares via the glm
function for maximum likelihood estimation. In all other cases, optim_args
is passed on to optim
for optimisation of the joint likelihood of outcome_true
, outcome_mis
, exposure_true
and exposure_mis
.
Value
ipwm
returns an object of class ipwm
.
The returned object is a list containing the following elements:
logOR |
the estimated log odds ratio; |
call |
the matched function call. |
If nboot != 0
, the list also contains
SE |
a bootstrap estimate of the standard error for the estimator of the log odds ratio; |
CI |
a bootstrap percentile confidence interval for the log odds ratio. |
Author(s)
Bas B. L. Penning de Vries, b.b.l.penning_de_vries@lumc.nl
References
Gravel, C. A., & Platt, R. W. (2018). Weighted estimation for confounded binary outcomes subject to misclassification. Statistics in medicine, 37(3), 425-436. https://doi.org/10.1002/sim.7522
Penning de Vries, B. B. L., van Smeden, M., & Groenwold, R. H. H. (2020). A weighting method for simultaneous adjustment for confounding and joint exposure-outcome misclassifications. Statistical Methods in Medical Research, 0(0), 1-15. https://doi.org/10.1177/0962280220960172
Examples
data(sim) # simulated data on 10 covariates, exposure A and outcome Y.
formulas <- list(
Y ~ A + L1 + L2 + L3 + L4 + L5 + L6 + L7 + L8 + L9 + L10 + B + Z,
A ~ L1 + L2 + L3 + L4 + L5 + L6 + L7 + L8 + L9 + L10 + B + Z,
Z ~ L1 + L2 + L3 + L4 + L5 + L6 + L7 + L8 + L9 + L10 + B,
B ~ L1 + L2 + L3 + L4 + L5 + L6 + L7 + L8 + L9 + L10
)
## Not run:
ipwm_out <- ipwm(
formulas = formulas,
data = sim,
outcome_true = "Y",
outcome_mis = "Z",
exposure_true = "A",
exposure_mis = "B",
nboot = 200,
sp = 1e6
)
ipwm_out
## End(Not run)
mecor: a Measurement Error Correction Package
Description
mecor provides correction methods for measurement error in a continuous covariate or outcome in linear regression models with a continuous outcome
Usage
mecor(formula, data, method = "standard", B = 0)
Arguments
formula |
an object of class formula (or one that is coerced to that class): a symbolic description of the regression model containing a MeasError, MeasErrorExt or MeasErrorRandom object in one of the covariates or the outcome. |
data |
a data.frame, list or environment (or object coercible by
as.data.frame to a data frame) containing the variables in the model
specified in |
method |
a character string indicating the method used to correct for the measurement error, either "standard" (regression calibration for covariate measurement error and method of moments for outcome measurement error), "efficient" (efficient regression calibration for covariate measurement error and efficient method of moments for outcome measurement error), "valregcal" (validation regression calibration) or "mle" (maximum likelihood estimation). Defaults to "standard". |
B |
number of bootstrap samples, defaults to 0. |
Value
mecor
returns an object of class "mecor".
An object of class mecor
is a list containing the following components:
corfit |
a list containing the corrected fit, including the coefficients
of the corrected fit ( |
uncorfit |
an lm.fit object of the uncorrected fit. |
Author(s)
Linda Nab, l.nab@lumc.nl
References
L. Nab, R.H.H. Groenwold, P.M.J. Welsing, and M. van Smeden. Measurement error in continuous endpoints in randomised trials: problems and solutions
L. Nab, M. van Smeden, R.H. Keogh, and R.H.H. Groenwold. mecor: an R package for measurement error correction in linear models with continuous outcomes
Examples
## measurement error in a covariate/outcome:
# internal covariate-validation study
data(vat)
out <-
mecor(ir_ln ~ MeasError(wc, reference = vat) + sex + age + tbf,
data = vat,
method = "standard",
B = 999)
# replicates study
data(bloodpressure)
mecor(creatinine ~ MeasError(sbp30, replicate = cbind(sbp60, sbp120)) + age,
data = bloodpressure,
method = "mle")
# outcome-calibration study
data(sodium)
mecor(MeasError(recall, replicate = cbind(urinary1, urinary2)) ~ diet,
data = sodium,
method = "efficient")
# external outcome-validation study
data(haemoglobin_ext)
calmod_fit <- lm(capillary ~ venous, data = haemoglobin_ext)
data(haemoglobin) # suppose reference venous is not available
mecor(MeasErrorExt(capillary, model = calmod_fit) ~ supplement,
data = haemoglobin)
# sensitivity analyses
data(vat) # suppose reference vat is not available
# guesstimate the coefficients of the calibration model:
mecor(ir_ln ~ MeasErrorExt(wc, model = list(coef = c(0.2, 0.5, -1.3, 0, 0.6))) + sex + age + tbf,
data = vat)
# assume random measurement error in wc of magnitude 0.25:
mecor(ir_ln ~ MeasErrorRandom(wc, variance = 0.25) + sex + age + tbf,
data = vat)
data(bloodpressure) # suppose replicates sbp60 and sbp60 are not available
mecor(creatinine ~ MeasErrorRandom(sbp30, variance = 25) + age,
data = bloodpressure)
## differential measurement error in the outcome:
# internal outcome-validation study
mecor(MeasError(capillary, reference = venous, differential = supplement) ~ supplement,
data = haemoglobin,
method = "standard")
Simulated dataset for the ipwm function
Description
A simulated dataset containing 5000 observations of the covariates L1-L10, the true exposure A and true outcome Y, and the misclassified exposure B and misclassified outcome Z.
Usage
sim
Format
A data frame with 5000 rows and 14 variables:
- L1
covariate, binary
- L2
covariate, continuous
- L3
covariate, binary
- L4
covariate, continuous
- L5
covariate, binary
- L6
covariate, binary
- L7
covariate, continuous
- L8
covariate, binary
- L9
covariate, binary
- L10
covariate, continuous
- A
exposure, binary
- Y
outcome, binary
- B
misclassified exposure, binary
- Z
misclassified outcome, binary
Examples
data("sim", package = "mecor")
TONE sodium data [outcome-calibration study]
Description
Self-reported sodium intake and urinary sodium in the TONE study, a randomized controlled trial designed to investigate whether a reduction in sodium intake results in satisfactory blood pressure control. Two replicate urinary sodium measures were available in 50% of the subjects included in the trial.
Usage
sodium
Format
A data frame with 1000 rows and 4 variables:
- recall
Sodium intake measured by a 24h recall (mg)
- diet
Usual diet or sodium-lowering diet (0 = usual, 1 = sodium-lowering)
- urinary1
Sodium intake measured in urine (1st measure, mg)
- urinary2
Sodium intake measured in urine (2nd measure, mg)
Details
This is a simulated data set inspired by the TONE study <doi: 10.1016/1047-2797(94)00056-y>. A motivating example using the example data can be found here: <doi:10.1002/sim.7011>
References
Lawrence J Appel, Mark Espeland, Paul K Whelton, Therese Dolecek, Shiriki Kumanyika, William B Applegate, Walter H Ettinger, John B Kostis, Alan C Wilson, Clifton Lacy, and Stephen T Miller. Trial of Nonpharmacologic Intervention in the Elderly (TONE). Design and rationale of a blood pressure control trial. Annals of Epidemiology (1995). <doi: 10.1016/1047-2797(94)00056-y>
Ruth H Keogh, Raymond J Carroll, Janet A Tooze, Sharon I Kirkpatrick, Laurence S Freedman. Statistical issues related to dietary intake as the response variable in intervention trials. Statistics in Medicine (2016). <doi:10.1002/sim.7011>
Examples
data("sodium", package = "mecor")
Summarizing Measurement Error Correction
Description
summary
method for class "mecor"
Usage
## S3 method for class 'mecor'
summary(object, alpha = 0.05, zerovar = FALSE, fieller = FALSE, ...)
Arguments
object |
an object of class "mecor", a result of a call to mecor. |
alpha |
probability of obtaining a type II error. |
zerovar |
a boolean indicating whether standard errors and confidence intervals using the zerovariance method must be added to the summary object. |
fieller |
a boolean indicating whether confidence intervals using the fieller method must be added to the summary object. |
... |
additional arguments affecting the summary produced |
Value
The function summary.mecor
returns a list of summary statistics of the
fitted corrected model and fitted uncorrected model.
call |
the matched call |
c |
summary of the corrected fit |
uc |
summary of the uncorrected fit |
B |
number of bootstrap replicates used |
alpha |
alpha level used |
See Also
The model fitting function mecor, summary
Examples
## measurement error in a covariate:
# internal covariate-validation study
data(vat)
mecor_fit <- mecor(ir_ln ~ MeasError(wc, reference = vat) + sex + age + tbf,
data = vat,
method = "standard")
summary(mecor_fit)
summary(mecor_fit, zerovar = TRUE, fieller = TRUE)
summary(mecor_fit, alpha = 0.10)
NEO visceral adipose tissue data [internal covariate-validation study]
Description
Insulin resistance, waist circumference, sex, age, total body fat and visceral adipose tissue of 650 individuals from the Netherlands Epidemiology of Obesity (NEO) study. Visceral adipose tissue measurements were taken of approximately 40% of the individuals, at random.
Usage
vat
Format
A data frame with 650 rows and 6 variables:
- ir_ln
Natural logarithm of insulin resistance (fasting glucose (mmol/L) x fasting insulin (mU/L) / 22.5)
- wc
Waist circumference (standardised, cm)
- sex
Sex (0 = male, 1 = female)
- age
Age (years)
- tbf
Total body fat (standardised, %)
- vat
Visceral adipose tissue (standardised, cm^2)
Details
This is a simulated data set inspired by the NEO data <doi:10.1007/s10654-013-9801-3>. A motivating example using the example data can be found here: <doi:10.1093/aje/kwab114>
References
Renee de Mutsert, Martin den Heijer, Ton J Rabelink, Johannes WA Smit, Johannes A Romijn, Johan W Jukema, Albert de Roos, Christa M Cobbaert, Margreet Kloppenburg, Saskia le Cessie, Saskia Middeldorp, Frits R Rosendaal. The Netherlands epidemiology of obesity (NEO) study: Study design and data collection. European Journal of Epidemiology (2013). <doi:10.1007/s10654-013-9801-3>
Linda Nab, Maarten van Smeden, Renee de Mutsert, Frits R Rosendaal, and Rolf HH Groenwold. Sampling strategies for internal validation samples for exposure measurement error correction: A study of visceral adipose tissue measures replaced by waist circumference measures. American Journal of Epidemiology (2021). <doi:10.1093/aje/kwab114>
Examples
data("vat", package = "mecor")
Visceral adipose tissue external data [external covariate-validation study]
Description
Waist circumference, visceral adipose tissue, sex, age, and total body fat of 100 individuals
Usage
vat_ext
Format
A data frame with 100 rows and 5 variables:
- wc
Waist circumference (standardised, cm)
- vat
Visceral adipose tissue (standardised, cm^2)
- sex
Sex (0 = male, 1 = female)
- age
Age (years)
- tbf
Total body fat (standardised, %)
Details
This is a simulated data set accompanying the dataset "vat", that is inspired by the NEO data <doi:10.1007/s10654-013-9801-3>. A motivating example using the example data can be found here: <doi:10.1093/aje/kwab114>
References
Renee de Mutsert, Martin den Heijer, Ton J Rabelink, Johannes WA Smit, Johannes A Romijn, Johan W Jukema, Albert de Roos, Christa M Cobbaert, Margreet Kloppenburg, Saskia le Cessie, Saskia Middeldorp, Frits R Rosendaal. The Netherlands epidemiology of obesity (NEO) study: Study design and data collection. European Journal of Epidemiology (2013). <doi:10.1007/s10654-013-9801-3>
Linda Nab, Maarten van Smeden, Renee de Mutsert, Frits R Rosendaal, and Rolf HH Groenwold. Sampling strategies for internal validation samples for exposure measurement error correction: A study of visceral adipose tissue measures replaced by waist circumference measures. American Journal of Epidemiology (2021). <doi:10.1093/aje/kwab114>
Examples
data("vat_ext", package = "mecor")