Hi,
the predict-function is not very good in guessing names from a given new dataset. So if you want to predict x1 from some new x2 values, your newdata argument should contain some x2 - values.

predict(model, newdata=data.frame(x2=seq(0,4)), interval = c("confidence"), level = 0.90,type="response")

without that, predict uses your old x2 values and issues a warning message.


Martin Batholdy schrieb:
hi,


I don't know what I am doing wrong,

but with that code;


x1 <- c(1.60, 0.27, 0.17, 1.63, 1.37, 2.00, 0.90, 1.07, 0.89, 0.43, 0.37, 0.59,
0.47, 1.83, 1.79, 0.90, 0.72, 1.83, 0.23, 1.97, 2.03, 2.19, 2.03, 0.86)

x2 <- c(1.30, 0.24, 0.20, 0.50, 1.33, 1.87, 1.30, 0.75, 1.07, 0.43, 0.37, 0.87,
1.40, 1.37, 1.63, 0.80, 0.57, 1.60, 0.39, 2.03, 1.90, 2.07, 1.93, 0.93)

model <- lm(x1 ~ x2)

predict(model, newdata=data.frame(x=seq(0,4)), ,interval = c("confidence"), level = 0.90,type="response")




I get an error message saying "newdate has four lines, but the variable found has 24"


what is wrong in the code?


thanks!
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to