Description Usage Arguments Value Author(s) Source References See Also Examples
View source: R/refitME_package.r
Function that extracts the fitted (naive) model object and wraps the MCEM algorithm to correct for measurement error/error-in-variables in predictors.
1 |
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 |
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.
Jakub Stoklosa, Wen-Han Hwang and David I. Warton.
See https://github.com/JakubStats/refitME for an RMarkdown vignette with examples.
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.
MCEMfit_glm
, MCEMfit_gam
and MCEMfit_gen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.