I face a problem when trying to use the function model.avg
of the MuMin
package on objects resulting from the function multinom
(package nnet
).
Although the manual list as multinom
compatible, the model.avg
function doesn't return the model average coefficients for the explanatory variables as I expect.
I know that the problem doesn't exist when the multinom
reponse variable as 2 levels only, so I guess it depends on the structure of the resulting multinom object. However, I don't know how to fix this issue.
Here is an example code where the function model.avg
works as expected:
#### MuMIn example
library(MuMIn)
data(Cement)
fm1 <- lm(y ~ ., data = Cement)
dd <- dredge(fm1)
summary(model.avg(dd, subset = delta < 4))$coefmat
Results:
Estimate Std. Error Adjusted SE z value Pr(>|z|)
(Intercept) 64.69312754 22.2354794 22.4624137 2.8800613 0.0039760
X1 1.45579791 0.2036676 0.2193043 6.6382554 0.0000000
X2 0.62502598 0.1202570 0.1291705 4.8387682 0.0000013
X4 -0.47600710 0.2215167 0.2309395 2.0611767 0.0392862
X3 -0.02153196 0.3767120 0.3924356 0.0548675 0.9562440
In this case, the 'model.avg' function returns the Model-averaged coefficients
(column Estimate
) for the explanatory variables (i.e. X1-X4) as expected.
Now, if I want to apply this to a multinom
object (response variable with at least 3 levels):
#### application to multinomial regression
library(foreign) ; library(nnet) ; library(MuMIn)
ml <- read.dta("http://www.ats.ucla.edu/stat/data/hsbdemo.dta")
ml$prog2 <- relevel(ml$prog, ref = "academic")
test <- multinom(prog2 ~ ses + write + schtyp, data = ml)
# [...] verbosity not displayed here
dd <- dredge(test)
# [...] verbosity not displayed here
summary(model.avg(dd, subset = delta < 4))$coefmat
Results
Estimate Std. Error z value Pr(>|z|)
general 2.850316 1.169132 2.437977 0.014769732
vocation 5.134921 1.173878 4.374322 0.000012181
Here, the function returns "model average coefficients" for the different levels of the response variable (i.e. general
and vocation
) rather than for the model average coefficients for the explanatory variables.
If this is possible, could you tell me please how to get the Model average coefficients
for the explanatory variables from multinom
objects?
Many thanks in advance.
It was indeed a bug with extraction of coefficients from multinom objects. It is fixed now in MuMIn 1.9.13.