pt_prep: Pre-QC Cleaning

View source: R/pt_prep.R

pt_prepR Documentation

Pre-QC Cleaning

Description

This function helps users prepare their fully- or partially-administered purchase task data. See details for full functionality.

Usage

pt_prep(pt, id_var, type, remove0 = TRUE, max_val = NULL)

Arguments

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.

Details

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.

Value

A data frame with the length of participants not identified as removed.

Examples

### --- 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)


PBCAR/PThelper documentation built on May 13, 2024, 3:45 p.m.