[R] How to predict the mean and variance of the dependent variable after regression

2010-06-21 Thread Yi
Hi, folks, As seen in the following codes: x1=rlnorm(10) x2=rlnorm(10,mean=2) y=rlnorm(10,mean=10)### Fake dataset linmod=lm(log(y)~log(x1)+log(x2)) After the regression, I would like to know the mean of y. Since log(y) is normal and y is lognormal, I need to know the mean and variance of

Re: [R] How to predict the mean and variance of the dependent variable after regression

2010-06-21 Thread Joshua Wiley
Hello, If you just want the mean and variance of log(y) try: mean(log(y)) var(log(y)) if there is missing data, you can add na.rm=TRUE to both of those. If you want the mean and variance of the predicted ys mean(predict(linmod)) var(predict(linmod)) see ?mean ?var ?predict.lm #the specific

Re: [R] How to predict the mean and variance of the dependent variable after regression

2010-06-21 Thread Joshua Wiley
On Mon, Jun 21, 2010 at 11:45 AM, Yi liuyi.fe...@gmail.com wrote: Hi, Josh, Thank you very much! It is what I want! Because it is very obvious that the variance is not a constant in my linear model. So I am thinking about robust standand error. Any code works for this purpose in R? I do not