idefix (version 0.4.0)

Datatrans: Data transformation.

Description

Transforms the data into the desired data format required by different estimation packages.

Usage

Datatrans(pkg, des, y, n.alts, n.sets, n.resp, bin, alt.names = NULL)

Arguments

pkg

Indicates the desired estimation package. Options are bayesm = rhierMnlRwMixture, ChoiceModelR = choicemodelr, RSGHB = doHB, Mixed.Probit = rbprobitGibbs, mlogit = mlogit, and Rchoice = Rchoice).

des

A design matrix in which each row is a profile.

y

A numeric vector containing binary or discrete responses. See bin argument.

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 (TRUE) or discrete data (FALSE). See y argument.

alt.names

A character vector containing the names of the alternatives. The default = NULL

Value

The data ready to be used by the specified package.

Details

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 succesive 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 repondent responded to. It is assumed that every responded responded to the same number of choice sets.

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab