Facilitates many of the analyses performed in studies of
behavioral economic demand. The package supports commonly-used options for
modeling operant demand including (1) data screening proposed by Stein,
Koffarnus, Snider, Quisenberry, & Bickel (2015;
An R package containing commonly used functions for analyzing behavioral economic demand curve data.
Install and load the devtools package. Then, use install_github to install the package and associated vignette.
install.packages("devtools")install.packages("digest") devtools::install_github("brentkaplan/beezdemand", build_vignettes = TRUE) library(beezdemand)
Currently, this version (0.0.95) is under development. You are free to use it, but be aware that there might be bugs present. If you find issues or would like to contribute, please contact me at [email protected].
Example dataset of responses on an Alcohol Purchase Task. Participants (id) reported the number of alcoholic drinks (y) they would be willing to purchase and consume at various prices (x; USD). Note the long format.
id x y1 19 0.0 102 19 0.5 103 19 1.0 104 19 1.5 85 19 2.0 86 19 2.5 87 19 3.0 78 19 4.0 717 30 0.0 318 30 0.5 319 30 1.0 320 30 1.5 321 30 2.0 222 30 2.5 223 30 3.0 224 30 4.0 2
Descriptive values of responses at each price. Includes mean, standard deviation, proportion of zeros, and numer of NAs.
> GetDescriptives(apt) 0 0.5 1 1.5 2 2.5 3 4 5 6 7 8 9 10Mean 6.80 6.80 6.50 6.10 5.30 5.20 4.80 4.30 3.90 3.50 3.30 2.60 2.40 2.20SD 2.62 2.62 2.27 1.91 1.89 1.87 1.48 1.57 1.45 1.43 1.34 1.51 1.58 1.32PropZeros 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.10 0.10 0.10NAs 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 15 20Mean 1.10 0.80SD 1.37 1.14PropZeros 0.50 0.60NAs 0.00 0.00
Examine consistency of demand data using Stein et al.'s (2015) alogrithm for identifying unsystematic responses. Default values shown.
> head(CheckUnsystematic(apt, deltaq = 0.025, bounce = 0.1, reversals = 0, ncons0 = 2), 3) Participant TotalPass DeltaQ DeltaQPass Bounce BouncePass Reversals1 19 3 0.2112 Pass 0 Pass 02 30 3 0.1437 Pass 0 Pass 03 38 3 0.7885 Pass 0 Pass 0 ReversalsPass NumPosValues1 Pass 162 Pass 163 Pass 14
Results of the analysis return both empirical and derived measures for use in additional analyses and model specification.
> head(FitCurves(apt, "hs"), 3) Participant Q0e BP0 BP1 Omaxe Pmaxe Equation Q0 K R21 19 10 NA 20 45 15 hs 10.492736 1 0.96433802 30 3 NA 20 20 20 hs 2.942614 1 0.79348223 38 4 15 10 21 7 hs 4.525925 1 0.8656883 Alpha Q0se Alphase N AbsSS SdRes Q0Low1 0.004856258 0.4312016 0.0002574193 16 0.02028108 0.03806112 9.5679012 0.014057972 0.2531714 0.0018292289 16 0.09724906 0.08334484 2.3996163 0.009120746 0.2373820 0.0009315781 14 0.02601971 0.04656511 4.008714 Q0High AlphaLow AlphaHigh EV Omaxd Pmaxd Notes1 11.417572 0.004304148 0.005408367 2.0591989 45.63181 14.38512 converged2 3.485613 0.010134666 0.017981278 0.7113402 15.76329 17.71936 converged3 5.043136 0.007091012 0.011150481 1.0964015 24.29624 17.75686 converged > head(FitCurves(apt, "koff"), 3) Participant Q0e BP0 BP1 Omaxe Pmaxe Equation Q0 K R21 19 10 NA 20 45 15 koff 10.219980 1 0.96369112 30 3 NA 20 20 20 koff 3.025350 1 0.81882533 38 4 15 10 21 7 koff 4.599041 1 0.8182557 Alpha Q0se Alphase N AbsSS SdRes Q0Low Q0High1 0.004501826 0.2673350 0.0002894209 16 3.186106 0.4770524 9.646603 10.7933562 0.014498545 0.1780691 0.0021436221 16 1.449398 0.3217583 2.643430 3.4072713 0.010588272 0.3414723 0.0018843340 16 5.043406 0.6002027 3.866656 5.331426 AlphaLow AlphaHigh EV Omaxd Pmaxd Notes1 0.003881080 0.005122573 2.2213207 49.22443 15.93181 converged2 0.009900933 0.019096158 0.6897244 15.28428 16.71106 converged3 0.006546778 0.014629766 0.9444412 20.92880 15.05260 converged
Provides the ability to share k globally (across all participants) while estimating Q0 and alpha locally.
> head(FitCurves(apt, "hs", k = "share"), 3) Participant Q0e BP0 BP1 Omaxe Pmaxe Equation Q0d SharedK R21 19 10 NA 20 45 15 hs 10.0146 3.3183 0.982102 30 3 NA 20 20 20 hs 2.7663 3.3183 0.764183 38 4 15 10 21 7 hs 4.4858 3.3183 0.88031 Alpha Q0se Alphase N AbsSS SdRes Q0Low Q0High AlphaLow1 0.0011616 0.24291 3.0813e-05 16 0.010182 0.026968 9.4936 10.5356 0.00109552 0.0033331 0.21928 3.7389e-04 16 0.111049 0.089062 2.2960 3.2366 0.00253123 0.0024580 0.20750 1.9633e-04 14 0.023186 0.043957 4.0337 4.9379 0.0020302 AlphaHigh EVd Omaxd Pmaxd Notes1 0.0012277 1.42418 44.552 13.161 converged2 0.0041350 0.49633 15.526 16.604 converged3 0.0028858 0.67304 21.054 13.885 converged
To learn more about a function and what arguments it takes, type "?" in front of the function name.
> ?CheckUnsystematicCheckUnsystematic package:beezdemand R Documentation Systematic Purchase Task Data Checker Description: Applies Stein, Koffarnus, Snider, Quisenberry, & Bickel's (2015) criteria for identification of nonsystematic purchase task data. ...
Derek D. Reed, Applied Behavioral Economics Laboratory (www.behavioraleconlab.com)
Paul E. Johnson, Center for Research Methods and Data Analysis, University of Kansas (www.crmda.ku.edu)
Michael Amlung, Cognitive Neuroscience of Addictions Laboratory (www.cnalab.weebly.com)
Peter G. Roma, Institutes for Behavior Resources, Inc. (www.ibrinc.org)
Steven R. Hursh, Institutes for Behavior Resources, Inc. (www.ibrinc.org)
Shawn P. Gilroy, GitHub
Reed, D. D., Niileksela, C. R., & Kaplan, B. A. (2013). Behavioral economics: A tutorial for behavior analysts in practice. Behavior Analysis in Practice, 6 (1), 34–54.
Reed, D. D., Kaplan, B. A., & Becirevic, A. (2015). Basic research on the behavioral economics of reinforcer value. In Autism Service Delivery (pp. 279-306). Springer New York.
Hursh, S. R., & Silberberg, A. (2008). Economic demand and essential value. Psychological Review, 115 (1), 186-198.
Koffarnus, M. N., Franck, C. T., Stein, J. S., & Bickel, W. K. (2015). A modified exponential behavioral economic demand model to better describe consumption data. Experimental and Clinical Psychopharmacology, 23 (6), 504-512.
Stein, J. S., Koffarnus, M. N., Snider, S. E., Quisenberry, A. J., & Bickel, W. K. (2015). Identification and management of nonsystematic purchase task data: Toward best practice. Experimental and Clinical Psychopharmacology
Have a question? Have a suggestion for a feature? Would you like to contribute? Email me at [email protected].
GPL Version 2 or later
One major change that might affect previous scripts is that in output summary tables, the column formally named ID is now named id (lowercase)
Cleaned up a few things here and there. The package is close for submission to CRAN as it passes R CMD check with no errors, warnings, or notes
GetSharedK()
updated to work better and faster at finding a reasonable value
Internal helper functions added to optimize GetSharedK()
ExtraF()
now compares alpha and Q0
A number of functions now allows you to specify the column names
FitCurves()
correctly pulls alpha and q0 standard errors when k is fitted as a free parameter. Also no longer accepts data transformations. Must be done prior to fitting using ChangeData()
.
FitCurves()
now fits mean/pooled data based on method
argument.
GetSharedK()
no longer accepts data transformations.
New ChangeData()
will soon serve as the replacement to
ReplaceZeros()
and other arguments specified in FitCurves()
.
For the time being, FitCurves()
will actually output a list
object. This may cause failures with old scripts. Try modifying
scripts to take the first element out of the list. This will soon be
taken care of.
New FitMeanCurves()
will fit curve to averaged or pooled
data. Can also make plots.
FitCurves()
can now make plots.
GetDescriptives()
can make box and whisker plots.