[R] Slight discrepancy between predict.lm() and all.effects()
Michael Kubovy
kubovy at virginia.edu
Tue Nov 28 03:24:42 CET 2006
In the course of exploring response prediction, I stumbled upon a
small discrepancy between the CIs produced by predict.lm() and
all.effects()
require(mlmRev)
require(effects)
hsb.lm <- lm(mAch ~ minrty * sector, Hsb82)
hsb.new <- data.frame(
minrty = rep(c('No', 'Yes'), 2),
sector = rep(c('Public', 'Catholic'), each = 2))
hsb.eff <- all.effects(hsb.lm)
cbind(
hsb.new,
predict(hsb.lm, hsb.new, interval = 'confidence', type =
'response')
)
# the following lower and upper bounds differ starting with the
fourth decimal place
data.frame(
hsb.new,
fit = hsb.eff[[1]]$fit,
lwr = hsb.eff[[1]]$lower,
upr = hsb.eff[[1]]$upper
)
Is this due to rounding or algorithm?
_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400 Charlottesville, VA 22904-4400
Parcels: Room 102 Gilmer Hall
McCormick Road Charlottesville, VA 22903
Office: B011 +1-434-982-4729
Lab: B019 +1-434-982-4751
Fax: +1-434-982-4766
WWW: http://www.people.virginia.edu/~mk9y/
More information about the R-help
mailing list