Appendix#

Exercise 1#

Tell me about these data#

For each of the datasets, answer the following questions:

  1. Do you have to agree in some fashion to a data use agreement? If yes, how?

  2. Can you download the data today?

  3. Can you share it with your team members?

  4. Can you include the data in the replication package?

  5. How would you go about preserving the data you used for reproducibility and replicability?

Group 1

Group 2

Group 3

Exercise 2#

Downloading data via code#

Easiest:

Stata

use "$URL" , clear

Why not?

  • Will it be there in two months? In six years?

  • What if the internet connection is down?

Easy:

Stata

global URL "https://www.cepii.fr/distance/dist_cepii.dta"
copy "$URL" (outputfile), replace

R

download.file(url="$URL",destfile="(outputfile)")

What if the internet dies? Use caching of downloaded data.

// ::::  Process only if data are present 

capture confirm  file "${datapath}/dist_cepii.dta"
if _rc == 0 {
    di in green "Data file is present, processing data"
} else { 
    di in red "Downloading data" 
    copy "$URL" "${datapath}/dist_cepii.dta", replace
}

//============ at this point, the data is available ======
// ::::  Process always 

use "${datapath}/dist_cepii.dta", clear
// do stuff....

That was easy! On to confidential data!

Environments in Stata#

See Environments in Stata.

Additional training resources#

Examples of replication packages#

This textbook’s source: labordynamicsinstitute/reproducibility-confidential

Licensed under CC BY-NC 4.0