多级嵌套Logit R

时间:2015-07-05 14:41:49

标签: r mlogit

我想使用语言R来估计嵌套的logit模型。作为我正在使用的#34; mlogit"这类问题的标准包。现在我想估计一个模型,不仅仅是一个阶段。问题如下:

  1. 阶段:人们决定是否要迁移到美国。
  2. 阶段:对于所有决定迁移的人,他们必须决定他们想要去的美国哪个地区(美国分为6个地区)
  3. 阶段:在该地区内,他们决定他们想要居住的地区; urba vs. rural
  4. 我已经使用mlogit.data()转换了我的数据。

    data <- mlogit.data(data = usa_canada_uk, choice = "migrant"))
    

    这是&#34;数据&#34;看起来:

                    sex   marst numperhh_cat age_cat   famsize                               nchlt5 labour_code sample                               nchlt10
    3888.no  female married          1-5     16+         1          no chiled aged 5 or younger not working   8262          no chiled aged 10 or younger
    12874.no female married          1-5     16+ 2 or more at least one child aged 5 or younger   ancillary   8262 at least one child aged 10 or younger
    13084.no female married          1-5     16+ 2 or more at least one child aged 5 or younger   ancillary   8262 at least one child aged 10 or younger
    9359.yes female married          1-5     16+         1          no chiled aged 5 or younger     service   8262          no chiled aged 10 or younger
    7569.no  female married          1-5     16+         1          no chiled aged 5 or younger     service   8262          no chiled aged 10 or younger
    5778.no  female married          1-5     16+         1          no chiled aged 5 or younger not working   8262          no chiled aged 10 or younger
             perwt        labforce age migrant country_of_birth       region citypop urban work.prob.home work.prob.abroad migration.prob stay.prob  chid
    3888.no      1     in labforce  26    TRUE   United Kingdom home_country      NA urban             NA               NA             NA        NA  3888
    12874.no     1     in labforce  47    TRUE   United Kingdom home_country      NA rural             NA               NA             NA        NA 12874
    13084.no     1     in labforce  22    TRUE   United Kingdom home_country      NA urban             NA               NA             NA        NA 13084
    9359.yes     1     in labforce  28   FALSE   United Kingdom home_country      NA urban             NA               NA             NA        NA  9359
    7569.no      1     in labforce  32    TRUE   United Kingdom home_country      NA urban             NA               NA             NA        NA  7569
    5778.no      1 not in labforce  38    TRUE   United Kingdom home_country      NA rural             NA               NA             NA        NA  5778
             alt
    3888.no   no
    12874.no  no
    13084.no  no
    9359.yes yes
    7569.no   no
    5778.no   no
    

    这是我的想法,我想如何编码,但它不起作用:

    mlog <- mlogit(migrant ~ 1  | age + numperhh_cat + sex + famsize + work.prob.home,
                 nests = list(home = c("home_country"),
                             foreign = c(region_1 = c("rural", "urban"),
                                         region_2 = c("rural", "urban"),
                                         region_3 = c("rural", "urban"),
                                         region_4 = c("rural", "urban"),
                                         region_5 = c("rural", "urban"),
                                         region_6 = c("rural", "urban"))
                                         ),
               reflevel = "yes",
               weights = perwt,
               data = data)
    

    如您所见,第一阶段的一个巢(决定不迁移=&#34; home_country&#34;)退化。

    如果有人可以帮助我,那就太棒了。

    祝福,

    克里斯

0 个答案:

没有答案