Dnieper 2012-01-17 10:51, Dunbar, Michael J. piste:

The subject says it all really.

Question 1.
Here is some code created to illustrate my problem, can anyone spot where I'm 
going wrong?

Question 2.
The reason I'm following a manual specification of models relates to the fact 
that in reality I am using mgcv::gam, and I'm not aware that dredge is able to 
separate individual smooth terms out of say s(a,b). Hence an additional 
request, if anyone has example code for using gam in a multimodel inference 
framework, especially with bivariate smooths, I'd be most grateful.

You can model average the coefficients, but not the terms.

Cheers and Thanks in Advance
Mike

require(MuMIn)
data(Cement)
# option 1, create model.selection object using dredge
fm0<- lm(y ~ ., data = Cement)
print(dd<- dredge(fm0))
fm1<- lm(formula = y ~ X1 + X2, data = Cement)
fm2<- lm(formula = y ~ X1 + X2 + X4, data = Cement)
fm3<- lm(formula = y ~ X1 + X2 + X3, data = Cement)
fm4<- lm(formula = y ~ X1 + X4, data = Cement)
fm5<- lm(formula = y ~ X1 + X3 + X4, data = Cement)
# ranked with AICc by default
# obviously this works
model.avg(get.models(dd, delta<  4))

#  option 2: the aim is to produce a model selection object comparable to that 
from get.models(dd, delta<  4)
# but from a manually-specified list of models
my.manual.selection<- mod.sel(list(fm1, fm2, fm3, fm4, fm5))
# works
model.avg(list(fm1, fm2, fm3, fm4, fm5)) # or jut model.avg(fm1, fm2, fm3, fm4, 
fm5)
# doesn't work
model.avg(my.manual.selection)

# hence this doesn't work
get.models(my.manual.selection, delta<  4)

There is no need to recreate the models (which is what get.models does) once you have them already as a list.

models <- list(fm1, fm2, fm3, fm4, fm5)
my.manual.selection <- mod.sel(models)
model.avg(models[ my.manual.selection$delta < 4 ])

______________________________________________
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.

Reply via email to