Description Usage Arguments Examples

View source: R/analyze-preference-data.r

The variables in the formula should reference columns in the data parameter and should have the following characteristics.

outcome: Numeric values giving the outcome of interest.

treatment: Character, categorical, or integer values denoting the treatment received by an individual.

arm: Logical value indicating whether the sample was from the random arm (TRUE) or choice (FALSE).

strata: An optional integer value denoting which strata individuals belong to.

1 | ```
preference(form, data, alpha = 0.05)
``` |

`form` |
a formula of the form outcome ~ treatment:arm {| strata}. See Details for more explanation. |

`data` |
a data.frame containing variables specified in the formula |

`alpha` |
(optional numeric) Level of significance (default 0.05) |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
# Unstratified
outcome <- c(10, 8, 6, 10, 5, 8, 7, 6, 10, 12, 11, 6, 8, 10, 5, 7, 9, 12, 6,
8, 9, 10, 7, 8, 11)
arm <- c(rep("choice", 13), rep("random", 12))
treatment <- c(rep(1, 5), rep(2, 8), rep(1, 6), rep(2, 6))
d <- data.frame(outcome=outcome, treatment=treatment, arm=arm)
preference(outcome ~ treatment:arm, d)
# Stratified
outcome <- c(10, 8, 6, 10, 5, 8, 7, 6, 10, 12, 11, 6, 8, 10, 5, 7, 9, 12, 6,
8, 9, 10, 7, 8,11)
random <- c(rep(FALSE, 13), rep(TRUE, 12))
treatment <- c(rep(1, 5), rep(2, 8), rep(1, 6), rep(2, 6))
strata <- c(1,1,2,2,2,1,1,1,1,2,2,2,2,1,1,1,2,2,2,1,1,1,2,2,2)
d <- data.frame(outcome=outcome, treatment=treatment, arm=arm, strata=strata)
preference(outcome ~ treatment:arm|strata, d, alpha=0.1)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.