refitME {refitME} | R Documentation |
A wrapper function for correcting measurement error in predictor variables via the MCEM algorithm
Description
Function that extracts the fitted (naive) model object and wraps the MCEM algorithm to correct for measurement error/error-in-variables in predictors.
Usage
refitME(mod, sigma.sq.u, B = 50, epsilon = 1e-05, silent = FALSE, ...)
Arguments
mod |
: any (S3 class) fitted object that responds to the generic functions |
sigma.sq.u |
: measurement error (ME) variance. A scalar if there is only one error-contaminated predictor variable, otherwise this must be stored as a vector (of known ME variances) or a matrix if the ME covariance matrix is known. |
B |
: the number of Monte Carlo replication values (default is set 50). |
epsilon |
: convergence threshold (default is set to 0.00001). |
silent |
: if |
... |
: further arguments passed through to the function that was used to fit |
Value
refitME
returns the naive fitted model object where coefficient estimates, the covariance matrix, fitted values, the log-likelihood, and residuals have been replaced with the final MCEM model fit. Standard errors are included and returned, if mod
is a class of object accepted by the sandwich package (such as glm
, gam
, survreg
and many more). The effective sample size (which diagnose how closely the proposal distribution matches the posterior, see equation (2) of Stoklosa, Hwang and Warton) have also been included as outputs.
Author(s)
Jakub Stoklosa, Wen-Han Hwang and David I. Warton.
Source
See https://github.com/JakubStats/refitME for an RMarkdown vignette with examples.
References
Carroll, R. J., Ruppert, D., Stefanski, L. A., and Crainiceanu, C. M. (2006). Measurement Error in Nonlinear Models: A Modern Perspective. 2nd Ed. London: Chapman & Hall/CRC.
Stoklosa, J., Hwang, W-H., and Warton, D.I. refitME: Measurement Error Modelling using Monte Carlo Expectation Maximization in R.
See Also
MCEMfit_glm
, MCEMfit_gam
and MCEMfit_gen
Examples
# A GLM example I - binary response data.
library(refitME)
data(Framinghamdata)
glm_naiv <- glm(Y ~ w1 + z1 + z2 + z3, x = TRUE, family = binomial, data = Framinghamdata)
# The error-contaminated predictor variable in this example is systolic blood pressure (w1).
sigma.sq.u <- 0.01259/2 # ME variance, as obtained from Carroll et al. (2006) monograph.
B <- 50 # The number of Monte Carlo replication values.
glm_MCEM <- refitME(glm_naiv, sigma.sq.u, B)