[R] lm prediction strange error

Dimitris Rizopoulos d.rizopoulos at erasmusmc.nl
Mon Aug 16 14:47:10 CEST 2010


better try it this way:

DF <- data.frame(y = rnorm(100), x = rchisq(100, df = 3))
m <- lm(y ~ x, DF)
predict(m, data.frame(x = seq(-13, 13, 0.5)))


I hope it helps.

Best,
Dimitris


On 8/16/2010 2:37 PM, Trafim Vanishek wrote:
> Dear all,
>
> I have an error in the simple prediction function for lm().
> Maybe someone experienced the same?
>
> xma<- matrix(data = 0, nrow = 100, ncol = 2)
> xma[, 1]<- rnorm(100)
> xma[, 2]<- rchisq(100, df = 3)
>
> m1<- lm(xma[, 1] ~ xma[, 2])
> predict(m1, as.data.frame(seq(-13, 13, 0.5)))
>
>
> Thanks a lot,
> Trafim
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>

-- 
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014



More information about the R-help mailing list