Learn R Programming

idefix (version 0.2.4)

Datatrans: Data transformation.

Description

Transforms the data into the neccesary format in order to use estimation functions from different packages.

Usage

Datatrans(pkg, des, y, n.alts, n.sets, n.resp, n.par, no.choice, bin)

Arguments

pkg

Indicates the required package for estimation (1 = rhierMnlRwMixture, 2 = choicemodelr, 3 = doHB and 4 = rbprobitGibbs).

des

A design matrix in which each row is a profile.

y

A numeric matrix. Each columnvector is the sequence of choices of a unique respondent. There can be n.sets rows with discrete values indicating the chosen alternative of that set, or there can be n.sets * n.alts rows with binary values indicating for each alternative whether it was chosen or not. In the latter case the bin argument should be TRUE.

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.

n.par

Numeric value indicating the number of model parameters that needs to be estimated.

no.choice

Logical value indicating whether a no choice response could be observed. This would be a 0 for each alternative.

bin

Logical value indicating whether the reponse matrix contains binary data (TRUE) or discrete data (FALSE). See y.

Value

The data ready to be used by the specified package.

Examples

Run this code
# NOT RUN {
# 3 Attributes, 2 are dummy coded and 1 continuous.
cs <- Profiles(lvls = c(2, 3, 2), coding = c("D", "C", "D"), c.lvls = list(c(2,4,6)))
p <- c(0.8, 0.2, -0.3) # parameter vector
# Generate design
des <- Modfed(cand.set = cs, n.sets = 8, n.alts = 2, alt.cte = c(0,0), par.draws = p)$des
# Generate responses
y <- RespondMNL(par = p, des = des, n.alts = 2)
y <- matrix(y, 16)
#  data 
Datatrans(pkg = 4, des = des, y = y, n.alts = 2, n.sets = 8, n.resp = 1,
          n.par = 3, no.choice = FALSE, bin = TRUE)
# }

Run the code above in your browser using DataLab