I created ordered logit models using polr in RStudio and the using the vif. It worked fine and I got my results. But after I decided toadd more variables such as dummy for age groups, education and income groups. But when I then use vif I got the error about subscript out of bound
My used data for this: Here is an example of my data set:
Work less | lifestatisfied | country | Work much |
---|---|---|---|
0 | 8 | GB | 1 |
1 | 8 | SE | 0 |
0 | 9 | DK | 1 |
0 | 9 | DE | 1 |
NA | 5 | NO | NA |
continued:
health | education | income | age | marital status |
---|---|---|---|---|
3 | 3 | Na | 61 | NA |
4 | 2 | 2 | 30 | NA |
1 | 3 | 4 | 39 | 6 |
5 | 7 | 5 | 52 | 4 |
4 | 1 | 5 | 17 | 5 |
- gender is dummy 1 or 2
- age is respondents age like 35, 47 etc.
- income is scaled and is 1 to 10
- educ (education) is 1 to 7
- health is scaled 1 to 5
- work less is dummy i.e. 1 or 0
- work much is dummy, i.e. 1 or 0
- marital status is scaled 1 to 6
- lifesatisfied is the dependent variable and is scaled 0 to 10.
My ordered regression model:
myorderedmodel = polr(factor(lifesatisfied, ordered = TRUE) ~ maritalstatus + gender + age + age20_29 + age30_39 + age40_49 + age50_59 + income + lowincome + avgincome + highincome + noeducation + loweducation + higheducation + health + child + religion + workless + workmuch, data = mydata, method = "logistic", Hess = TRUE)
vif(myorderedmodel)
Gives the following error:
Error in R[subs, subs] : subscript out of bounds
I really didn't understand the error. What does it mean? And how can it be solved?