Type: Package
Title: Tools for Case 3 Best-Worst Scaling
Version: 0.2-1
Date: 2024-02-01
Author: Hideo Aizaki
Maintainer: Hideo Aizaki <azk-r@spa.nifty.com>
Description: Provides basic functions that support an implementation of multi-profile case (Case 3) best-worst scaling (BWS). Case 3 BWS is a question-based survey method to elicit people's preferences for attribute levels. Case 3 BWS constructs various combinations of attribute levels (profiles) and then asks respondents to select the best and worst profiles in each choice set. A main function creates a dataset for the analysis from the choice sets and the responses to the questions. For details on Case 3 BWS, refer to Louviere et al. (2015) <doi:10.1017/CBO9781107337855>.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Suggests: crossdes, DoE.base, support.CEs, survival
NeedsCompilation: no
Depends: R (≥ 3.5)
LazyData: true
Packaged: 2024-02-01 06:28:24 UTC; rpkgdev
Repository: CRAN
Date/Publication: 2024-02-01 07:00:02 UTC

Tools for Case 3 best-worst scaling

Description

Provides basic functions that support an implementation of Case 3 (multi-profile case) best-worst scaling.

Details

Case 3 (multi-profile case) best-worst scaling (BWS) is a question-based survey method to elicit people's preferences for attribute levels. A Case 3 BWS question consists of three or more profiles. Each profile has two or more attributes and each attribute has two or more levels. Respondents are asked to select the best and worst profiles for each question. Analyzing the responses to the questions reveals the people's preferences for the attribute levels. Refer to Hensher et al. (2015), Lancsar et al. (2013), Louviere et al. (2015), and Marley and Pihlens (2012) for details.

Acknowledgments

I would like to thank Professor Kazuo Sato for his kind support. This work was supported by JSPS KAKENHI Grant Numbers JP16K07886 and JP20K06251.

Author(s)

Hideo Aizaki

References

Hensher DA, Rose JM, Greene WH (2015) Applied Choice Analysis. 2nd edition. Cambridge University Press.

Louviere JJ, Flynn TN, Marley AAJ (2015) Best-Worst Scaling: Theory, Methods and Applications. Cambridge University Press.

Lancsar E, Louviere J, Donaldson C, Currie G, Burgess L (2013) Best worst discrete choice experiments in health: Methods and an application. Social Science & Medicine 76: 74–82.

Marley AAJ, Pihlens D (2012) Models of best-worst choice and ranking among multiattribute options (profiles). Journal of Mathematical Psychology 56: 24–34.


Creating a dataset suitable for Case 3 best-worst scaling analysis

Description

This function creates a dataset suitable for Case 3 best-worst scaling analysis using a modeling approach.

Usage

bws3.dataset(data, id = "id", response, choice.sets, categorical.attributes = NULL,
 continuous.attributes = NULL, common = NULL, optout = FALSE, asc = NULL,
 model = "maxdiff", detail = FALSE, ...)

Arguments

data

A data frame containing a respondent dataset.

id

A character representing the respondent identification number variable in the respondent dataset.

response

A named list containing the names of response variables in the respondent dataset.

choice.sets

An object of the S3 class "cedes".

categorical.attributes

A vector containing the names of attributes treated as dummy-coded variables in the analysis, or a named vector containing the reference levels of attributes treated as effect-coded variables. If there are no categorical variables, it is set as NULL (default).

continuous.attributes

A vector containing the names of attributes treated as continuous variables in the analysis. If there are no continuous variables, it is set as NULL (default).

common

A named vector containing a fixed combination of levels corresponding to a common alternative (base/reference) in the choice sets. If the common alternative is an opt-out (no choice) option, use the argument optout instead. If there is no common option, it is set as NULL (default).

optout

A logical variable describing whether the opt-out option is included in the BWS questions. If TRUE (default), the opt-out option is included; otherwise it is not.

asc

