r - How to change na.action for zero-inflated regression model? -
i running zero-inflated negative binomial regression model using function zeroinfl
pscl
package.
i need exclude na's model in order able plot residuals against dependent variable later in analysis.
therefore, want set na.action="na.exclude"
. can without problem non-zero-inflated negative binomial regression model (using glm.nb
glm
package), eg.
fm_nbin <- glm.nb(dv ~ factor(idv) + contr1 +contr2 + contr3, data=df, subset=(df$var<500), na.action="na.exclude") fm_nbin.res = resid(fm_nbin) plot(fm_nbin.res~df$var)
works fine. however, when same zero-inflated model, not work:
zinfl <- zeroinfl(dv ~ factor(idv) + contr1 +contr2 + contr3 | factor(idv) + contr1 +contr2 + contr3, data=df, subset=(df$var<500), na.action="na.exclude") zinfl.res = resid(zinfl) plot(zinfl.res~df$var)
gives error
error in function (formula, data = null, subset = null, na.action = na.fail, : variable lengths differ (found 'df$var')
is there other command should use exclude na's regression?
edit: this nearest of answer find. can in way applied problem? also, can naresid
in way applied?
as 1 finds following trail of documentation zeroinfl
glm.fit
: "the ‘factory-fresh’ default na.omit
." notice have not put quotes around since supposed function rather function accept name doesn't matter if quoted. admit don't know how na.omit
, na.exclude
differ (something residuals read), go default setting first, since delivers want regression functions. try leaving out:
zinfl <- zeroinfl(dv ~ factor(idv) + contr1 +contr2 + contr3 | factor(idv) + contr1 +contr2 + contr3, data=df, subset=(df$var<500) )
Comments
Post a Comment