Re: [R] Predictably puzzled.

2021-11-19 Thread David Carlson
All you need is predict(fit, data.frame(x)) or if you had started with a data frame: xy <- data.frame(x, y) fit <- lm(y~x, xy) predict(fit, xy) David Professor Emeritus of Anthropology Texas A&M University College Station, TX On Fri, Nov 19, 2021 at 8:45 PM Rolf Turner wrote: > > On Fri, 19 N

Re: [R] Predictably puzzled.

2021-11-19 Thread Rolf Turner
On Fri, 19 Nov 2021 18:35:23 -0800 Bert Gunter wrote: > ?predict.lm says: > > "predict.lm produces predicted values, obtained by evaluating the > regression function in the frame newdata (which defaults to > model.frame(object)). " > > model.frame(fit) is: > 1 1.37095845 -0.30663859 > 2 -0

Re: [R] Predictably puzzled.

2021-11-19 Thread Bert Gunter
?predict.lm says: "predict.lm produces predicted values, obtained by evaluating the regression function in the frame newdata (which defaults to model.frame(object)). " model.frame(fit) is: 1 1.37095845 -0.30663859 2 -0.56469817 -1.78130843 4 0.63286260 1.21467470 6 -0.10612452 -0.43046913

[R] Predictably puzzled.

2021-11-19 Thread Rolf Turner
Consider the following toy example: set.seed(42) y <- rnorm(20) x <- rnorm(20) y[c(3,5,14,15)] <- NA fit <- lm(y~x) predict(fit) This for some reason, which escapes me, does not provide predicted values when the response/dependent variable is missing, despite there being