A vector containing binary values, which takes the value of 1 when an alternative specific constant (ASC) is included in the utility function of an alternative and 0 otherwise: the i-th element in the vector corresponds to the i-th alternative. If there are no ASCs, it is set as NULL (default).

model

A character showing a type of dataset created by the function: "maxdiff" for a maximum difference model; "sequential" for a sequential model; and "rank" for a rank-ordered model.

detail

A logical variable describing whether the response variables that are assigned to the argument response are also stored in the dataset created by the function.

...

Optional arguments; currently not in use.

Details

This function creates a dataset for Case 3 BWS analysis using the modeling approach, which uses discrete choice models. When using the function, a model type must be selected from among the three standards models: maximum difference (maxdiff/paired), sequential, and rank-ordered. The argument model is set according to the selected model. See Lancsar et al. (2013) and Marley and Pihlens (2012) for details on the three models, and Hensher et al. (2015, Appendix 6B) for details on the dataset structure for Case 3 BWS.

The respondent dataset, in which each row corresponds to a respondent, is assigned to the argument data. The dataset must include the respondent's identification number (id) variable, the block variable (BLOCK), and the response variables, each indicating the alternatives (profiles) that were selected as the best and worst for each question. Other variables in the respondent dataset are treated as the respondents' characteristics such as gender and age. The variables relating to respondents' characteristics are also stored in the resultant dataset created by the function. The names of the id and response variables are left to the discretion of the user. The id variable is assigned to the argument id (the default is "id"). The response variables are assigned to the argument response in list format: each element of the list, corresponding to a Case 3 BWS question, is a named vector that contains alternative numbers selected as the best and worst in the Case 3 BWS question (see the Examples section below for details).

An object containing the choice sets, which follows the S3 class "cedes" (see the rotation.design function in the support.CEs package), is assigned to the argument choice.sets. Only unlabeled (generic) designs are acceptable in the current version of the function. Attribute variables in choice.sets are assigned either to the argument categorical.attributes or the argument continuous.attributes, according to the model you use. If categorical attributes are treated as dummy-coded variables in the analysis, a vector containing the names of the categorical attributes is assigned to categorical.attributes. If categorical attributes are treated as effect-coded variables in the analysis, a named vector containing the names of reference levels is assigned to categorical.attributes. For example, suppose a profile consists of three 3-level attributes: attribute A with levels A1, A2, and A3; attribute B with B1, B2, and B3 levels; and attribute C with C1, C2, and C3 levels. If the three attributes are treated as dummy-coded variables in the analysis, a vector c("A", "B", "C") is assigned to categorical.attributes. If the three attributes are treated as effect-coded variables in the analysis and the first level in each attribute is a reference level, a named vector c(A = "A1", B = "B1", C = "C1") is assigned to it. If each BWS question contains a common alternative, such as status quo, and it is not included in the choice sets assigned to the argument choice.sets, a fixed combination of levels corresponding to the common alternative in vector format (e.g., c("A1", "B3", "C2")) is assigned to the argument common. If each BWS question includes an opt-out (no choice) option, the argument option is set as TRUE; otherwise it is set as FALSE (default). Accordingly, the attribute variables in the dataset created by the function take the value of 0 in the row corresponding to the opt-out options. The order of alternatives in choice.sets must be the same as the alternative numbers used in the response variables. Furthermore, the order of questions in the respondent dataset must be the same as that in choice.sets.

If alternative specific constants (ASCs) are needed for the model you choose, a vector with binary values is set according to your model specification and then assigned to the argument asc. The i-th element in the vector corresponds to the i-th alternative, and the value of 1 indicates the presence of ASC in the corresponding alternative and the value of 0 indicates its absence. For example, suppose that each BWS question has four alternatives and the 1st, 2nd, and 3rd alternatives in the model have an ASC each. In this case, a vector c(1, 1, 1, 0) is assigned to asc. Consequently, the resultant dataset includes four ASCs: ASC1 taking the value of 1 for the 1st alternative and 0 otherwise, ASC2 taking the value of 1 for the 2nd alternative and 0 otherwise, ASC3 taking the value of 1 for the 3rd alternative and 0 otherwise, and ASC4 taking the value of 0 for all the alternatives (ASC4 is not needed in the analysis).

