Run glm.mids on a subset of imputed data from mice (R) -
Run glm.mids on a subset of imputed data from mice (R) -
i error when seek run glm.mids
on subset of mids
imputation object:
library(mice) imp2 = mice(nhanes) glm.mids( (hyp==2)~bmi+chl, data=imp2, subset=(age==1) )
gives cryptic error message
"error in eval(expr, envir, enclos) : ..1 used in wrong context, no ... in"
even though syntax works regular glm
on original dataset:
glm( (hyp==2)~bmi+chl, data=nhanes, subset=(age==1) )
the documentation ?glm.mids
doesn't address subset
says can pass additional parameters onto glm
. if can't utilize subset
glm.mids
, there way subset mids
list object directly?
i have taken liberty of rewriting glm.mids
. bit kludgy. issue seems stem implicit nature attributes passed glm.
also see these post:
https://stat.ethz.ch/pipermail/r-help/2003-november/041537.html
http://r.789695.n4.nabble.com/question-on-passing-the-subset-argument-to-an-lm-wrapper-td3009725.html
library(mice) glm.mids=function (formula, family = gaussian, data, ...) { phone call <- match.call() if (!is.mids(data)) stop("the info must have class mids") analyses <- as.list(1:data$m) (i in 1:data$m) { data.i <- complete(data, i) analyses[[i]] <- do.call("glm",list(formula=quote(formula),family=quote(family),data=quote(data.i),...)) } object <- list(call = call, call1 = data$call, nmis = data$nmis, analyses = analyses) oldclass(object) <- c("mira", "glm", "lm") return(object) } imp2 = mice(nhanes) glm.mids( (hyp==2)~bmi+chl, data=imp2 ,subset=quote(age==1))
the part rewrote glm function phone call within glm.mids analyses[[i]] <- do.call("glm",list(formula=quote(formula),family=quote(family),data=quote(data.i),...))
in old version read analyses[[i]] <- glm(formula, family = family, info = data.i,...)
r subset r-mice
Comments
Post a Comment