2017-04-25 9 views
0

SermasとColiasのRパッケージChoiceModelRで経験のある方が、階層ベイズ多項ロジットモデルを見積もることを願っています。現在、私は実際のデータを準備するためにコンジョイント(テストデータ)からデータを分析しています。データファイルは、必要に応じて(UnitID Set Alt X_1 ... X_natts y)の形式を持ち、yは離散です。各選択肢セットには、3つの選択肢(alt:1-3)と選択肢のない選択肢(alt:4)があります。独立変数はエフェクトコード(1,0、-1)です。私が見る限り、そのデータは必要な形式です。しかし、私は係数を推定することはできません。私は人口統計学的変数なしでモデルを実行した場合、私は次のエラーを取得する:choicemodelr:データ構造に誤りがありますか?

Error in Ops.data.frame(data[, 1], ID[i]) : 
‘==’ only defined for equally-sized data frames 

私は次のことを得る人口統計学的変数の使用:

Error: number of rows in demos does not equal number of units

を私はインターネットでのエラーの説明を見つけることができません。遠くにこの問題を解決する方法を知らない。私は、私が見ていないのはデータファイルの単純な間違いだと思います。私はすでに別のコーディングを使用しようとしましたが、同じエラーが発生します。ここで私が使用したコードは次のとおりです。

> xcoding=c(0,0,0,0,0,0,0,0,0,0,0,0,0,0) 
> mcmc = list(R = 20000, use = 10000) 
> options = list(none=FALSE, save=TRUE, keep=1) 
> out = choicemodelr(data=robottest_bayes, xcoding, mcmc = mcmc, options = options) 
> #with demographic variables 
> out = choicemodelr(data=robottest_bayes, demos=robottest_bayes_demo, xcoding, mcmc = mcmc, options = options) 

データファイルは次のとおりです。

> show(robottest_bayes) 
# A tibble: 8,464 × 18 
    respid ques alt apperance_burly apperance_intelligent apperance_pink features_car features_laundry features_compute 
    <int> <int> <int>   <int>     <int>   <int>  <int>   <int>   <int> 
1  1  1  1    1      0    0   1    0    0 
2  1  1  2    0      1    0   0    1    0 
3  1  1  3    0      0    1   0    0    1 
4  1  1  4    0      0    0   0    0    0 
5  1  2  1    0      1    0   0    0    0 
6  1  2  2    0      0    1   0    0    0 
7  1  2  3    1      0    0   0    0    0 
8  1  2  4    0      0    0   0    0    0 
9  1  3  1    0      0    1   0    0    0 
10  1  3  2    1      0    0   0    0    0 
# ... with 8,454 more rows, and 9 more variables: features_dog <int>, features_vaccuum <int>, features_splines <int>, 
# brand_botpro <int>, brand_gizmobot <int>, price_10 <int>, price_11 <int>, nochoice <int>, choice <int> 

> show(robottest_bayes_demo) 
# A tibble: 529 × 3 
    respid sex age 
    <int> <int> <int> 
1  1  0 42 
2  2  0 55 
3  3  0 37 
4  4  0 35 
5  5  1 41 
6  6  1 35 
7  7  0 56 
8  8  0 27 
9  9  1 36 
10  10  1 42 
# ... with 519 more rows 

私は本当にアドバイスのいずれかの種類に感謝し、すでにあなたが答えに費やす可能性がある時間をありがとうございました!

カテゴリーで探す、 マイケルあなたがデータファイルから選択の余地オプションの行を除外し、そして、スクリプトを修正しようとするかもしれ

答えて

0

:なし= TRUE(

オプション=リスト、TRUE =保存し、

回答者が「選択肢なし」を選択した選択肢セットについて、選択肢数は「代替数+1」、つまり4です.ChoiceModelRは、 「選択肢なし」が選択されていることを認識する。

p。 ChoiceModelRのビネットの

"なし:noneパラメータを推定するためにTRUEに設定され、データには" none "(つまり選択肢なし)の行(デフォルトはFALSE)が含まれていません。

どうか試してみてください。

関連する問題