[R] AIC in MuMIn

Gavin Simpson gavin.simpson at ucl.ac.uk
Wed Aug 18 10:21:24 CEST 2010


On Wed, 2010-08-18 at 08:51 +0100, Gavin Simpson wrote:
> On Wed, 2010-08-18 at 05:42 +0800, elaine kuo wrote:
> > Thank you.
> > Most of the answers solved the puzzles.
<snip />
> >  => Please explain why fitted lm is better for GLM.
> 
> Seriously? A GLM specified as glm(...., family = gaussian) is the linear
> model that you'd get with lm(). lm() fits the model far more efficiently
> than glm(). The code you showed specifically used 'family = gaussian',
> hence my comment.

Hmmm. Thinking some more, I might not have answered your (unstated)
question. What do your mean by GLM?

I mean the Generalized Linear Model, not the General Linear Model. The
Generalized one allows for non-normal responses and different
mean-variance relationships and is the GLM of Nelder and Wedderburn
(1972, J. Royal Statistical Society, Series A, 135(3),370-384) and the
monograph by McCullagh and Wedderburn (1989, Generalized Linear Models,
Chapman & Hall/CRC). The R function glm() fits these kinds of model.

The General Linear Model (IIRC) was the linking of linear regression and
anova into a single entity. The R function lm() fits these kinds of
models.

The linear model is a special case of the Generalized Linear Model when
the Gaussian error is used with the identity link function. Hence a
Gaussian GLM (my GLM) with the identity link fitted by glm() will give
the same results as lm(), but it will do so in a very inefficient
manner. As this was what your code was doing I suggested using lm()
instead.

HTH

G

> 
> >         But temp_ran is not in your model...
> >         
> >         > error in eval(expr, envir, enclos), 'temp_ran' not found
> >         
> >         
> >         When used properly (none of this datam.std$ business), subset
> >         will do
> >         what you want:
> >         
> >         > dd2 <- dredge(lm1, subset = X1)
> >         > dd2
> >         Global model: lm(formula = y ~ ., data = Cement)
> >         ---
> >         Model selection table
> >            (Int)        X     X1     X2      X3      X4 k   R.sq
> >         Adj.R.sq     RSS
> >         3   52.58          1.4680 0.6623                 4 0.9787
> >         0.9744   57.90
> >         
> >         
> > => Please suggest how to define subset in my case
> 
> How would I know? I still haven't seen your data. You seem to be
> mistaken on what is and is not included in your model and you fitted it.
> What hope do we have...? However, given the model 'mig.stds' from above
> in this email:
> 
> > mig.stds <-lm(SummerM_ratio ~ temp_max + evi_mean + topo_var +
> >              topo_mean + coast + Iso_index_0808,
> >              ## now tell R were to find the variables in formula
> >              data = datum.std)
> > ## If you are fitting a Gaussian GLM it is better fitted with lm()
> 
> If you want to consider dredged models containing temp_max, then you
> would do
> 
> dredge(mig.stds, subset = temp_max)
> 
> If you want models that contain temp_max and coast, then you'd do
> 
> dredge(mig.stds, subset = temp_max & coast)
> 
> or
> 
> dredge(mig.stds, fixed = ~ temp_max + coast)
> 
> The bits you include in subset or fixed are the names of your variables
> that you want in or out of the models. In your case, the names of the
> variables as input into the model formula. With 'subset' you need to use
> logical operators (and [&], or [|]) whilst with 'fixed' you can specify
> a formula of variables that should be included or excluded in the same
> way you'd write any R formula.
> 
> But, now having been told this, please note that this is *all* discussed
> on the ?dredge help page if you bother to read it. I've never used this
> package, and, OK, I have used R for going on for 11 or 12 years now so
> am used to reading help pages and understand the language a bit more you
> perhaps do, but you do seem to be asking questions or running into
> problems that are all covered by the help pages.
> 
> > Finally, it would be highly appreciated to recommend any references of
> > R for a beginner like me.
> 
> Read the An Introduction to R manual that comes with R or that can be
> downloaded from the R website/CRAN. Also look at the contributed
> documentation section on the R website which contains numerous free
> introductory guides.
> 
> > Elaine
> 
> HTH
> 
> G
> -- 
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
>  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> 
> ______________________________________________
> 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.

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list