Sherrie Jin
2010-May-30 09:05 UTC
[R] How can I fit a fixed-effect linear model or generalized linear model with method="ml"?
Hi, I want to fit a linear model (without any random effect) with method "ml". I tried to use "glm" I found that there is no option for "ml" or "reml" and the default one is "reml". THen I tried to use "lme" but it requires a random effect. How can I fix this problem? Of course, it's not necessary to be "glm" or "lme", I am just looking for commands which allow me to fit a linear model (without any random effect) with "ml" method. And later I may also need to fit generalized linear models (probit, gamma and negtive binomial) with method "ml". Any suggestions? Thanks. [[alternative HTML version deleted]]
Achim Zeileis
2010-May-30 10:02 UTC
[R] How can I fit a fixed-effect linear model or generalized linear model with method="ml"?
On Sun, 30 May 2010, Sherrie Jin wrote:> Hi, > > I want to fit a linear model (without any random effect) with method "ml". I > tried to use "glm" I found that there is no option for "ml" or "reml" and > the default one is "reml". THen I tried to use "lme" but it requires a > random effect. How can I fix this problem? > > Of course, it's not necessary to be "glm" or "lme", I am just looking for > commands which allow me to fit a linear model (without any random effect) > with "ml" method. And later I may also need to fit generalized linear models > (probit, gamma and negtive binomial) with method "ml". Any suggestions?glm() always performs Maximum Likelihood estimation and thus has no method="ml" argument. Z> Thanks. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
Doran, Harold
2010-May-30 10:34 UTC
[R] How can I fit a fixed-effect linear model or generalized linear model with method="ml"?
Why are you not using the lm() function? OLS is ML with no random effects ________________________________________ From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Sherrie Jin [jingoosy at gmail.com] Sent: Sunday, May 30, 2010 5:05 AM To: r-help at r-project.org Subject: [R] How can I fit a fixed-effect linear model or generalized linear model with method="ml"? Hi, I want to fit a linear model (without any random effect) with method "ml". I tried to use "glm" I found that there is no option for "ml" or "reml" and the default one is "reml". THen I tried to use "lme" but it requires a random effect. How can I fix this problem? Of course, it's not necessary to be "glm" or "lme", I am just looking for commands which allow me to fit a linear model (without any random effect) with "ml" method. And later I may also need to fit generalized linear models (probit, gamma and negtive binomial) with method "ml". Any suggestions? Thanks. [[alternative HTML version deleted]] ______________________________________________ R-help at 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.
Sherrie Jin
2010-May-30 16:44 UTC
[R] How can I fit a fixed-effect linear model or generalized linear model with method="ml"?
Thanks for your reply. I should have made my question clearer. Yes, I want to estimate standard errors with the method "ml" rather than "reml". According to your suggestion, I looked at the source code for "summary.glm". Now I know it's "summary.glm" rather than "glm" itself estimates the standard errors. So it must be "summary.glm" that uses "reml" as a default to compute standard errors. But when I read the source code for "summary.glm", I'm still confused. How can I modify the code to re-compute the standard errors with method "reml"? I'm pretty new to R and haven't write any code by myself. Thanks. On Sun, May 30, 2010 at 8:01 AM, Prof Brian Ripley <ripley@stats.ox.ac.uk>wrote:> On Sun, 30 May 2010, Achim Zeileis wrote: > > On Sun, 30 May 2010, Sherrie Jin wrote: >> >> Hi, >>> >>> I want to fit a linear model (without any random effect) with method >>> "ml". I >>> tried to use "glm" I found that there is no option for "ml" or "reml" >>> and >>> the default one is "reml". THen I tried to use "lme" but it requires a >>> random effect. How can I fix this problem? >>> >>> Of course, it's not necessary to be "glm" or "lme", I am just looking for >>> commands which allow me to fit a linear model (without any random effect) >>> with "ml" method. And later I may also need to fit generalized linear >>> models >>> (probit, gamma and negtive binomial) with method "ml". Any suggestions? >>> >> >> glm() always performs Maximum Likelihood estimation and thus has no >> method="ml" argument. >> > > ML of what? For the coefficients, yes. However, for parameters in the > distribution estimated via the dispersion, not usually and not in the case > of sigma^2 for the gaussian. > > Strictly, neither lm() not glm() estimate the dispersion, but their > summary() methods do. However, you can use your own estimate of dispersion > and supply it to summary.glm (but not summary.lm): you can also use gls() > from package nlme. MASS (the book) discusses how to get MLE for a gamma > glm, for example, and MASS::glm.nb fits a negative binomial glm with > parameters estimated by ML. > > -- > Brian D. Ripley, ripley@stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/<http://www.stats.ox.ac.uk/%7Eripley/> > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UK Fax: +44 1865 272595 >[[alternative HTML version deleted]]