Value

This function returns a dataset for analysis, which is an object of S3 class "bws3dataset" and inherits from data frame format. The dataset for the maxdiff (paired) model contains the following variables as well as attribute variables and respondents' characteristic variables:

id

A respondent's identification number; the actual name of this variable is set according to the id variable in the respondent dataset if the argument id is set by users.

BLOCK

A serial number of blocks.

QES

A serial number of Case 3 BWS questions.

PAIR

A serial number for the possible pairs of the best and worst alternatives for each question.

BEST

An alternative number treated as the best in the possible pairs of the best and worst alternatives.

WORST

An alternative number treated as the worst in the possible pairs of the best and worst alternatives.

RES.B

An alternative number selected as the best by respondents.

RES.W

An alternative number selected as the worst by respondents.

RES

A binary variable that takes the value of 1 when a possible pair of the best and worst alternatives is selected by respondents and 0 otherwise. The variable is used as a dependent variable in the model formula of the function for discrete choice analysis.

STR

A stratification variable identifying each combination of respondent and question. The variable may be used in the model formula for discrete choice analysis.

ASC

Alternative specific constant(s). The serial number of the alternatives is appended to the tail of ASC (e.g., ASC1, ASC2, and ASC3).

The dataset for the sequential model and the one for the rank-ordered model contains the variables id, BLOCK, QES, and STR mentioned above, in addition to the following variables:

ALT

A serial number of alternatives for each question.

RES.ALT

An alternative number selected as the best or worst by respondents.

SET

A serial number of implied choice sets for each question.

BW

A state variable taking the value of 1 for the possible best alternatives and -1 for the possible worst alternatives. The variable is not included in the dataset for the rank-ordered model.

RES

A binary variable that takes the value of 1 when a possible best or worst alternative is selected by respondents and 0 otherwise.

Author(s)

Hideo Aizaki

References

See the help page for support.BWS3-package.

See Also

support.BWS3-package, rotation.design, clogit

Examples

# The following lines of code construct choice sets for Case 3 BWS
# using rotation.design() in the package support.CEs; create a dataset
# for the analysis using bws3.dataset(); and then conduct a maxdiff model
# analysis on the basis of a conditional logit model specification
# using clogit() in the package survival.

# Load packages
library(support.CEs)
library(survival)
# Reproduce old results
if(getRversion() >= "3.6.0") RNGkind(sample.kind = "Rounding")
# Create choice sets
dsgn <- rotation.design(                
  attribute.names = list(
    A = c("A1", "A2", "A3"), B = c("B1", "B2", "B3"),
    C = c("C1", "C2", "C3"), D = c("D1", "D2", "D3")),
  nalternatives = 4, nblocks = 1,randomize = TRUE, seed = 9876)
