# The following lines of code reproduce five examples shown on
# the website Discrete Choice Experiments.
# Check Main Ex. 1
## Not run:
# CheckMainEx1.sets <- matrix(c(
# 0, 0, 0, 0, 3, 2, 2, 2,
# 2, 2, 0, 2, 1, 1, 2, 1,
# 3, 0, 0, 0, 2, 2, 2, 2,
# 1, 1, 0, 1, 0, 0, 2, 0,
# 1, 0, 2, 0, 0, 2, 1, 2,
# 3, 2, 1, 0, 2, 1, 0, 2,
# 2, 1, 0, 0, 1, 0, 2, 2,
# 0, 0, 0, 2, 3, 2, 2, 1,
# 3, 0, 0, 1, 2, 2, 2, 0,
# 0, 2, 2, 1, 3, 1, 1, 0,
# 1, 2, 0, 0, 0, 1, 2, 2,
# 1, 0, 1, 2, 0, 2, 0, 1,
# 2, 0, 2, 0, 1, 2, 1, 2,
# 2, 0, 1, 1, 1, 2, 0, 0,
# 3, 1, 2, 2, 2, 0, 1, 1,
# 0, 1, 1, 0, 3, 0, 0, 2),
# nrow = 16, byrow = TRUE)
#
# CheckMainEx1 <- sb.design(
# operation = "check",
# nattributes = 4,
# nlevels = c(4, 3, 3, 3),
# nalternatives = 2,
# attribute.names = list(A = c("a0", "a1", "a2", "a3"),
# B = c("b0", "b1", "b2"),
# C = c("c0", "c1", "c2"),
# D = c("d0", "d1", "d2")),
# design = CheckMainEx1.sets,
# effect = "main")
#
# CheckMainEx1
# summary(CheckMainEx1)## End(Not run)
# Construct Main Ex. 1
## Not run:
# ConstructMainEx1.treatment <- matrix(c(
# 0, 0, 0, 0,
# 2, 2, 0, 2,
# 3, 0, 0, 0,
# 1, 1, 0, 1,
# 1, 0, 2, 0,
# 3, 2, 1, 0,
# 2, 1, 0, 0,
# 0, 0, 0, 2,
# 3, 0, 0, 1,
# 0, 2, 2, 1,
# 1, 2, 0, 0,
# 1, 0, 1, 2,
# 2, 0, 2, 0,
# 2, 0, 1, 1,
# 3, 1, 2, 2,
# 0, 1, 1, 0),
# nrow = 16, byrow = TRUE)
#
# ConstructMainEx1 <- sb.design(
# operation = "construct",
# nattributes = 4,
# nlevels = c(4, 3, 3, 3),
# nalternatives = 2,
# attribute.names = list(A = c("a0", "a1", "a2", "a3"),
# B = c("b0", "b1", "b2"),
# C = c("c0", "c1", "c2"),
# D = c("d0", "d1", "d2")),
# design = ConstructMainEx1.treatment,
# generators = c(3, 2, 2, 2),
# effect = "main")
#
# ConstructMainEx1
# summary(ConstructMainEx1)## End(Not run)
# Construct Main Ex. 2
## Not run:
# ConstructMainEx2.treatment <- matrix(c(
# 0, 0,
# 0, 1,
# 1, 0,
# 1, 1),
# nrow = 4, byrow = TRUE)
#
# ConstructMainEx2 <- sb.design(
# operation = "construct",
# nattributes = 2,
# nlevels = c(2, 2),
# nalternatives = 2,
# attribute.names = list(X = c("x0", "x1"),
# Y = c("y0", "y1")),
# design = ConstructMainEx2.treatment,
# generators = c(1, 1),
# effect = "main")
#
# ConstructMainEx2
# summary(ConstructMainEx2)## End(Not run)
# Construct Main + Some Ex. 1
## Not run:
# ConstructMainSomeEx1.treatment <- matrix(c(
# 0, 0, 0, 0,
# 2, 2, 0, 2,
# 3, 0, 0, 0,
# 1, 1, 0, 1,
# 1, 0, 2, 0,
# 3, 2, 1, 0,
# 2, 1, 0, 0,
# 0, 0, 0, 2,
# 3, 0, 0, 1,
# 0, 2, 2, 1,
# 1, 2, 0, 0,
# 1, 0, 1, 2,
# 2, 0, 2, 0,
# 2, 0, 1, 1,
# 3, 1, 2, 2,
# 0, 1, 1, 0),
# nrow = 16, byrow = TRUE)
#
# ConstructMainSomeEx1 <- sb.design(
# operation = "construct",
# nattributes = 4,
# nlevels = c(4, 3, 3, 3),
# nalternatives = 2,
# attribute.names = list(A = c("a0", "a1", "a2", "a3"),
# B = c("b0", "b1", "b2"),
# C = c("c0", "c1", "c2"),
# D = c("d0", "d1", "d2")),
# design = ConstructMainSomeEx1.treatment,
# generators = c(3, 2, 2, 2),
# effect = "mplussome",
# interactions = c(1, 2),
# determinant = "1")
#
# ConstructMainSomeEx1
# summary(ConstructMainSomeEx1)## End(Not run)
# Construct Main + Some Ex. 2
## Not run:
# ConstructMainSomeEx2.treatment <- matrix(c(
# 0, 0,
# 0, 1,
# 1, 0,
# 1, 1),
# nrow = 4, byrow = TRUE)
#
# ConstructMainSomeEx2 <- sb.design(
# operation = "construct",
# nattributes = 2,
# nlevels = c(2, 2),
# nalternatives = 2,
# attribute.names = list(X = c("x0", "x1"),
# Y = c("y0", "y1")),
# design = ConstructMainSomeEx2.treatment,
# generators = matrix(c(0, 1, 1, 1), nrow = 2, byrow = TRUE),
# effect = "mplussome",
# interactions = c(1, 2),
# determinant = NULL)
#
# ConstructMainSomeEx2
# summary(ConstructMainSomeEx2)## End(Not run)
Run the code above in your browser using DataLab