It's not clear what you're trying to do. Here is an example of building a model and using predict:
Code:n <- 30 x1 <- rnorm(n) x2 <- runif(n) y <- 2 + x1 - .5*x2 + rnorm(n) dat <- data.frame(y, x1, x2) o <- lm(y ~ x1 + x2, data = dat) # Gives predictions for every value in the data set predict(o, interval = "confidence", level = .90) # If we want new predictions we need to use the newdata # argument newdat <- data.frame(x1 = c(1, 2), x2 = c(.5, .7)) predict(o, newdata = newdat, interval = "confidence", level = .9)





Reply With Quote

