R's predict.lm() fails when trying to compute term-wise confidence (or prediction) intervals for a subset of the terms in a model:
> dat <- data.frame(y=log(1:10), x=1:10, fac=rep(LETTERS[11:13],c(3,3,4))) > fit <- lm(y~fac*x, data=dat) > # can compute intervals for all terms > pfit <- predict(fit, type="terms", interval="confidence", newdata=dat[7:5,]) > # error computing intervals for a subset of the terms > pfit2 <- predict(fit, type="terms", terms=c("x","fac"), interval="confidence", newdata=dat[7:5,])Error in predictor + hwid : non-conformable arrays > # pfit2 should be the same as pfit2Expected > pfit2Expected <- lapply(pfit2, function(x)if(is.matrix(x)) structure(x[, c("x","fac")], constant=attr(x, "constant")) else x) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel