ct2df | R Documentation |
A convinience function converting a data frame object in contingency-table format of bid(s) and responses of dichotomous choice CV into a simple data frame of individual observations. The outcome is suitable for the analysis using functions in the package.
ct2df(x,
bid1 = "bid1", bid2h = "bidh", bid2l = "bidl", bidl = "bidl", bidh = "bidh",
nny = "nny", nnn = "nnn", yy = "yy", yn = "yn", ny = "ny", nn = "nn",
y = "y", n = "n", n_y = "n_y", n_n = "n_n", nn_y = "nn_y", nn_n = "nn_n",
type = "double", spike = FALSE)
x |
a data frame object in contingency-table format containing bid(s) and responses |
bid1 |
a character string showing the bid (for "single") or the bid in the first stage (for "double") |
bid2h |
a character string showing the second (higher) bid when respondents answer "Yes" in the first stage |
bid2l |
a character string showing the second (lower) bid when respondents answer "No" in the first stage |
bidh |
a character string showing the higher bid (for "oohb") |
bidl |
a character string showing the lower bid (for "oohb") |
nny |
a character string showing a number of respondents rejecting the first and the second bids and having a positive willingness-to-pay (WTP) (for a spike "double") |
nnn |
a character string showing a number of respondents rejecting the first and the second bids and having a zero WTP (for a spike "double") |
yy |
a character string showing a number of respondents accepting both the first and the second bids |
yn |
a character string showing a number of respondents accepting only the first bid |
ny |
a character string showing a number of respondents accepting only the second bid (for "double") or rejecting the first bid and having a positive WTP (for a spike "single") |
nn |
a character string showing a number of respondents rejecting the first and the second bids (for "double") or rejecting the first bid and having a zero WTP (for a spike "single") |
y |
a character string showing a number of respondents accepting the bid |
n |
a character string showing a number of respondents rejecting the bid |
n_y |
a character string showing a number of respondents rejecting the bid and having a positive WTP (for a spike "oohb") |
n_n |
a character string showing a number of respondents rejecting the bid and having a zero WTP (for a spike "oohb") |
nn_y |
a character string showing a number of respondents rejecting the first and second bids and having a positive WTP (for a spike "oohb") |
nn_n |
a character string showing a number of respondents rejecting the first and second bid and having a zero WTP (for a spike "oohb") |
type |
a character string setting the elicitation format, which takes one of "single" (single-bounded dichotomous choice format), "oohb" (one-and-one-half-bounded dichotomous choice format), or "double" (double-bounded dichotomous choice format) |
spike |
a logical code: |
The function ct2df
implements a conversion of a data frame
containing bid(s) and responses regarding dichotomous choice CV in
contingency-table format into a data frame suitable for use by the functions
sbchoice
, oohbchoice
, dbchoice
, sbspike
, oohbspike
, dbspike
, kristrom
,
turnbull.sb
, and turnbull.db
.
See CarsonSB
and CarsonDB
for dataset
in contingency-table format.
See the examples below and ones in spike-models
, for usage in detail.
The function returns a data frame, in which each row shows a single respondent. It contains the following variables.
For "single",
R1 |
a response to a bid: 1 for "Yes", 0 for "No" |
bid1 |
the bid |
For "double",
B1 |
a bid in the first stage |
B2H |
a (higher) bid in the second stage when the response is "Yes" in the first stage |
B2L |
a (lower) bid in the second stage when the response is "No" in the first stage |
R |
a combination of responses in the first and second stages, which takes yy for "Yes" and "Yes", yn for "Yes" and "No", ny for "No" and "Yes", or nn for "No" and "No" |
R1 |
the response in the first stage, which takes 1 for "Yes", 0 for "No" |
R2 |
the response in the second stage, which takes 1 for "Yes", 0 for "No" |
bid1 |
the bid in the first stage |
bid2 |
the bid in the second stage the respondent faced |
For "oohb",
BH |
a higher bid |
BL |
a lower bid |
R |
a combination of responses in the first and second stages |
R1 |
the response in the first stage, which takes |
R2 |
the response in the second stage, which takes |
For spike models,
S |
the response in a simple spike question, which takes |
Aizaki H, Nakatani T, Sato K (2014). Stated Preference Methods Using R. CRC Press, Boca Raton, FL.
sbchoice
, oohbchoice
, dbchoice
,
sbspike
, oohbspike
, dbspike
,
kristrom
, turnbull.sb
, turnbull.db
# Single-bounded dichotomous choice CV format
data(CarsonSB)
CarsonSB
CarsonSB.dat <- ct2df(
x = CarsonSB,
bid1 = "T1",
y = "Y",
n = "N",
type = "single")
head(CarsonSB.dat)
summary(turnbull.sb(R1 ~ bid1, data = CarsonSB.dat))
# Double-bounded dichotomous choice CV format
data(CarsonDB)
CarsonDB
CarsonDB.dat <- ct2df(
x = CarsonDB,
bid1 = "T1",
bid2h = "TU",
bid2l = "TL",
yy = "yy",
yn = "yn",
ny = "ny",
nn = "nn",
type = "double")
head(CarsonDB.dat)
summary(turnbull.db(R1 + R2 ~ bid1 + bid2, data = CarsonDB.dat))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.