Contemporary software commonly used to design stated preference experiments are expensive and the code is closed source. spdesign is a free software package with an easy to use interface to make flexible stated preference experimental designs using state-of-the-art methods.
The package was introduced in Mariel, P., Campbell, D., Sandorf, E. D., Meyerhoff, J., Vega-Bayo, A. & Blevins, R., 2025, Environmental Valuation with Discrete Choice Experiments in R: A Guide on Design, Implementation, and Data Analysis, Springer Nature, doi: https://doi.org/10.1007/978-3-031-89338-4
The package can be installed from CRAN.
install.packages("spdesign")A development version of the package can be installed from Github. Tagged releases correspond to CRAN versions of the package. Installing from CRAN, you get the latest official release. Installing from Github gives you the development version.
remotes::install_github("edsandorf/spdesign")This is a basic example which shows you how to solve a common problem:
library(spdesign)
#' Specifying a utility function with 3 attributes and a constant for the
#' SQ alternative. The design has 20 rows.
utility <- list(
alt1 = "b_x1[0.1] * x1[1:5] + b_x2[0.4] * x2[c(0, 1)] + b_x3[-0.2] * x3[seq(0, 1, 0.25)]",
alt2 = "b_x1 * x1 + b_x2 * x2 + b_x3 * x3",
alt3 = "b_sq[0.15] * sq[1]"
)
# Generate designs ----
design <- generate_design(
utility,
rows = 20,
model = "mnl",
efficiency_criteria = "d-error",
algorithm = "federov",
control = list(
max_iter = 10 #NB! This MUST be changed when running real designs
)
)
# Get a summary of the design
summary(design)All software contains bugs and we would very much like to find these and root them out. If you find a bug or get an error message, please reach out so that we can try and improve the software.
We are grateful to Petr Mariel, Jürgen Meyerhoff and Ainhoa Vega for providing feedback and extensive testing of an early version of the package. We also thank participants in the 2022 Summer School “Valuing options of adaption to climate change using choice experiments” at the University of Cape Town for valuable feedback on a beta version of the package.
We would also like to acknowledge all those who have contributed with bug reports: Gabriele Iannaccone, Petr Mariel, Julian Sagebiel, Huu-Luat Do, Eduardo Barbosa, Binod Prasad Sapkota, Klaus Moeltner
The package comes with no warranty and the authors cannot be held liable for errors or mistakes resulting from use. The authors acknowledge funding from the European Union’s Horizon 2020 research and innovation program under the Marie Sklodowska-Curie grant INSPiRE (Grant agreement ID: 793163).