View source: R/shiny_support.R
Decode | R Documentation |
Transforms a coded design matrix into a design containing character attribute levels, ready to be used in a survey. The frequency of each attribute level in the design is also included in the output.
Decode( des, n.alts, lvl.names, coding, alt.cte = NULL, c.lvls = NULL, no.choice = NULL )
des |
A numeric matrix which represents the design matrix. Each row is a profile. |
n.alts |
Numeric value indicating the number of alternatives per choice set. |
lvl.names |
A list containing character vectors with the values of each level of each attribute. |
coding |
A character vector denoting the type of coding used for each
attribute. See also |
alt.cte |
A binary vector indicating for each alternative if an
alternative specific constant is present. The default is |
c.lvls |
A list containing numeric vectors with the attribute levels for
each continuous attribute. The default is |
no.choice |
An integer indicating the no choice alternative. The default
is |
des
A design matrix, this can also be a single choice set. See for
example the output of Modfed or CEA.
In lvl.names
, the number of character vectors in the list should equal
the number of attributes in de choice set. The number of elements in each
character vector should equal the number of levels for that attribute.
Valid arguments for coding
are C
, D
and E
. When
using C
the attribute will be treated as continuous and no coding will
be applied. All possible levels of that attribute should then be specified in
c.lvls
. If D
(dummy coding) is used
contr.treatment
will be applied to that attribute. The first
attribute wil be used as reference level. For E
(effect coding)
contr.sum
is applied, in this case the last attribute level is
used as reference level.
If des
contains columns for alternative specific constants,
alt.cte
should be specified. In this case, the first column(s) (equal
to the number of nonzero elements in alt.cte
) will be removed from
des
before decoding the alternatives.
design |
A character matrix which represents the design. |
lvl.balance |
A list containing the frequency of appearance of each attribute level in the design. |
## Not run: # Example without continuous attributes. design <- example_design coded <- c("D", "D", "D") # Coding. # Levels as they should appear in survey. al <- list( c("$50", "$75", "$100"), # Levels attribute 1. c("2 min", "15 min", "30 min"), # Levels attribute 2. c("bad", "moderate", "good") # Levels attribute 3. ) # Decode Decode(des = design, n.alts = 2, lvl.names = al, coding = coded) # Example with alternative specific constants design <- example_design2 coded <- c("D", "D", "D") # Coding. # Levels as they should appear in survey. al <- list( c("$50", "$75", "$100"), # Levels attribute 1. c("2 min", "15 min", "30 min"), # Levels attribute 2. c("bad", "moderate", "good") # Levels attribute 3. ) # Decode Decode(des = design, n.alts = 3, lvl.names = al, coding = coded, alt.cte = c(1, 1, 0)) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.