MCEMfit_gam {refitME} | R Documentation |
Function for wrapping the MCEM algorithm on gam
objects
Description
Function for wrapping the MCEM algorithm on GAMs where predictors are subject to measurement error/error-in-variables.
Usage
MCEMfit_gam(
mod,
family,
sigma.sq.u,
B = 50,
epsilon = 1e-05,
silent = FALSE,
...
)
Arguments
mod |
: a |
family |
: a specified family/distribution. |
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 ME variances) or a matrix if the ME covariance matrix is known. |
B |
: the number of Monte Carlo replication values (default is set to 50). |
epsilon |
: convergence threshold (default is set to 0.00001). |
silent |
: if |
... |
: further arguments passed to |
Value
MCEMfit_gam
returns the original naive fitted model object but coefficient estimates and the covariance matrix have been replaced with the final MCEM model fit. Standard errors and 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
Ganguli, B, Staudenmayer, J., and Wand, M. P. (2005). Additive models with predictors subject to measurement error. Australian & New Zealand Journal of Statistics, 47, 193–202.
Wand, M. P. (2018). SemiPar: Semiparametic Regression. R package version 1.0-4.2., URL https://CRAN.R-project.org/package=SemiPar.
Stoklosa, J., Hwang, W-H., and Warton, D.I. refitME: Measurement Error Modelling using Monte Carlo Expectation Maximization in R.
See Also
Examples
# A GAM example using the air pollution data set from the SemiPar package.
library(refitME)
library(SemiPar)
library(mgcv)
library(dplyr)
data(milan.mort)
dat.air <- sample_n(milan.mort, 100) # Takes a random sample of size 100.
Y <- dat.air[, 6] # Mortality counts.
n <- length(Y)
z1 <- (dat.air[, 1])
z2 <- (dat.air[, 4])
z3 <- (dat.air[, 5])
w1 <- log(dat.air[, 9]) # The error-contaminated predictor (total suspended particles).
dat <- data.frame(cbind(Y, w1, z1, z2, z3))
gam_naiv <- gam(Y ~ s(w1), family = "poisson", data = dat)
sigma.sq.u <- 0.0915 # Measurement error variance.
B <- 10 # Consider increasing this if you want a more accurate answer.
gam_MCEM <- refitME(gam_naiv, sigma.sq.u, B)
plot(gam_MCEM, select = 1)
detach(package:mgcv)