I have a question regarding a prediction for linear model with two variants (multivariant). I am trying to use a model I trained to predict new data. I have this code that trains z in terms of x and y. The data is around 60,000 rows:
fit <- lm(z ~ poly(x, y, degree = 4), data = data)
Then I want to predict just one row by doing the following
x <- -20
y <- 20
data2 <- data.frame(cbind(x,y))
prediction <- predict(fit,data2)
The r throughs this error:
Error in Z[, 2] <- x - alpha[1L] : replacement has length zero
Thanks for your help!
The following code using the reproducible input shown in the Note at the end runs without any error messages.
Note