Machteld Vandecandelaere
2012-Nov-08 10:24 UTC
[R] Package "glmulti": Include a variable in ALL models
Dear all, I have a question about the glmulti package. I want to include some variables in all models. To that end I applied the wrapper function as shown in the examples (http://www.inside-r.org/packages/cran/glmulti/docs/glmulti). To include the variable "Geslacht" in all models:> glm.redefined = function(formula, data, always="", ...) {glm(as.formula(paste(deparse(formula), always)), data=data, ...)} > output<-glmulti(ZBK3~ Onafhankelijk*Zelfconcept*Hyperactief*Populariteit, data=IME, fitfunc=glm.redefined, level=2, crit=aic, method="g", always= "+Geslacht")However, in the output, the variable "Geslacht" is not included... :> print(output)glmulti.analysis Method: g / Fitting: glm.redefined / IC used: aic Level: 2 / Marginality: FALSE>From 100 models:Best IC: -1212.52589228289 Best model: [1] "ZBK3 ~ 1 + Onafhankelijk + Hyperactief + Populariteit + Populariteit:Onafhankelijk + " [2] " Populariteit:Zelfconcept + Populariteit:Hyperactief" [1] "ZBK3 ~ 1 + Onafhankelijk + Hyperactief + Populariteit + Populariteit:Onafhankelijk" [1] "ZBK3 ~ 1 + Onafhankelijk + Hyperactief + Populariteit + Populariteit:Onafhankelijk + " [2] " Populariteit:Zelfconcept" [1] "ZBK3 ~ 1 + Onafhankelijk + Hyperactief + Populariteit + Populariteit:Onafhankelijk + " [2] " Populariteit:Hyperactief" Evidence weight: 0.0594426803705217 Worst IC: -1203.94552868636 16 models within 2 IC units. 67 models to reach 95% of evidence weight. Convergence after 700 generations. Time elapsed: 4.5986722668012 minutes. Hopefully you can tell me what is wrong here. Thank you very much in advance, Kind regards, Machteld Machteld Vandecandelaere University of Leuven - Centre for Educational Effectiveness and Evaluation Dekenstraat 2, box 3773 - room VHI 2.43 B-3000 Leuven Tel: + 0032 16 325 780 E-mail: Machteld.Vandecandelaere@ppw.kuleuven.be<mailto:Machteld.Vandecandelaere@ppw.kuleuven.be> URL: http://ppw.kuleuven.be/o_en_o/COE [[alternative HTML version deleted]]
Machteld VDC
2012-Nov-08 14:49 UTC
[R] Package "glmulti": Include a variable in ALL models
Solved! Thanx to Vincent Calcagno: /Dear Machteld, In the coming 2.0 version of glmulti, there will be a more proper way to force variables in. In the current version, it has to be done ad-hoc, and you did it well. The 'formulas' only show terms that are shuffled by glmulti; the constant terms are always there but they do not show up. To make sure of this, get the fitted model objects themselves (output at objects[[1]] for instance) and print their summary: they will include the forced variable in their formula. Best wishes, Vincent/ Also possible with the coef(object) call. ----- Machteld Vandecandelaere University of Leuven - Centre for Educational Effectiveness and Evaluation Dekenstraat 2, box 3773 ? room VHI 2.43 B-3000 Leuven Tel: + 0032 16 325 780 E-mail: Machteld.Vandecandelaere at ppw.kuleuven.be URL: http://ppw.kuleuven.be/o_en_o/COE -- View this message in context: http://r.789695.n4.nabble.com/Package-glmulti-Include-a-variable-in-ALL-models-tp4648849p4648890.html Sent from the R help mailing list archive at Nabble.com.