Sorry, for the second question. I stated in a wrong way. My aim is the mean
and sd of each new observation.

#####
mean=fitted(prediction)
######

But I do not know how to get sd for each new observation.

Any tips?

Thanks

Yi



On Wed, Jul 21, 2010 at 2:29 PM, Yi <liuyi.feier@gmail.com> wrote:

> 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]]

