Windows 98 R : Copyright 2001, The R Development Core Team Version 1.2.1 (2001-01-15) Dear friends. How comes this works and produce a single prediction: x <- rnorm(15) y <- x + rnorm(15) predict(lm(y ~ x)) new <- data.frame(x = seq(-3, 3, 0.5)) predict(lm(y ~ x), new, se.fit = TRUE) pred.w.plim <- predict(lm(y ~ x), new, interval="confidence") new1 <- data.frame(x=3) predict(lm(y ~ x), new1, interval="confidence") while this refuses to take the "new" and predict ? lot <- c(30,20,60,80,40,50,60,30,70,60) hours <- c(73,50,128,170,87,108,135,69,148,132) z1 <- lm(hours~lot) new <- data.frame(x=80) predict(z1,new,interval="confidence",level=90) best wishes Troels -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Troels Ring wrote:> > Windows 98 > R : Copyright 2001, The R Development Core Team > Version 1.2.1 (2001-01-15) > Dear friends. > How comes this works and produce a single prediction: > x <- rnorm(15) > y <- x + rnorm(15) > predict(lm(y ~ x)) > new <- data.frame(x = seq(-3, 3, 0.5)) > predict(lm(y ~ x), new, se.fit = TRUE) > pred.w.plim <- predict(lm(y ~ x), new, interval="confidence") > new1 <- data.frame(x=3) > predict(lm(y ~ x), new1, interval="confidence") > > while this refuses to take the "new" and predict ? > lot <- c(30,20,60,80,40,50,60,30,70,60) > hours <- c(73,50,128,170,87,108,135,69,148,132) > z1 <- lm(hours~lot) > new <- data.frame(x=80) > predict(z1,new,interval="confidence",level=90)What you want is level=0.9 ??? Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 9 Apr 2001, Troels Ring wrote:> Windows 98 > R : Copyright 2001, The R Development Core Team > Version 1.2.1 (2001-01-15) > Dear friends. > How comes this works and produce a single prediction: > x <- rnorm(15) > y <- x + rnorm(15) > predict(lm(y ~ x)) > new <- data.frame(x = seq(-3, 3, 0.5)) > predict(lm(y ~ x), new, se.fit = TRUE) > pred.w.plim <- predict(lm(y ~ x), new, interval="confidence") > new1 <- data.frame(x=3) > predict(lm(y ~ x), new1, interval="confidence") > > while this refuses to take the "new" and predict ? > lot <- c(30,20,60,80,40,50,60,30,70,60) > hours <- c(73,50,128,170,87,108,135,69,148,132) > z1 <- lm(hours~lot) > new <- data.frame(x=80) > predict(z1,new,interval="confidence",level=90)There's no variable called `lot' in your new data frame. new <- data.frame(lot=80) And you want a 90% not a 90 confidence interval: predict(z1,new,interval="confidence",level=0.9) fit lwr upr [1,] 170 166.9245 173.0755 Now, did you really want a confidence and not prediction interval? -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
You need to change "new <- data.frame(x=80)" to read "new <- data.frame(lot=80)" Alan On Mon, 09 Apr 2001 15:43:13 +0200 Troels Ring <tring at gvdnet.dk> wrote:> Windows 98 > R : Copyright 2001, The R Development Core Team > Version 1.2.1 (2001-01-15) > Dear friends. > How comes this works and produce a single prediction: > x <- rnorm(15) > y <- x + rnorm(15) > predict(lm(y ~ x)) > new <- data.frame(x = seq(-3, 3, 0.5)) > predict(lm(y ~ x), new, se.fit = TRUE) > pred.w.plim <- predict(lm(y ~ x), new, interval="confidence") > new1 <- data.frame(x=3) > predict(lm(y ~ x), new1, interval="confidence") > > while this refuses to take the "new" and predict ? > lot <- c(30,20,60,80,40,50,60,30,70,60) > hours <- c(73,50,128,170,87,108,135,69,148,132) > z1 <- lm(hours~lot) > new <- data.frame(x=80) > predict(z1,new,interval="confidence",level=90) > best wishes > Troels > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._---------------------- Alan T. Arnholt arnholt at math.appstate.edu -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 09 Apr 2001 15:43:13 +0200 Troels Ring <tring at gvdnet.dk> wrote:> lot <- c(30,20,60,80,40,50,60,30,70,60) > hours <- c(73,50,128,170,87,108,135,69,148,132) > z1 <- lm(hours~lot) > new <- data.frame(x=80) > predict(z1,new,interval="confidence",level=90)you will also need to change your level to read .90 versus 90> predict.lm(z1,newdata=new,interval="confidence",level=.90)fit lwr upr [1,] 170 166.9245 173.0755 Alan ---------------------- Alan T. Arnholt arnholt at math.appstate.edu -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Faster than the wind several people spotted the errors>while this refuses to take the "new" and predict ? >lot <- c(30,20,60,80,40,50,60,30,70,60) >hours <- c(73,50,128,170,87,108,135,69,148,132) >z1 <- lm(hours~lot) >new <- data.frame(x=80)new <- data.frame(lot=80) and predict(z1,new,interval="confidence",level=.90)>predict(z1,new,interval="confidence",level=90)Thank you for your efforts and kindness ! Troels -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20010409/73b61a36/attachment.html