I *do* see the same phenomenon that Bert describes and the code of predict.lm()
*does* appear to contain a bug.  There is a line:

XRinv <- if (missing(newdata) && is.null(w))

But "w" gets assigned (as object$weights) only if (is.null(scale)).

If that assignment is moved outside of the applicable "if field" (e.g. and is put
just after the line:

if (se.fit || interval != "none") {

then predict.lm() throws no error.

> sessionInfo()
R version 3.0.2 Patched (2013-09-26 r64005)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods base

other attached packages:
[1] fortunes_1.5-0 misc_0.0-15

loaded via a namespace (and not attached):
[1] tools_3.0.2

The operative difference between my set-up and Chuck's is that I am using
version 3.0.2 Patched.  So I am very puzzled as to why Chuck does *not* get
an error thrown!

BTW traceback() was not helpful:

> predict(z,int="conf",scale=1)
Error in predict.lm(z, int = "conf", scale = 1) : object 'w' not found
> traceback()
2: predict.lm(z, int = "conf", scale = 1)
1: predict(z, int = "conf", scale = 1)

    cheers,

    Rolf


On 11/16/13 10:55, Charles Berry wrote:
Bert Gunter <gunter.berton <at> gene.com> writes:

Yes, I realize that it is more likely  a misunderstanding on my part.
Suitable humility will be tendered if this is pointed out.

The claimed "bug" is that predict.lm throws an error when the scale
argument is specified with interval = "conf" (and in some other
cases):

z <- lm(rnorm(10)~I(1:10))
predict(z,int="conf",scale=1)
Error in predict.lm(z, int = "conf", scale = 1) : object 'w' not found

R version 3.0.2 (2013-09-25)
Platform: i386-w64-mingw32/i386 (32-bit)

Cheers,
Bert

I do not see this (see below).

Maybe traceback() or options(recover=browser) to get
to the bottom??



z <- lm(rnorm(10)~I(1:10))
predict(z,int="conf",scale=1)
           fit        lwr       upr
1  0.02491723 -1.1270591 1.1768935
2  0.06402057 -0.9129873 1.0410284
3  0.10312392 -0.7185606 0.9248085
4  0.14222726 -0.5569958 0.8414504
5  0.18133060 -0.4477852 0.8104464
6  0.22043395 -0.4086818 0.8495497
7  0.25953729 -0.4396858 0.9587604
8  0.29864063 -0.5230439 1.1203252
9  0.33774398 -0.6392639 1.3147518
10 0.37684732 -0.7751290 1.5288236
version
                _
platform       x86_64-apple-darwin10.8.0
arch           x86_64
os             darwin10.8.0
system         x86_64, darwin10.8.0
status
major          3
minor          0.2
year           2013
month          09
day            25
svn rev        63987
language       R
version.string R version 3.0.2 (2013-09-25)
nickname       Frisbee Sailing
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to