# Prepare response variables
dat <- data.frame(          
  IDvar = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
  BLOCK = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
  q1b1  = c(2, 1, 1, 1, 1, 2, 1, 1, 1, 1),
  q1w1  = c(4, 2, 4, 3, 4, 4, 4, 3, 3, 4),
  q1b2  = c(1, 4, 2, 2, 2, 3, 3, 2, 2, 2),
  q1w2  = c(3, 3, 3, 4, 3, 1, 2, 4, 4, 3),
  q2b1  = c(1, 4, 2, 1, 1, 4, 4, 4, 1, 2),
  q2w1  = c(3, 3, 3, 3, 3, 1, 3, 2, 2, 3),
  q2b2  = c(4, 1, 4, 4, 4, 3, 1, 1, 4, 4),
  q2w2  = c(2, 2, 1, 2, 2, 2, 2, 3, 3, 1),
  q3b1  = c(4, 2, 1, 4, 2, 2, 4, 4, 3, 4),
  q3w1  = c(1, 3, 3, 1, 1, 1, 1, 1, 4, 1),
  q3b2  = c(2, 1, 2, 3, 4, 3, 2, 3, 1, 3),
  q3w2  = c(3, 4, 4, 2, 3, 4, 3, 2, 2, 2),
  q4b1  = c(2, 2, 2, 1, 2, 3, 4, 4, 2, 1),
  q4w1  = c(3, 4, 3, 3, 4, 4, 3, 2, 4, 2),
  q4b2  = c(1, 1, 4, 2, 1, 1, 1, 1, 1, 3),
  q4w2  = c(4, 3, 1, 4, 3, 2, 2, 3, 3, 4),
  q5b1  = c(1, 1, 1, 3, 3, 2, 3, 3, 3, 1),
  q5w1  = c(2, 2, 2, 2, 4, 4, 2, 2, 2, 2),
  q5b2  = c(3, 3, 3, 1, 1, 1, 1, 1, 4, 3),
  q5w2  = c(4, 4, 4, 4, 2, 3, 4, 4, 1, 4),
  q6b1  = c(1, 3, 3, 1, 2, 4, 3, 3, 3, 3),
  q6w1  = c(4, 2, 1, 3, 1, 1, 1, 4, 1, 1),
  q6b2  = c(3, 1, 2, 4, 4, 3, 2, 1, 2, 4),
  q6w2  = c(2, 4, 4, 2, 3, 2, 4, 2, 4, 2),
  q7b1  = c(4, 4, 2, 2, 3, 4, 4, 4, 2, 1),
  q7w1  = c(3, 2, 4, 1, 1, 3, 3, 3, 1, 3),
  q7b2  = c(2, 3, 3, 4, 4, 2, 2, 2, 4, 4),
  q7w2  = c(1, 1, 1, 3, 2, 1, 1, 1, 3, 2),
  q8b1  = c(3, 2, 2, 2, 1, 3, 2, 2, 3, 3),
  q8w1  = c(4, 4, 1, 4, 4, 4, 3, 1, 2, 2),
  q8b2  = c(2, 1, 3, 1, 2, 2, 4, 3, 1, 4),
  q8w2  = c(1, 3, 4, 3, 3, 1, 1, 4, 4, 1),
  q9b1  = c(4, 1, 3, 4, 3, 3, 3, 1, 4, 4),
  q9w1  = c(2, 4, 1, 3, 4, 1, 1, 2, 3, 1),
  q9b2  = c(1, 2, 2, 2, 2, 4, 2, 3, 2, 2),
  q9w2  = c(3, 3, 4, 1, 1, 2, 4, 4, 1, 3))
# Store names of response variables
rsp.vars <- list(
  q1 = c("q1b1", "q1w1", "q1b2", "q1w2"),
  q2 = c("q2b1", "q2w1", "q2b2", "q2w2"),
  q3 = c("q3b1", "q3w1", "q3b2", "q3w2"),
  q4 = c("q4b1", "q4w1", "q4b2", "q4w2"),
  q5 = c("q5b1", "q5w1", "q5b2", "q5w2"),
  q6 = c("q6b1", "q6w1", "q6b2", "q6w2"),
  q7 = c("q7b1", "q7w1", "q7b2", "q7w2"),
  q8 = c("q8b1", "q8w1", "q8b2", "q8w2"),
  q9 = c("q9b1", "q9w1", "q9b2", "q9w2"))
# Store names of attributes
attributes <- c("A", "B", "C", "D")
# Create a dataset
bws3dat <- bws3.dataset(
  data = dat, id = "IDvar", response = rsp.vars,
  choice.sets = dsgn, categorical = attributes, model = "maxdiff")
# Fit the model
clogit(RES ~ A2 + A3 + B2 + B3 + C2 + C3 + D2 + D3 + strata(STR), bws3dat)

Designing choice sets for Case 3 best-worst scaling

Description

This function creates a design for Case 3 best-worst scaling (BWS) from a full/fractional factorial design (FFD) and a balanced incomplete block design (BIBD).

Usage

bws3.design(bibd, ffd, attribute.levels)

Arguments

bibd

A data frame or matrix containing a BIBD.

ffd

A data frame or matrix containing a FFD.

attribute.levels

A list containing the names of the attributes and their levels.

Details

This function creates the choice sets for Case 3 BWS according to Louviere et al. (2015): candidate alternatives (profiles) are created using a FFD; and then the profiles are assigned to the choice sets using a BIBD. The FFD and BIBD used in the function must satisfy the following:

1) The level values in the FFD and those in the BIBD are serial integer values starting from 1.

2) The number of columns of the BIBD is equal to or larger than three.

3) The number of treatments in the BIBD is equal to the number of rows of the FFD.

4) The number of columns of the FFD is equal to the number of attributes.

5) The order of columns (from left to right) of the FFD corresponds to the order of component names in the list assigned to the argument attribute.levels.

Value

This function returns an object of S3 class "cedes" which is a list of the following components (see also the help for rotation.design in the support.CEs package):

alternatives

A list of objects, alt.j: the j-th alternative in each choice set created by the function. Each alt.j includes the variables BLOCK, QES, ALT, and attribute variables corresponding to the argument attribute.levels.

design.information

Information related to the design for Case 3 BWS created by the function. This list includes objects such as the number of blocks into which the design is divided (nblocks), the number of questions per block (nquestions), the number of alternatives per choice set (nalternatives), and the number of attributes per alternative (nattributes).

References

See the help page for support.BWS3-package.

See Also

bws3.dataset, bws3.response, support.BWS3-package, rotation.design

Examples

# See the section Examples in the help page for the function bws3.response.

Generating artificial responses to Case 3 best-worst scaling questions

Description

This function synthesizes responses to Case 3 best-worst scaling (BWS) questions on the basis of a maximum difference model.

Usage

bws3.response(design, categorical.attributes = NULL, 
  continuous.attributes = NULL, asc = NULL, common = NULL,
  optout = FALSE, b, n, detail = FALSE, seed = NULL)

Arguments

design

An object of the S3 class "cedes".

categorical.attributes

A vector containing the names of the attributes that are treated as dummy-coded variables in the model. If there are no categorical variables, it is set as NULL (default).

continuous.attributes

A vector containing the names of the attributes that are treated as continuous variables in the model. If there are no continuous variables, it is set as NULL (default).

asc

A vector containing binary values, which takes the value of 1 when an alternative specific constant (ASC) is included in the utility function of an alternative and 0 otherwise. The i-th element in the vector corresponds to the i-th alternative. If there are no ASCs, it is set as NULL (default).

common

A named vector containing a fixed combination of levels corresponding to a common alternative (base/reference) in the choice sets. If the common alternative is an opt-out (no choice) option, use the argument optout instead. If there is no common option, it is set as NULL (default).

optout

A logical variable describing whether the opt-out option is included in the BWS questions. If TRUE (default), the opt-out option is included; if FALSE, it is not.

b

A vector containing parameters of independent variables in the model. The vector is used to calculate utilities for alternatives.

n

An integer value showing the number of respondents in the resultant dataset.

detail

A logical variable: if TRUE, the dataset is returned in a detailed format; and if FALSE (default), the dataset is returned in a simple format.

seed

Seed for a random number generator.

Details

This function synthesizes responses to Case 3 BWS questions on the basis of a maximum difference model. The model assumes that an alternative consists of k attribute-levels, and that m alternatives exist in a choice set (a question). The number of possible pairs where alternative i is selected as the best and alternative j is selected as the worst (i \neq j) from m alternatives is given by m \times (m - 1). The model also assumes that the respondents select alternative i as the best and alternative j as the worst because the difference in utility between alternatives i and j is the highest among all of the m \times (m - 1) differences in utility. The systematic component of the utility is assumed to be a linear additive function of the attribute and/or level variables. If the error component of the utility is assumed to be an independently, identically distributed type I extreme value, the probability of selecting alternative i as the best and alternative j as the worst is expressed as a conditional logit model.

Given the parameter values assigned to the argument b, the choice sets assigned to the argument design, and the classifications of attributes (categorical or continuous) assigned to the arguments categorical.attributes and/or continuous.attributes, the function bws3.response calculates the utility for the alternatives. The parameter values assigned to the argument b are set as a numerical vector where the elements correspond to the parameters of attribute and/or level variables. As an example, assume that three attributes A, B, and C are the first, second, and third continuous attribute, respectively, in alternatives, and their corresponding attribute variables X_{A}, X_{B}, and X_{C} have parameter values of 0.1, 0.4, and -0.5, respectively. A vector assigned to the argument b is c(0.1, 0.4, -0.5). As another example, assume that the three attributes A, B, and C are categorical attributes with three levels each (e.g., levels A1, A2, and A3 for attribute A) and that the first level for each attribute (i.e., A1, B1, and C1) is treated as the base (reference) level. If the parameters for the dummy-coded level variables corresponding to levels A2, A3, B2, B3, C2, and C3 are 0.2, 0.4, 0.4, 0.8, -0.7, and -1.4, respectively, a vector assigned to the argument b is given as c(0, 0.2, 0.4, 0, 0.4, 0.8, 0, -0.7, -1.4), where the first, fourth, and seventh elements correspond to the reference level for each attribute, and thus have a value of 0. After calculating the utility values (by adding the calculated values of the systematic component of the utility and random numbers generated from a type I extreme value distribution), the function bws3.response finds the pair with the highest difference in utility from the m \times (m - 1) differences in utility.

If the systematic component of the utility includes ASCs, the argument asc is set: the i-th element of a binary vector assigned to the argument asc takes a value of 1 if the i-th alternative has an ASC, and takes a value of 0 otherwise. As an example, if a choice set consists of four alternatives and only the fourth alternative has an ASC, a vector c(0, 0, 0, 1) is assigned to the argument asc. Although this creates four ASCs (i.e., ASC1, ASC2, ASC3, and ASC4) corresponding to the four alternatives in the resultant dataset, only the fourth ASC (ASC4) is used in the analysis (the remaining ASC1, ASC2, and ASC3 are ignored). As another example, if a choice set consists of three alternatives and the first and second alternatives have ASCs, a vector c(1, 1, 0) is assigned to the argument asc: this results in three ASCs in the resultant dataset; only the first and second ASCs (ASC1 and ASC2) are used in the analysis.

If BWS questions include an opt-out option, the argument optout is set as TRUE; otherwise it is set as FALSE. The function bws3.response assumes that the opt-out option is the last alternative in each choice set and that all of the attribute and/or level variables associated with the opt-out option have a value of 0.

Value

This function returns a data frame that contains synthesized responses to Case 3 BWS questions, in either a detailed or a simple format. The detailed format dataset contains the following variables, as well as independent variables according to the arguments categorical.attributes and/or continuous.attributes.

id

An identification number of artificial respondents.

BLOCK

A serial number of blocks in the choice sets.

QES

A serial number of questions.

BEST

An alternative number treated as the best in the possible pairs of the best and worst alternatives.

WORST

An alternative number treated as the worst in the possible pairs of the best and worst alternatives.

PAIR

A serial number of possible pairs of the best and worst alternatives for each question.

RES

Responses to BWS questions, taking the value of 1 if a possible pair of the best and worst alternative is selected by the synthesized respondents and 0 otherwise.

STR

A stratification variable used to identify each combination of respondent and question.

The simple format dataset contains the following variables.

id

An identification number of artificial respondents.

