R误差中联合分析的ChoiceModelR包:估计Beta
我进行了一项联合研究,现在尝试使用R软件包来估算效用。我已经阅读了软件包文档,并查看了有关StackOverflow(和)的类似答案/问题,但得到了下面的错误消息 我的数据文件(您可以从中下载的.csv具有所需的格式(UnitID Set Alt X_1…X_natts y)是离散的。在每个选项集中,我有2个可选项和“无”选项。我已从数据文件中排除了带有“无”选项的行。对于“无”选项集,选项号设置为“可选项数+1”,即3 据我所知,该数据是必需的格式。但是,我无法估计实用程序并得到以下错误:R误差中联合分析的ChoiceModelR包:估计Beta,r,bayesian,multinomial,R,Bayesian,Multinomial,我进行了一项联合研究,现在尝试使用R软件包来估算效用。我已经阅读了软件包文档,并查看了有关StackOverflow(和)的类似答案/问题,但得到了下面的错误消息 我的数据文件(您可以从中下载的.csv具有所需的格式(UnitID Set Alt X_1…X_natts y)是离散的。在每个选项集中,我有2个可选项和“无”选项。我已从数据文件中排除了带有“无”选项的行。对于“无”选项集,选项号设置为“可选项数+1”,即3 据我所知,该数据是必需的格式。但是,我无法估计实用程序并得到以下错误: E
Error: invalid values of y present in data - values must be 1 to 3
我的输入如下所示:
id set_number card_number att1 att2 att3 att4 dv
1 932 1 1 1 1 1 3 2
2 932 1 2 2 2 4 4 0
4 932 2 1 3 3 3 1 2
5 932 2 2 4 2 2 4 0
7 932 3 1 5 4 1 3 2
8 932 3 2 6 3 3 2 0
...
我的代码如下所示
library(ChoiceModelR)
c_data <- read.csv("c_data.csv")
# Set parameter for calculation
# R is the total number of iterations of the Markov Chain Monte Carlo to be performed
# use is the number of iterations to be used in parameter estimation
mcmc = list(R = 4000, use = 2000)
# Set parameter of datainput
# xcoding specifies the way in which each attribute will be coded (0 = categorical, 1 = nominal)
# none = TRUE to estimate a none parameter, and the data does not include a row for “none” (i.e., no choice)
# keep is the thinning parameter that defines the number of random draws to save
xcoding = c(0, 0, 0, 0)
options = list(none = TRUE, keep = 5)
# Putting it together to get betas
choicemodelr(data = c_data, xcoding = xcoding, mcmc = mcmc, options = options)
20个带dput的顶行:
structure(list(id = c(932L, 932L, 932L, 932L, 932L, 932L, 932L,
932L, 932L, 932L, 932L, 932L, 932L, 932L, 932L, 932L, 933L, 933L,
933L, 933L), set_number = c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L,
5L, 6L, 6L, 7L, 7L, 8L, 8L, 1L, 1L, 2L, 2L), card_number = c(1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L), att1 = c(1L, 2L, 3L, 4L, 5L, 6L, 3L, 4L, 5L, 2L,
3L, 4L, 2L, 6L, 6L, 4L, 3L, 5L, 6L, 2L), att2 = c(1L, 2L, 3L,
2L, 4L, 3L, 1L, 3L, 1L, 2L, 1L, 4L, 4L, 3L, 4L, 3L, 3L, 1L, 2L,
4L), att3 = c(1L, 4L, 3L, 2L, 1L, 3L, 2L, 4L, 1L, 2L, 3L, 4L,
1L, 4L, 2L, 3L, 1L, 4L, 3L, 4L), att4 = c(3L, 4L, 1L, 4L, 3L,
2L, 2L, 1L, 3L, 4L, 2L, 4L, 2L, 3L, 2L, 3L, 4L, 2L, 3L, 1L),
dv = c(2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 1, 0, 1, 0, 2, 0, 1,
0, 1, 0)), row.names = c(NA, -20L), class = "data.frame")
如果您能给我提些建议,我将不胜感激
structure(list(id = c(932L, 932L, 932L, 932L, 932L, 932L, 932L,
932L, 932L, 932L, 932L, 932L, 932L, 932L, 932L, 932L, 933L, 933L,
933L, 933L), set_number = c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L,
5L, 6L, 6L, 7L, 7L, 8L, 8L, 1L, 1L, 2L, 2L), card_number = c(1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L), att1 = c(1L, 2L, 3L, 4L, 5L, 6L, 3L, 4L, 5L, 2L,
3L, 4L, 2L, 6L, 6L, 4L, 3L, 5L, 6L, 2L), att2 = c(1L, 2L, 3L,
2L, 4L, 3L, 1L, 3L, 1L, 2L, 1L, 4L, 4L, 3L, 4L, 3L, 3L, 1L, 2L,
4L), att3 = c(1L, 4L, 3L, 2L, 1L, 3L, 2L, 4L, 1L, 2L, 3L, 4L,
1L, 4L, 2L, 3L, 1L, 4L, 3L, 4L), att4 = c(3L, 4L, 1L, 4L, 3L,
2L, 2L, 1L, 3L, 4L, 2L, 4L, 2L, 3L, 2L, 3L, 4L, 2L, 3L, 1L),
dv = c(2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 1, 0, 1, 0, 2, 0, 1,
0, 1, 0)), row.names = c(NA, -20L), class = "data.frame")