On Tue, 2010-10-12 at 19:37 +0800, elaine kuo wrote:> Dear List,
>
> I want to ask a AIC question based on package library(MuMIn)
>
> The relative importance of 16 explanatory variables
>
> are assessed using delta AIC in a generalized linear model.
>
>
> Please kindly advise if it is possible to show models
Using the below example you quote:
dd <- dredge(lm1, subset = X1 & X2)
>
> with any two only certain variables.
If you are now going to ask how can I select only those models with two
variables in, this:
dd <- dredge(lm1)
parms <- !is.na(dd[, -c(1, (ncol(dd) - c(0:7)))])
want <- which(rowSums(parms) == 2)
dd[want, ]
will do it, again using the example you quote.
HTH
G
> Thank you.
>
>
> Elaine
>
> I asked a similar question and got a great help for models
>
> with only one variable as below.
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> In effect, you want
>
> data(Cement)
> lm1 <- lm(y ~ ., data = Cement)
> dd <- dredge(lm1, subset = X1)
>
> want <- with(dd, is.na(X) & is.na(X2) & is.na(X3) &
is.na(X4))
> want
> ## how many models selected?
> sum(want)
> ## OK selected just 1, show it
> dd[want, , drop = FALSE]
>
> Oh, actually, I suppose you could automate this, so it will return all
> models with single variable:
>
> dd <- dredge(lm1)
> parms <- !is.na(dd[, -c(1, (ncol(dd) - c(0:7)))])
> want <- which(rowSums(parms) == 1)
> dd[want, ]
>
> Having said all this, I don't think this is a good way to do model
> selection.
>
> G
>
> [[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.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%