0

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?

Phil
  • 7,287
  • 3
  • 36
  • 66
rr19
  • 79
  • 1
  • 9
  • See here . This could be helpful. – TarJae Aug 14 '22 at 06:57
  • 1
    @TarJae thanks for you comment! I actually saw this yesterday but I really didn't understand anything of if.. it is too much technical and complicated for me to understand – rr19 Aug 14 '22 at 07:12
  • Using the summary() and Anova() works fine.. but using vif gives `Error in R[subs, subs] : subscript out of bounds` – rr19 Aug 16 '22 at 10:36
  • is there a limit of how many variables that can be used in `vif()` – rr19 Aug 16 '22 at 10:39
  • if I for instance remove all the dummary variables for age groups i created then it works.. anyone knows why? I would really wanted to keep the age groups in my regression – rr19 Aug 16 '22 at 11:30

0 Answers0