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 family, model.frame, update and predict, and accepts weighted observations via weights. The mod argument specifies the naive fitted model. Make sure the first p input predictor variables in the naive model are the selected error-contaminated predictors variables. Also, the mod argument allows vlgm/vgam (S4 class) model objects when using the posbinomial family – this is a specific function developed for fitting closed population capture–recapture models, see MCEMfit_CR.

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 TRUE, the convergence message (which tells the user if the model has converged and reports the number of iterations required) is suppressed (default is set to FALSE).

...

: further arguments passed through to the function that was used to fit mod, that will be used in refitting. These need only be specified if making changes to the arguments as compared to the original call that produced mod.

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)


[Package refitME version 1.2.2 Index]