mlogit - Multistage Nested Logit R -
i want estimate nested logit model using language r. standard packages such problems using "mlogit". estimate model, more 1 stage. problem follows:
- stage: people decide, if want migrate or not.
- stage: people decided migrate, have decide in region of want go (us devided in 6 regions)
- stage: within region, decide in kind of area want live; urba vs. rural
i transformed data using mlogit.data().
data <- mlogit.data(data = usa_canada_uk, choice = "migrant"))
this how "data" looks:
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 @ least 1 child aged 5 or younger ancillary 8262 @ least 1 child aged 10 or younger 13084.no female married 1-5 16+ 2 or more @ least 1 child aged 5 or younger ancillary 8262 @ least 1 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
here idea, how want code it, not working:
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)
as can see, 1 nest on first stage (deciding not migrate = "home_country") degenerated.
if me, awesome.
best wishes,
chris
Comments
Post a Comment