[R-sig-ME] vif using GLMMadaptive
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Mon May 4 00:04:04 CEST 2020
Yes. I misunderstood the issue, and particularly the meaning in
this context of 'aliased' (which has now been well explained by you and
Tom Philippi). I would still stand by my first sentence ...
cheers
Ben Bolker
On 5/3/20 6:00 PM, Fox, John wrote:
> Hi Ben,
>
>> On May 3, 2020, at 4:34 PM, Ben Bolker <bbolker using gmail.com> wrote:
>>
>> My advice would be to sort out the underlying problem (which is *not* at all related to mixed models) and not move to mixed models in the hope that that will fix something. I believe (but am not sure) that you're using vif() from the car package?
>>
>> * you may be able to un-alias your variables by eliminating the 'main effect' terms in your model; in R formula syntax, A*B is equivalent to 1+A+B+A:B. So dropping the main effects that are already included in the * terms, or switching from * to : for interactions, may solve your problem.
> I don't think so: That is, when the formula is processed, the redundancies introduced by the mistaken use of * should automatically be accounted for, as in the following:
>
>> D <- data.frame(a=factor(rep(c("a", "b"), 2)), b=factor(rep(c("A", "B"), each=2)))
>> D
> a b
> 1 a A
> 2 b A
> 3 a B
> 4 b B
>
>> model.matrix(~1 + a + b + a*b, data=D)
> (Intercept) ab bB ab:bB
> 1 1 0 0 0
> 2 1 1 0 0
> 3 1 0 1 0
> 4 1 1 1 1
> attr(,"assign")
> [1] 0 1 2 3
> attr(,"contrasts")
> attr(,"contrasts")$a
> [1] "contr.treatment"
>
> attr(,"contrasts")$b
> [1] "contr.treatment"
>
> The problem is probably more fundamental, as has already been suggested.
>
> Best,
> John
>
>> On 5/1/20 2:12 AM, Matos, Grisenia wrote:
>>> I am a PhD student and am working on a school project due over the weekend. I ran the following regression:
>>> spending.REG <- glm.nb(spending_count ~ conservative + liberal + moderate + trust_gov + liberal*trust_gov + conservative*trust_gov + moderate*trust_gov + income + education + age + female + white + budget_difficult + democrat + republican, data = Trustdata1)
>>>
>>> I attempted to get a vif score and got this error in R Studio: there are aliased coefficients in the model
>>>
>>> The variables conservative, liberal and moderate are fixed effect where they are either 0 or 1. The female variable is a 0 or 1. There are three interactive variables: moderate*trust_gov, liberal*trust_gov, and conservative*trust_gov. Moreover, moderate and moderate*trust_gov are the base variables.
>>>
>>> I would like to calculate the vif for the regression equation. First, in order to get rid of the error and thereafter calculate the vif scores, I attempted to use your code:
>>>
>>> library("GLMMadaptive")
>>>
>>> fm <- mixed_model(y ~ time + sex, random = ~ 1 | id, data = <your_data>,
>>> family = zi.negative.binomial(), zi_fixed = ~ sex, zi_random = ~ 1 | id)
>>>
>>> it returned an error: unexpected '=' in: "erate + trust_gov + liberal*trust_gov + conservative*trust_gov + moderate*trust_gov + income + education + age + female + white + budget_difficult + democrat + republican, random = 1 | id, dat
>>> + family ="
>>>
>>> Please provide guidance as to what I am doing incorrectly. I appreciate your help.
>>>
>>> Thanks,
>>>
>>> Grisenia
>>>
>>>
>>>
>>>
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-mixed-models using r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>> _______________________________________________
>> R-sig-mixed-models using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
More information about the R-sig-mixed-models
mailing list