The gls function in the nlme package is one approach. If you know the covariance matrix exactly (it is just numerical with nothing that needs to be estimated) then you can also take the Cholesky decomposition of the inverse of the covariance matrix (or other square root method) and multiply the x matrix and y vector by this root, then do ordinary least squares.
Another possibility is generalized estimating equations (gee) which I think are implemented in a few different packages. On Wed, Nov 28, 2012 at 4:03 PM, Emese Vágó <vagoem...@hotmail.com> wrote: > > > > Hi all, > > > > I would > like to do a weighted linear regression, when the error of the dependent > variable > is correlated. So I have a weighting (covariance) matrix instead of a > vector. As > I understood the weights argument in the lm function should be a vector > and > not a matrix. Can anyone suggest me a function (package) which would do the > job? > > > Thanks a > lot! > > > > Emese > > > [[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. > > -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[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.