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 have much experience in this area, but I do recall reading in Venables and Ripley (Venables, W. N. & Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth Edition. Springer, New York. ISBN 0-387-95457-0) that they have a function for fitting robust linear models in the package that goes with their book. library(MASS) # load the package ?rlm # look at the help documentation > BTW, It is very nice of you to tell me how to look up the function in R. You are welcome. You can also find a lot of information using the RSiteSearch() function. It can search the mailing list archives as well as the documentation. > Actually I don't understand all the information from summary(linmod). I > am looking for books for help. Please let me know, if you happen to know > the right source for this. There are several introductory books you could look at http://www.r-project.org/doc/bib/R-books.html for a partial list. Personally, I found Introductory Statistics with R by Peter Dalgaard very helpful, but there are certainly others. Best regards, Josh > > Thank you again for your help :) > > Yi > > On Mon, Jun 21, 2010 at 11:34 AM, Joshua Wiley <jwiley.ps...@gmail.com> > wrote: >> >> 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 method being used for predict() with model >> objects of class lm >> >> HTH, >> >> Josh >> >> On Mon, Jun 21, 2010 at 11:24 AM, Yi <liuyi.fe...@gmail.com> wrote: >> > 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 >> > log(y) >> > first. I tried mean (y) and mean(linmod), but either one is what I >> > want. >> > >> > Any tips? >> > >> > Thanks in advance! >> > >> > [[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. >> > >> >> >> >> -- >> Joshua Wiley >> Ph.D. Student >> Health Psychology >> University of California, Los Angeles > > -- Joshua Wiley Ph.D. Student Health Psychology University of California, Los Angeles ______________________________________________ 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.