Hello,
In the following I tried 3  versions of an example in R help. Only the two 
first predict command work.
After :

library(splines)
require(stats)

1)
fm1 <- lm(weight ~ bs(height, df = 5), data = women)
ht1  <- seq(57, 73, len = 200)
ph1  <- predict(fm1, data.frame(height=ht1))  # OK
plot(women, xlab = "Height (in)", ylab = "Weight (lb)")
lines(ht1, ph1)

2)
height <- women$height        # 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
weight <- women$weight        # 115 117 120 123 126 129 132 135 139 142 146 150 
154 159 164

fm2 <- lm(weight ~ bs(height, df = 5))
ht2 <- seq(57, 73, len = 200)
ph2 <- predict(fm2, data.frame(height=ht2)) # OK
plot(women, xlab = "Height (in)", ylab = "Weight (lb)")
lines(ht2,ph2)

3)
height <- women$height        # 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
weight <- women$weight        # 115 117 120 123 126 129 132 135 139 142 146 150 
154 159 164

fb3 <- bs(height, df = 5)
fm3 <- lm(weight ~ fb3)
ht3 <- seq(57, 73, len = 200)
ph3 <- predict(fm3, data.frame(height=ht3))  # Error message about newdata. Why 
?
plot(women, xlab = "Height (in)", ylab = "Weight (lb)")
lines(ht3,ph3) # no line

Thanks for the reason of this message.
Alex Randria




        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to