Sign inSign up

skranz/mm_comment

By skranz

•Updated over 4 years ago

Replication container for the comment Kranz and Puetz (2022) on Brodeur et al. (2020)

Image
0

276

skranz/mm_comment repository overview

This container allows to replicate Kranz and Puetz (conditionally accepted, AER): Methods Matter: p-Hacking and Publication Bias in Causal Analysis in Economics: Comment .

First install Docker. Then pull this image from Dockerhub. Type in your Linux shalle the command:

docker pull skranz/mm_comment:latest

⁠Running without Stata

To run the container without Stata, adapt the following command and then run it in the shell:

docker run -entrypoint="/usr/bin/with-contenv bash" --name mm_comment -d  -p 8805:8787 -e ROOT=FALSE -e USER=rstudio -e PASSWORD=<YOUR_PASSWORD> skranz/mm_comment:latest

You need to replace <YOUR_PASSWORD> by a password of your choice.

The container hosts RStudio Server that you can access to from your web browser under

http://localhost:8805

In the log-in screen type as username rstudio and as password the password you have specified in you docker run command above.

In RStudio open the file README.md in the directory methods_matter_comment and follow the instructions there. All R code can be run, but to run the Stata code, you need to map a Stata 16 license as explained below.

If you want to access the Linux shell inside your container, you can open in RStudio Tools -> Shell. To install additional software that require sudo rights, you may want to change the -e ROOT=FALSE to -e ROOT=TRUE in your docker run command.

⁠Stopping the container

If you want to change the run command (e.g. add a Stata license) you first have to stop and remove your container. For this run on your server:

docker stop mm_comment
docker rm mm_comment

⁠Running with Stata

To use Stata in the docker container adapt the following command:

docker run -entrypoint="/usr/bin/with-contenv bash" --name mm_comment -d  -p 8805:8787 -e ROOT=FALSE -e USER=rstudio -e PASSWORD=<YOUR_PASSWORD> -v <PATH TO YOUR STATA LICENSE FILE stata.lic>:/usr/local/stata/stata.lic skranz/mm_comment:latest

You also need to replace <PATH TO YOUR STATA LICENSE FILE stata.lic> with the complete file path to a stata.lic license file on your computer. This file can typically be found in your Stata folder (better make a copy). Make sure that you still satisfy the terms of your Stata license if you run it in the container.

The container contains Stata 16 (from the dataeditors container). So it probably only works with a Stata 16 licencse.

⁠Using Stata interactively in RStudio in the container

We added to the docker container the following R package:

https://github.com/skranz/RStudioStataConsole⁠

It allows to use Stata interactively from your RStudio Server instance running in your webbrowser.

You can start a Stata session in a terminal by clicking here in RStudio on

Addins -> Start Stata

(Or manually by Tools -> Shell and then typing stata in the shell console).

You can open and edit do file in the file pane by clicking on it in the file pane.

To run a do file that is active in your editor use

Addins -> Run do file

To run a single line from an open do file in the Stata terminal do the following:

  1. Put the cursor on the line in the do file that you want to run
  2. Make sure you have the Stata terminal window open
  3. Press Ctrl-Alt-Enter

To show the current data set in your Stata terminal session use in RStudio

Addins -> View Stata Data

(This will first export in Stata the current data set into a temporary .dta file and the load and view it in RStudio. Should the creation of the data set take longer than 5 seconds, there will be a time out)

⁠Mapping replication repository folder on your server into the container

If you adapt scripts etc, the changes will only be present inside the docker container. While you can download files from RStudio, you may want to directly affect affect a directory on your computer outside the container. You can do so by specifying volumes in the docker run command. See here for details:

https://docs.docker.com/storage/volumes/⁠

Assume you have downloaded and unpacked our openICPSR repository on a windows PC. Then adapt the following comman:

docker run -entrypoint="/usr/bin/with-contenv bash" --name mm_comment -d  -p 8805:8787 -e ROOT=FALSE -e USER=rstudio -e PASSWORD=<YOUR_PASSWORD> -v <PATH TO YOUR STATA LICENSE FILE stata.lic>:/usr/local/stata/stata.lic -v <LOCAL PATH TO CODE SUPPLEMENT>:/home/rstudio/methods_matter_comment  skranz/mm_comment:latest

You have to change <LOCAL PATH TO CODE SUPPLEMENT> to the main directory of your code supplement on your computer (the main directory is the directory where the mm_repliation.Proj is located).

⁠Running main.R directly with a docker run command

If for some reason you just want to check, whether the replication scripts run without starting RStudio, you could adapt and run the Docker run command below:

docker run --user rstudio -v <LOCAL PATH TO stata.lic>:/usr/local/stata/stata.lic -it -v <LOCAL PATH TO CODE SUPPLEMENT>:/home/rstudio/methods_matter_comment  skranz/mm_comment:latest R -e 'Sys.setenv("PATH" = paste(Sys.getenv("PATH"),"/usr/local/stata/",sep=":")); setwd("/home/rstudio/methods_matter_comment");options(stata.silent=TRUE); source("Scripts/main.R")'

You need to adapt the mounted paths to the stata.lic file and to your code supplement. The code then also generates several Stata log files. Please make sure that you have approbriate read and write permissions for the mounted directory with the code supplement. You don't need to mount the code supplement, but then you cannot access and check the modified files or the generated stata log.

Tag summary

Content type

Image

Digest

Size

1.8 GB

Last updated

over 4 years ago

docker pull skranz/mm_comment