misclassMlogit {misclassGLM} | R Documentation |
Mlogit estimation under misclassified covariate
Description
misclassMLogit
computes estimator for a GLM with a misclassified covariate
using additional side information on the misclassification process
Usage
misclassMlogit(
Y,
X,
setM,
P,
na.action = na.omit,
control = list(),
par = NULL,
baseoutcome = NULL,
x = FALSE
)
Arguments
Y |
a matrix of 0s and 1s, indicating the target class. This is the dependent variable. |
X |
a matrix containing the independent variables |
setM |
matrix, rows containing potential patterns for a misclassed (latent) covariate M in any coding for a categorical independent variable, e.g. dummy coding. |
P |
probabilities corresponding to each of the potential pattern conditional on the other covariates denoted in x. |
na.action |
how to treat NAs |
control |
options for the optimization procedure (see |
par |
(optional) starting parameter vector |
baseoutcome |
reference outcome class |
x |
logical, add covariates matrix to result? |
Examples
## simulate data
data <- simulate_mlogit_dataset()
## estimate model without misclassification error
library(mlogit)
data2 <- mlogit.data(data, varying = NULL, choice = "Y", shape = "wide")
summary(mlogit(Y ~ 1 | X + M2, data2, reflevel = "3"))
## estimate model with misclassification error
summary(mlogit(Y ~ 1 | X + M, data2, reflevel = "3"))
## 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
Yneu <- matrix(rep.int(0, nrow(data) * 3), ncol = 3)
for (i in 1:nrow(data)) Yneu[i, data$Y[i]] <- 1
est <- misclassMlogit(Y = Yneu,
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.misclassMlogit(est,
Y = Yneu,
X = data.matrix(data[, 2, drop = FALSE]),
Pmodel = Pmodel,
PX = data,
repetitions = 100))
## End(Not run)
[Package misclassGLM version 0.3.5 Index]