In this repository, you can find both the data and the analyses for the book:
Zauchner, Patricia F. (2024). Raising the Acceptance of Rank Reversing Redistributions: The Role of Need Considerations. Springer VS.
The CSV files for this project be found in the published_data
folder.
These files contain the manipulated experimental data. The codebook for
the originally downloaded data can be found in the codebook.pdf
file,
which describes the variables as they were defined in the oTree code.
All data manipulations are documented in the make_data.R
file.
You can install R and R-Studio from here: https://posit.co/download/rstudio-desktop/
This code was last tested in R version 4.4.1. If you encounter any issues with this code in newer versions of R, you can install the older version from the following link: https://cran.r-project.org/bin/windows/base/old/. Please also let me know if you encounter any problems. However, please be aware that a basic understanding of R is required to understand the code.
Please open this project by clicking on 4.analyses.Rproj
which is
located in the same folder as this README file.
There are two ways to install the packages used for this project. The
preferred method is to use the renv
package (“Way 1”). Alternatively,
you can install the packages using the code provided in “Way 2.”
Install and run renv::restore()
to install all the packages this
project uses. This is the preferred method because it installs exactly
those versions of the packages that were last tested with this code.
If renv
encounters any issues installing one or more packages, it may
be due to compatibility issues with your R version. One solution is to
delete the problematic package from the list in the renv.lock
file and
see if it resolves the issue. Another option is to install an older R
version compatible with the packages and run the code there. Please
notify me if renv
is not working correctly with the newest R version.
For more information on renv
, visit:
https://rstudio.github.io/renv/articles/renv.html. Additional details
about the lockfile can be found here:
https://rstudio.github.io/renv/articles/lockfile.html.
install.packages("renv")
# The renv snapshot was saved with
# renv::snapshot()
# Retrieve snapshot
renv::restore()
To install the packages, you can also copy the following code into the console and execute it.
# Install and load packages ####
# 1) List packages you need
need <- c(
"afex",
"aod",
"bife",
# "captioner", # Not available for new R versions. Code is copied to file functions_captioner.R
"corrplot",
"data.table",
"devtools",
"DescTools",
"dplyr",
"effects",
"emmeans",
"extrafont",
"ggplot2",
"ggtext",
"gmoTree",
"gtools",
"knitr",
"moments",
"pander",
"performance",
"plm",
"psych",
"rmarkdown",
"sandwich",
"SciViews",
"stringr",
"texreg")
# Install packages if they are not there
have <- need %in% rownames(installed.packages())
if (any(!have)) install.packages(need[!have], dependencies = TRUE)
invisible(lapply(need, library, character.only = TRUE))
# Check what's there
table(need, have)
table(have[have == FALSE], need[have == FALSE])
# Delete
suppressWarnings(rm(have, need))
# Extrafont handling
extrafont::font_import() # This might take some time
All packages used but one were cited in my dissertation. Last minute,
the package extrafont
was also used, which unfortunately could not be
cited in the dissertation. However, I greatly appreciate Chang’s
package. This would be its citation:
Chang Winston (2023). extrafont: Tools for Using Fonts. R package version 0.19. https://CRAN.R-project.org/package=extrafont
You can load the data into your R environment using:
base::load(file = "data.RData")
To run the analyses, knit the following Rmd-files in this folder:
-
experimentchapter.Rmd
contains the time calculations and the correlation matrix of the variables in the redistribution game as presented in Chapter 4. The simulation study is in a separate R project, which you can also download from https://osf.io/96eyp. -
all_analyses.Rmd
contains almost all analyses from Chapter 5 and its connected ESM Appendix D. -
robustness.Rmd
contains the second robustness test in Table ESM Appendix D, Table D9 because this takes longer than the other calculations.
You have the permission to use the data and the code in this repository. For usage of data, you need to cite my dissertation:
Zauchner, Patricia F. (2024). Raising the Acceptance of Rank Reversing Redistributions: The Role of Need Considerations. Springer VS.