View source: R/estimation_support.R
Datatrans | R Documentation |
Transforms the data into the desired data format required by different estimation packages.
Datatrans(pkg, des, y, n.alts, n.sets, n.resp, bin, alt.names = NULL)
pkg |
Indicates the desired estimation package. Options are
|
des |
A design matrix in which each row is a profile. |
y |
A numeric vector containing binary or discrete responses. See |
n.alts |
Numeric value indicating the number of alternatives per choice set. |
n.sets |
Numeric value indicating the number of choice sets. |
n.resp |
Numeric value indicating the number of respondents. |
bin |
Logical value indicating whether the reponse vector contains
binary data ( |
alt.names |
A character vector containing the names of the alternatives.
The default = |
The design (des
) specified should be the full aggregated design.
Thus, if all participants responded to the same design, des
will be a repetition of
that design matrix.
The responses in y
should be successive when there are multiple
respondents. There can be n.sets
elements for each respondent with
discrete values indicating the chosen alternative for each set. Or there can
be n.sets * n.alts
elements for each respondent with binary values
indicating for each alternative whether it was chosen or not. In the latter
case the bin
argument should be TRUE
.
n.sets
indicates the number of sets each respondent responded to. It is
assumed that every responded responded to the same number of choice sets.
The data ready to be used by the specified package.
idefix.data <- aggregate_design des <- as.matrix(idefix.data[, 3:8], ncol = 6) y <- idefix.data[, 9] bayesm.data <- Datatrans(pkg = "bayesm", des = des, y = y, n.alts = 2, n.sets = 8, n.resp = 7, bin = TRUE) Mix.pro.data <- Datatrans(pkg = "Mixed.Probit", des = des, y = y, n.alts = 2, n.sets = 8, n.resp = 7, bin = TRUE) mlogit.data <- Datatrans(pkg = "mlogit", des = des, y = y, n.alts = 2, n.sets = 8, n.resp = 7, bin = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.