Hi, folks, Here are the codes:
############## y=1:10 x=c(1:9,1) lin=lm(log(y)~x) ### log(y) is following Normal distribution x=5:14 prediction=predict(lin,newdata=x) ##prediction=predict(lin) ############### 1. The codes do not work, and give the error message: Error in eval(predvars, data, env) : numeric 'envir' arg not of length one. But if I use the code after the pound sign, it works. I mean the name of the newdata is x, why it does not work though? 2. Because the prediction is conducted for log(y). I need to get the expected value of y, which is LN distribution, for the new data sets. I need to know the expectation of log(y) and variance of log(y). ##### mean=mean(prediction) sd=sd(prediction) mean_y=exp(mean+0.5*sd^2) ### formula from Normal to LN ###### Is sd(prediction) the correct why to calculate the sigma of the prediction? Or should I just use the value of Residual standard error from summary(lin)? Answer to either question will be appreciated! Thanks Yi [[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.