[R] predict incosistency ?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Sep 25 14:46:20 CEST 2001
On Tue, 25 Sep 2001, Jorge Luis Ojeda Cabrera wrote:
> When fitting model 'y~1', the 'lm' response is ok, but it is not possible
> to get predictions using 'predict'. May be this is a bug, at least i
> think it is somehow
> inconsistent.
>
> > rm(list=ls())
> > d <- data.frame(x=runif(50),y=rnorm(50))
> > plot(d)
> > d.lm <- lm(y~1,data=d)
> > d.lm
>
> Call:
> lm(formula = y ~ 1, data = d)
>
> Coefficients:
> (Intercept)
> 0.1654
>
> > mean(d$y)
> [1] 0.1654461
> > predict(d.lm,data.frame(x=0.5))
> Error in x[[j]] : subscript out of bounds
That's a bug that is already fixed in R-devel. However, there is
another one that may be harder to fix: the model frame is
Browse[1]> data
NULL data frame with 1 rows
and cases was not anticipated.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list