BLOCK

A serial number of blocks in the choice sets.

Bi

A variable describing the alternative number that is selected as the best in the i-th BWS question. The serial number of questions is appended to the tail of the variable name (e.g., B1 for the first question, B2 for the second question, and B3 for the third question).

Wi

A variable describing the alternative number that is selected as the worst in the i-th BWS question. The serial number of questions is appended to the tail of the variable name (e.g., W1 for the first question, W2 for the second question, and W3 for the third question).

The detailed format dataset includes a dependent variable and independent variables for the analysis, and thus is available for discrete choice analysis functions such as the function clogit in the survival package. On the other hand, the simple format dataset only contains variables that correspond to responses to BWS questions, as well as id and BLOCK variables. It must be converted using the function bws3.dataset in the package for the analysis. For details, see the Examples section.

See Also

support.BWS3-package, rotation.design, clogit, oa.design, find.BIB

Examples

# The following lines of code synthesize responses to Case 3 BWS questions,
# return them in detailed and simple format, and then fit the models using
# the function clogit in the survival package. The choice sets include 
# three alternatives that are expressed by three attributes (A, B, and C)
# with three levels each. The function bws3.design creates the choice sets
# from a three-level fractional factorial design with 3 factors that is
# generated using the function oa.design in the DoE.base package and a BIBD
# with 9 treatments, 12 blocks, and size 3 that is generated using
# the function find.BIB in the crossdes package. The systematic component
# of the utility for alternatives where all of the three attributes are
# treated as categorical attributes is the same as that explained in 
# the Details section.

## Not run: 
# Load packages
library(DoE.base)
library(survival)
library(crossdes)

# Create design matrix
set.seed(987)
bibd <- find.BIB(trt = 9, b = 12, k = 3)
isGYD(bibd)
oa <- oa.design(nl = c(3, 3, 3), randomize = FALSE)
atr <- list(
  A = c("A1", "A2", "A3"), B = c("B1", "B2", "B3"),
  C = c("C1", "C2", "C3"))
dsgn <- bws3.design(bibd = bibd, ffd = oa, attribute.levels = atr)

# Synthesize responses to Case 3 BWS questions 
param <- c(0, 0.2, 0.4, 0, 0.4, 0.8, 0, -0.7, -1.4)
atr.names <- c("A", "B", "C")
## dataset in detailed format
dat.detail <- bws3.response(
  design = dsgn, b = param, n = 100,
  categorical.attributes = atr.names,
  detail = TRUE, seed = 987)
str(dat.detail)
## dataset in simple format
dat.simple <- bws3.response(
  design = dsgn, b = param, n = 100,
  categorical.attributes = atr.names,
  detail = FALSE, seed = 987)
str(dat.simple)

# Convert dat.simple into dataset for the analysis
dat.simple.md <- bws3.dataset(
  data = dat.simple,
  response = list(
    c("B1", "W1"), c("B2", "W2"), c("B3", "W3"),
    c("B4", "W4"), c("B5", "W5"), c("B6", "W6"),
    c("B7", "W7"), c("B8", "W8"), c("B9", "W9"),
    c("B10", "W10"), c("B11", "W11"), c("B12", "W12")),
  choice.sets = dsgn,
  categorical.attributes = atr.names,
  model = "maxdiff")

# Fit conditional logit models
mf <- RES ~ A2 + A3 + B2 + B3 + C2 + C3  + strata(STR)
out.detail <- clogit(mf, dat.detail)
out.simple <- clogit(mf, dat.simple.md)
out.simple
all.equal(coef(out.detail), coef(out.simple))

## End(Not run)

Consumer valuation of milk

Description

This dataset contains artificial responses to Case 3 BWS questions about consumer valuation of milk.

Usage

data(milk)

Format

A data frame with 150 rows (respondents) and 20 columns (variables).

id

Identification number of respondents.

BLOCK

Serial number of blocks.

B1

