if (FALSE) {
# 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")
}
Run the code above in your browser using DataLab