Skip to content
Prev 304651 / 398506 Next

predict.lm(...,type="terms") question

On Aug 31, 2012, at 3:48 PM, jjthaden wrote:

            
This was the code you offered:

#Ludbrook's data set S1 (except renaming
#his 'x' as 'concn' and his 'y' as 'area')
S1 <- data.frame(
     area = c(2.4,2.6,6.0,6.5,8.9,),
     concn = c(1.1,4,5,8.5,8.5))

There's an extra comma in the "area" vector.
I don't really know  ....  this appears to be a different problem than  
you posed earlier. If you would learn to post with context, we might  
not be in the position of trying to read your mind.
Yes. I have no trouble doing so.

 >  x <- rnorm(15); x2=rnorm(15)
 >  y <- x + x2 +rnorm(15)
 >  fit <- lm(y ~ x+x2)
 >  new <- data.frame(x2 = seq(-3.5, 3.5, 0.5)  )
 >  predict(fit, newdata=new,type="terms", terms="x2")
            x2
1  -4.9230035
2  -4.1850588
3  -3.4471141
4  -2.7091694
5  -1.9712248
6  -1.2332801
7  -0.4953354
8   0.2426093
9   0.9805539
10  1.7184986
11  2.4564433
12  3.1943880
13  3.9323326
14  4.6702773
15  5.4082220
attr(,"constant")
[1] 0.4501911
Hmmm ... Nabble ... definitely part of the problem.