[Rd] predict.lm(...., se=T), with 1-column model matrix (PR#1018)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
08 Jul 2001 14:05:24 +0200


john.maindonald@anu.edu.au writes:

> #       r-bugs@r-project.org
> 
> The problem occurs when the model matrix has a single
> column.
> 
> > elastic <- data.frame(stretch=c(46,54,48,50,44,42,52),
>    distance=c(183,217,189,208,178,150,249))
> > elastic.lm <- lm(distance ~ -1 + stretch, data=elastic)
> 
> > predict(elastic.lm,se=T)
> Error in XRinv^2 %*% rep(res.var, p) : non-conformable arguments
> 
> The fix is to replace 
>   XRinv <- qr.Q(object$qr)[, p1]
> with
>   XRinv <- qr.Q(object$qr)[, p1, drop=FALSE]
> 
> The statement is five lines above XRinv^2 %*% rep(res.var, p)
> 

Ick! Thanks.

For a workaround, notice that

> predict(elastic.lm,se=T,new=elastic)
$fit
       1        2        3        4        5        6        7 
188.8946 221.7458 197.1074 205.3202 180.6818 172.4690 213.5330 

$se.fit
[1] 6.423642 7.540797 6.702930 6.982219 6.144353 5.865064 7.261508

$df
[1] 6

$residual.scale
[1] 17.79576


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._