misclassGLM {misclassGLM} | R Documentation |
GLM estimation under misclassified covariate
Description
misclassGLM
computes estimator for a GLM with a misclassified covariate
using additional side information on the misclassification process
Usage
misclassGLM(
Y,
X,
setM,
P,
na.action = na.omit,
family = gaussian(link = "identity"),
control = list(),
par = NULL,
x = FALSE,
robust = FALSE
)
Arguments
Y |
a vector of integers or numerics. This is the dependent variable. |
X |
a matrix containing the independent variables. |
setM |
(optional) matrix, rows containing potential patterns for a misclassified (latent) covariate M in any coding for a categorical independent variable, e.g. dummy coding (default: Identity). |
P |
probabilities corresponding to each of the potential pattern conditional on the other covariates denoted in x. |
na.action |
how to treat NAs |
family |
a description of the error distribution and link function to be used in the model.
This can be a character string naming a family function, a family function or the result
of a call to a family function. (See |
control |
options for the optimization procedure (see |
par |
(optional) starting parameter vector |
x |
logical, add covariates matrix to result? |
robust |
logical, if true the computed asymptotic standard errors are replaced by their robust counterparts. |
Examples
## simulate data
data <- simulate_GLM_dataset()
## estimate model without misclassification error
summary(lm(Y ~ X + M2, data))
## estimate model with misclassification error
summary(lm(Y ~ X + M, data))
## estimate misclassification probabilities
Pmodel <- glm(M2 ~ M + X, data = data, family = binomial("logit"))
summary(Pmodel)
## construct a-posteriori probabilities from Pmodel
P <- predict(Pmodel, newdata = data, type = "response")
P <- cbind(1 - P, P)
dimnames(P)[[2]] <- c("M0", "M1") ## speaking names
## estimate misclassGLM
est <- misclassGLM(Y = data$Y,
X = as.matrix(data[, 2, drop = FALSE]),
setM = matrix(c(0, 1), nrow = 2),
P = P)
summary(est)
## and bootstrapping the results from dataset
## Not run:
summary(boot.misclassGLM(est,
Y = data$Y,
X = data.matrix(data[, 2, drop = FALSE]),
Pmodel = Pmodel,
PX = data,
repetitions = 100))
## End(Not run)