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.lmCall: 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> predict(d.lm,data.frame(x=c(0.05,0.25,0.5)))Error in x[[j]] : subscript out of bounds>I am using a little bit older version> version_ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 1 minor 2.3 year 2001 month 04 day 26 language R>Thanks in advance. Best, Jorge. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Jorge Luis Ojeda Cabrera <jojeda at posta.unizar.es> writes:> 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.....> I am using a little bit older version...> major 1 > minor 2.3Well we can't fix bugs retroactively... The NEWS file for 1.3.1 has this under "BUG FIXES": o predict.lm() failed with single-column model matrix (PR#1018). -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 boundsThat'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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._