多项式逻辑随机效应

时间:2018-08-15 07:38:54

标签: logistic-regression panel-data multinomial random-effects

我想使用面板数据使多项逻辑回归与个体水平随机效应相适应,类似于此处所述:

https://www.stata.com/stata-news/news29-2/xtmlogit/

根据this website,在MCMCpack软件包中有一个命令MCMCmnl应该执行此操作。但是,我不知道如何实现该模型。

我提供了一些我想应用该模型的可复制数据。此外,上面的链接还应该用作检查结果是否相似的一个方法。

提前感谢您的时间和考虑!

library(readstata13)
library(dplyr)
library(MCMCpack)

url <- "http://www.stata-press.com/data/r13/nlswork3.dta"
x <- read.dta13(url)

x <- select(x, idcode, age, race, msp, wks_ue, wks_work)

# modify dataset for Stata News
x$workstat <- with(x, ifelse(wks_ue >= 26 & !is.na(wks_work), yes = 2, no = NA)) # employed
x$workstat <- with(x, ifelse(wks_work < 26 & is.na(workstat), yes = 3, no = workstat)) # unemployed
x$workstat <- with(x, ifelse(is.na(workstat) & !is.na(wks_work), yes = 1, no = workstat)) # out of labor force
x$student <- with(x, ifelse(age <= 18, yes = 1, no = 0))

# ignoring missing data problem altogether
fit <- lm(workstat ~ age + race + student + msp, data = x)
# - N used
esample.n <- nobs(fit)
# - Sample identifier, a set of row names which can be used to subset the corresponding dataframe
esample<-rownames(as.matrix(resid(fit)))

x <- mutate(x, race = as.factor(race), student = as.factor(student), msp = as.factor(msp))

# E.g. subsetting
x <- x[esample,]

问题:如何使用单个MCMCmnl实施具有个体随机效应的多项式逻辑回归??

0 个答案:

没有答案