Datatrans: Data transformation.

Description Usage Arguments Details Value Examples

View source: R/estimation_support.R

Description

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

Usage

1
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).

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

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.

Value

The data ready to be used by the specified package.

Examples

1
2
3
4
5
6
7
8
9
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)

Example output

Loading required package: shiny
[1] "The dataset is ready to be used for bayesm package"
[1] "The dataset is ready to be used for Mixed Probit Estimation"
[1] "The dataset is ready to be used for mlogit package"

idefix documentation built on Nov. 27, 2020, 1:07 a.m.