Alternative selected as the best in question 1.

W1

Alternative selected as the worst in question 1.

B2

Alternative selected as the best in question 2.

W2

Alternative selected as the worst in question 2.

B3

Alternative selected as the best in question 3.

W3

Alternative selected as the worst in question 3.

B4

Alternative selected as the best in question 4.

W4

Alternative selected as the worst in question 4.

B5

Alternative selected as the best in question 5.

W5

Alternative selected as the worst in question 5.

B6

Alternative selected as the best in question 6.

W6

Alternative selected as the worst in question 6.

B7

Alternative selected as the best in question 7.

W7

Alternative selected as the worst in question 7.

B8

Alternative selected as the best in question 8.

W8

Alternative selected as the worst in question 8.

f

Dummy variable taking 1 if respondent is female, 0 otherwise.

age

Respondent's age: 2 = 20s; 3 = 30s; 4 = 40s; and 5 = 50s.

Author(s)

Hideo Aizaki

Source

Responses were generated artificially as follows.

1) A Case 3 BWS question required respondents to select their most and least preferred ones from among two cartons of milk (Milk 1 and Milk 2) and an opt-out option. Each response variable (B and W) indicates an alternative selected: 1 = Milk 1; 2 = Milk 2; and 3 = the opt-out option.

2) Milk has six attributes: safety, worker, ghg, cattle, biodiversity, and price. The former five attributes refer to sustainable dairy practices involved in the production process of raw milk.

3) A total of 24 questions were created and then divided into 3 sets of 8 questions.

4) Conditions for generating responses were set considering Aizaki et al. (2013) and Aizaki and Takeshita (2023).

5) Respondents' characteristics (variables f and age) were generated randomly.

References

Aizaki H, Takeshita H. (2023) Comparing consumer preferences for sustainable dairy activities among countries. Behaviormetrika 50: 653–677. (Open access paper)

Aizaki H, Nanseki T, Zhou H. (2013) Japanese consumer preferences for milk certified as good agricultural practice. Animal Science Journal 84: 82–89.

See Also

bws3.dataset, rotation.design, clogit

Examples

## Not run: 
# Load packages
library(survival)
library(support.CEs)
# Define attributes and levels
## Each practice attribute has two levels: "wo.x" and "x".
## "wo" is an abbreviation of "without".
## "wo.x" means a milk carton without a label regarding practice x.
## "x" means a milk carton with a label regarding practice x.
attrs <- list(
 safety       = c("wo.safety", "safety"),
 worker       = c("wo.worker", "worker"),
 ghg          = c("wo.ghg", "ghg"),
 cattle       = c("wo.cattle", "cattle"),
 biodiversity = c("wo.biodiversity", "biodiversity"),
 price        = c(148, 158, 168, 178, 188, 198))
# Create choice sets
BWS3design <- rotation.design(
 attribute.names = attrs,
 nalternatives = 2,
 nblocks = 3,
 randomize = TRUE,
 seed = 987)
# Load a dataset "milk"
data(milk)
# Create a dataset
bws3dat <- bws3.dataset(
 data = milk,
 response = list(
  c("B1", "W1"), c("B2", "W2"), c("B3", "W3"), c("B4", "W4"),
  c("B5", "W5"), c("B6", "W6"), c("B7", "W7"), c("B8", "W8")),
 choice.sets = BWS3design,
 categorical.attributes = 
  c("safety", "worker", "ghg", "cattle", "biodiversity"),
 continuous.attributes  = c("price"),
 optout = TRUE,
 asc = c(0,0,1),
 model = "maxdiff")
# Fit a model
bws3mf <- RES ~ ASC3 + safety + worker + ghg + cattle +
                biodiversity + price + strata(STR)
bws3md.cl <- clogit(formula = bws3mf, data = bws3dat)
bws3md.cl
gofm(bws3md.cl)
mwtp(bws3md.cl, monetary.variables = "price")

## End(Not run)