The error is
Error in x$terms %||% attr(x, "terms") %||% stop("no terms component nor attribute") : no terms component nor attribute
To the code
cooked2 <- data.frame(cooked = c(1, 3, 6, nrow = 1) )#predicting with 1,3 and 6 times cooking
predict.lm(model2, newdata = cooked2, interval = "prediction")
Not able to guess what is the issue, since in another code it worked.
Works here
ig1 <- data.frame(ig = c(10, 100, 200)) #predicting with 10,100 and 200 followers
predict.lm(model, newdata = ig1) #predicting with lm since we use lm models in TASK 1
Edit : Model 2 is created by
cor(dw$wb, dw$cooked) #predic ting with the variable cooked
#the result is 0.6047707 which shows the variables are close to postively correlated.
#Now with the help of lm( ) function, we are going to make a linear model. #lm( ) function has two attributes first is a formula where we will use “ wb~ cooked” #because cooked is an independent variable and wb is a dependent variable r
model2 <- lm(wb ~ cooked, data = dw)
print(model2)
summary(model2)