pt_prep | R Documentation |
This function helps users prepare their fully- or partially-administered purchase task data. See details for full functionality.
pt_prep(pt, id_var, type, remove0 = TRUE, max_val = NULL)
pt |
A data frame consisting of the 'id_var' and purchase task variables. |
id_var |
The name of the unique identifier (ID) as found in the data frame. |
type |
The type of purchase task administered, one of c("partial","full"). The "full" type of PT administers all price points, regardless of consumption responses. The "partial" type of PT uses consumption responses to determine when to end administration, either at the first instance when consumption reaches zero, or zero consumption at the end of a price array. |
remove0 |
Whether those with zero consumption across all items should be removed. The default is TRUE. |
max_val |
Optional identification of a maximum allowed response for any given price point. |
This function will both identify and remove participants:
i) with any missing responses (fully-administered purchase task); or any missing responses prior to breakpoint (partially-administered purchase task);
ii) (optional) with zero consumption across all items; and
iii) (for purchase tasks not administered in full) without zero consumption at the final price point (except in instances of demand at the final price point).
In addition, this function can re-assign the maximum value allowed at any price point.
A data frame with the length of participants not identified as removed.
### --- Load Data
data("cpt_data")
### --- Prep Data
pt <- price_prep(cpt_data, id_var = "ID", vars = c(paste0("cpt",1:15)),
prices = c("0","0.05","0.10","0.20","0.30","0.40","0.50", "0.75","1","2","3","4","5","7.5","10"))
### --- Function Example
pt2 <- pt_prep(pt, id_var = "ID", type = "partial", remove0 = FALSE, max_val = 99)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.