1

mlogit() パッケージを使用して、R でネストされた Logit モデルを実行しました。現在、限界効果/弾力性を測定しようとしていますが、引き続きエラーが発生します。ここでは、パッケージの作成者がビネットを変更してエラーを再現しました。

data("Fishing", package = "mlogit")
Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice = "mode")
m <- mlogit(mode ~ price | income | catch, data = Fish,
            nests=list(water=c("boat","charter"),
                       land=c("beach","pier")))
# compute a data.frame containing the mean value of the covariates in the sample
 z <- with(Fish, data.frame(price = tapply(price, index(m)$alt, mean), 
                                                         catch = tapply(catch, index(m)$alt, mean), 
                                                        income = mean(income)))
# compute the marginal effects (the second one is an elasticity
 effects(m, covariate = "income", data = z) 

次のエラーが表示されます。

Error in `colnames<-`(`*tmp*`, value = c("beach", "boat", "charter", "pier" : 
  attempt to set 'colnames' on an object with less than two dimensions
In addition: Warning message:
In cbind(Gb, Gl) :
  number of rows of result is not a multiple of vector length (arg 2)

これは、ネストされたモデル (通常の多項ロジットなど) がない場合に正常に機能し、以前のスタックオーバーフローの質問でカバーされていますが、変更されたデータ フレーム (でこの場合平均フレーム z)。

ここでの解決策は次のとおりです。Rでのmlogitの限界効果は役に立ちませんでした。

4

0 に答える 0