嵌套logit模型顺序估计的奇异性问题

时间:2019-07-09 09:20:15

标签: r mlogit

出于教学目的,我尝试将嵌套logit模型估计为MNL序列。在该程序的某个时刻(参见Ben Akiva&Lerman,1986,Ch.10,10.4),人们共同估计了代表巢的MNL。 MNL(即“嵌套”)由相应的选择集表示。 但是,在估算模型时,由于奇异性,我遇到了一条错误消息。

我尝试了下面的代码。

library(mlogit)
data("Fishing", package = "mlogit")
# nest1: beach & pier -> model 1
# nest2: boat & charter -> model 2
# joint estimation of model 1 and 2
# Ben Akiva & Lerman (1986), Chp. 10 (.4)

# availabilities according to models
Fishing$avail.beach <- 0 
Fishing$avail.pier <- 0 
Fishing$avail.boat <- 0 
Fishing$avail.charter <- 0

Fishing$avail.charter[Fishing$mode == "charter" | Fishing$mode == "boat"] <- 1 
Fishing$avail.boat[Fishing$mode == "charter" | Fishing$mode == "boat"] <- 1 
Fishing$avail.pier[Fishing$mode == "pier" | Fishing$mode == "beach"] <- 1 
Fishing$avail.beach[Fishing$mode == "pier" | Fishing$mode == "beach"] <- 1 

names(Fishing) 

Fish <- mlogit.data(Fishing, shape="wide", varying=c(2:9, 11:14), choice="mode")
fish.joint  <- subset(Fish, avail ==1) # eliminate rows of non-available alts

head(model.matrix(mFormula(mode ~ price), fish.joint), n=4)

fish.1 <- mlogit(mode ~ price, fish.joint)

在我看来,model.matrix看起来可识别

> head(model.matrix(mFormula(mode ~ price), fish.joint), n=4)
          boat:(intercept) charter:(intercept) pier:(intercept)   price
1.boat                   1                   0                0 157.930
1.charter                0                   1                0 182.930
2.boat                   1                   0                0  10.534
2.charter                0                   1                0  34.534

但是,

> fish.1 <- mlogit(mode ~ price, fish.joint)
Error in solve.default(H, g[!fixed]) : 
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0

0 个答案:

没有答案