我正在尝试在mlogit软件包中运行hmftest。网上有一个例子,但我真的不明白。
说我有3个类别:1、2、3和两个连续变量:A,B。我真的只需要运行Hausman-McFadden检验,看看多项式逻辑回归中的独立性假设是否成立。 我不理解该示例,主要是因为我不知道此示例中变量的性质。
## from Greene's Econometric Analysis p. 731
data("TravelMode",package="AER")
TravelMode <- mlogit.data(TravelMode,choice="choice",shape="long",
alt.var="mode",chid.var="individual")
## Create a variable of income only for the air mode
TravelMode$avinc <- with(TravelMode,(mode=='air')*income)
## Estimate the model on all alternatives, with car as the base level
## like in Greene's book.
#x <- mlogit(choice~wait+gcost+avinc,TravelMode,reflevel="car")
x <- mlogit(choice~wait+gcost+avinc,TravelMode)
## Estimate the same model for ground modes only (the variable avinc
## must be dropped because it is 0 for every observation
g <- mlogit(choice~wait+gcost,TravelMode,reflevel="car",
alt.subset=c("car","bus","train"))
## Compute the test
hmftest(x,g)
了解以上示例的任何人都可以提供帮助吗?非常感谢你,