[6431] in s-news-athena
Bug in predict?
daemon@ATHENA.MIT.EDU (Luciano Molinari)
Tue Feb 14 02:52:13 1995
Date: Tue, 14 Feb 1995 08:39:24 +0100
From: Luciano Molinari <molinari@stat.math.ethz.ch>
To: S-news@utstat.toronto.edu
I believe I have come across a minor bug in predict, as documented by the
example given below. I could trace the bug back to model.matrix and I guess
it is in model.frame.default.
I am working with S-Plus for Windows 3.2.
Does anybody have or suggest a fix?
Thanks,
L. Molinari
--------- Example -----------
names(wink)
[1] "PlCh" "PlAT" "Gr"
zzf_lm(PlAT~PlCh*Gr,data=wink)
print(summary(zzf),corr=F)
Call: lm(formula = PlAT ~ PlCh * Gr, data = wink)
Residuals:
Min 1Q Median 3Q Max
-10.35 -3.304 0.5884 3.251 6.963
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 0.0757 3.0618 0.0247 0.9804
PlCh 0.4357 0.0678 6.4238 0.0000
Gr 2.1014 3.0618 0.6863 0.4961
PlCh:Gr -0.1672 0.0678 -2.4651 0.0177
Residual standard error: 4.037 on 44 degrees of freedom
Multiple R-Squared: 0.8848
F-statistic: 112.7 on 3 and 44 degrees of freedom, the p-value is 0
wink[22,]
PlCh PlAT Gr
22 41 8 Pat
wink[26,]
PlCh PlAT Gr
26 41 26 Cntr
fitted(zzf)[22]
22
13.18492
fitted(zzf)[26]
26
22.69162
predict(zzf,data.frame(PlCh=41,Gr="Cntr"))
1
22.69162
predict(zzf,data.frame(PlCh=41,Gr="Pat"))
1
22.69162
predict(zzf,data.frame(PlCh=c(41,41),Gr=c("Pat","Cntr")))
1 2
13.18492 22.69162
model.matrix(delete.response(zzf$terms),data.frame(PlCh=41,Gr="Pat"),
con=zzf$con)
(Intercept) PlCh Gr PlCh:Gr
1 1 41 -1 -41
model.matrix(delete.response(zzf$terms),data.frame(PlCh=41,Gr="Cntr"),
con=zzf$con)
(Intercept) PlCh Gr PlCh:Gr
1 1 41 -1 -41
model.matrix(delete.response(zzf$terms),
data.frame(PlCh=c(41,41),Gr=c("Pat","Cntr")),con=zzf$con)
(Intercept) PlCh Gr PlCh:Gr
1 1 41 1 41
2 1 41 -1 -41
--------- End of Message ---------