Using the glmulti package in R for exhaustive search multiple regression for akaike weights

后端 未结 1 1233
离开以前
离开以前 2021-02-04 18:49

I was wondering if someone could help me understand why I am getting an error message when I enter a script into R. For abit of background information I am looking into

1条回答
  •  既然无缘
    2021-02-04 19:13

    This worked for me. I think the main thing is not to blindly include all the parameters in the model call. Most of these have default values, thus (if the package writer has done their job) you should be able to leave them as they are and not worry too much (although of course you should RTFM and (try to) understand what they mean ...)

    dat <- read.csv("GPPdriversRhineland.csv")
    library(glmulti)
    

    I decided to rename the predictors with shorter tags:

    prednames <- c("NDVI","solar.rad","avg.temp","precip",
                    "nutr.avail","water.cap")
    names(dat)[1:6] <- prednames
    

    This is all you need to fit all combinations of main effects: since you have six predictors, there are 64 level-1 models (including the null model).

    g1 <- glmulti("GPP",xr=prednames,data=dat,level=1)
    

    For a bigger computational challenge:

    g2 <- glmulti("GPP",xr=prednames,data=dat,level=2)
    

    I believe there are 2^(choose(6,2)+6) = 2.1 million possible models here. I haven't looked at ?glmulti closely enough to tell it how to stop fitting models. I just started it off (so far it has evaluated 66,000 models), but it has found a 2-level model with AIC about 500.5, which is much better than the min-AIC of 518 in the set of 1-level models ...

    PS I played around with settings a bit more, trying the genetic algorithm approach rather than the exhaustive approach (I don't see an obvious way to tell glmulti "use the exhaustive approach, but stop after N tries"). Even with slightly more permissive-than-default genetic algorithm settings, it seems to get stuck at AIC approx 504, above the value found in the (partial) exhaustive screening I tried first.

    e.g.:

    g2 <- glmulti("GPP",xr=prednames,data=dat,level=2,marginality=TRUE,
                  method="g",conseq=25,popsize=500,mutrate=1e-2)
    

    PPS: the reason I was getting better results in the exhaustive case was that I had marginality=FALSE, i.e. the model was allowed to leave out main-effect parameters that were involved in interactions included in the model. This isn't necessarily sensible. If I turn off the marginality constraint, then the genetic algorithm can get down to AIC=499 without too much trouble ...

    glmulti("GPP",xr=prednames,data=dat,level=2,marginality=TRUE,
                  method="d")
    

    is also useful: it prints out the number of candidate models defined for a given specification.

    0 讨论(0)
提交回复
热议问题