y.hat[i] = predict(fit.new.observation, data.frame(land.area=area[i, 3]))
The fit.new.observation
model is expecting a column called land
in the newdata
argument of predict
, but the column is called land.area
.
Pergunta
When I change my data.frame I get an error and can't do the lm:
observation.not.i = area[-i, ]
fit.new.observation = lm(farm ~ land, data = observation.not.i)
Error is
Error in eval(expr, envir, enclos) : object 'land' not found
I am using this in jackknife procedure as in the following:
r.jack = c(rep(0, 50))
y.hat = c(rep(0, 50))
for (i in 1:50) {
observation.not.i = area[-i, ]
fit.new.observation = lm(farm ~ land, data = observation.not.i)
y.hat[i] = predict(fit.new.observation, data.frame(land.area=area[i, 3]))
r.jack[i] = area[i, 2] - y.hat[i]
}
However when I just run fit=lm(farm~land,data=area)
it works fine. Please let me know if you are aware of the cause of the problem.
Solução
y.hat[i] = predict(fit.new.observation, data.frame(land.area=area[i, 3]))
The fit.new.observation
model is expecting a column called land
in the newdata
argument of predict
, but the column is called land.area
.