Skip to content

Commit

Permalink
Updates to the presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
larsvilhuber committed Jul 1, 2024
1 parent 5ca3aff commit 4fc689d
Show file tree
Hide file tree
Showing 15 changed files with 1,721 additions and 233 deletions.
25 changes: 25 additions & 0 deletions presentation/00-index-mod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# Introduction

This document describes a few **possible** steps to self-check replication packages before submitting them to a journal. It is not meant to be exhaustive, and it is not meant to be prescriptive. There are **many ways to construc**t a replication package, and many more to check that it works.

## Computational Empathy
The key ingredient is what I call "**computational empathy**" - thinking about what an unknown person attempting to reproduce the results in your paper might face, **what they might know and assume**, and more importantly, **what they might not know** or know to assume. While the replication package might very well run on your computer, that is by no means evidence that it will run on someone else's computer.

## Prerequisites {.smaller}

In what follows, we will assume that the replicator satisfies the following conditions:

::: {.incremental}

- they are familiar with their own **operating system** (not yours!)
- they are somewhat familiar with **how to run code** in the "dominant" programming language in your field (but...)
- they are **probably not familiar** with cutting edge methods of running software that you might be using (but want to learn!)
- they likely have some experience with **how social scientists write code** and prepare data, but may not have your years of experience

:::

## TL;DR

Techy lingo for "**too long, didn't read**". A summary of the most important takeaways will be at the top of each section.

8 changes: 4 additions & 4 deletions presentation/01-run_it_again.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Furthermore, it may suggest that you haven't been able to re-run your own code v
::: {.incremental}

- ✅ your code runs without problem, after all the debugging.
- your code runs without manual intervention, and with low effort
- it actually produces all the outputs
- your code generates a log file that you can inspect, and that you could share with others.
- it will run on somebody else's computer
- [ ] your code runs without manual intervention, and with low effort
- [ ] it actually produces all the outputs
- [ ]your code generates a log file that you can inspect, and that you could share with others.
- [ ] it will run on somebody else's computer

:::
6 changes: 3 additions & 3 deletions presentation/02-hands_off_running.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ For examples for **Julia, Python, MATLAB,** and **multi-software scripts**, see

- ✅ your code runs without problem, after all the debugging.
- ✅your code runs without manual intervention, and with low effort
- it actually produces all the outputs
- your code generates a log file that you can inspect, and that you could share with others.
- it will run on somebody else's computer
- [ ] it actually produces all the outputs
- [ ] your code generates a log file that you can inspect, and that you could share with others.
- [ ] it will run on somebody else's computer


4 changes: 2 additions & 2 deletions presentation/03-automatically_saving_figures.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Learn how to save tables in robust, reproducible ways. Do not try to copy-paste
- ✅ your code runs without problem, after all the debugging.
- ✅your code runs without manual intervention, and with low effort
- ✅it actually produces all the outputs
- your code generates a log file that you can inspect, and that you could share with others.
- it will run on somebody else's computer
- [ ] your code generates a log file that you can inspect, and that you could share with others.
- [ ] it will run on somebody else's computer

:::
6 changes: 1 addition & 5 deletions presentation/04-creating_log_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,8 @@ which will create a log file with everything that would normally appear on the c
## Takeaways


::: {.incremental}

- ✅ your code runs without problem, after all the debugging.
- ✅your code runs without manual intervention, and with low effort
- ✅it actually produces all the outputs
- ✅your code generates a log file that you can inspect, and that you could share with others.
- ❓it will run on somebody else's computer

:::
- [ ] it will run on somebody else's computer
117 changes: 117 additions & 0 deletions presentation/05-00-intermezzo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Environments


## TL;DR

- Search paths and environments are key concepts to create **portable**, **reproducible** code, by **isolating** each project from others.
- Methods exist in all (statistical) programming languages

## What is an environment?

From the [renv](https://rstudio.github.io/renv/) documentation:

- **Isolated**: Installing a new or updated package for one project won't break your other projects, and vice versa.
- **Portable**: Easily transport your projects from one computer to another, *even across different platforms*.
- **Reproducible**: Records the exact package versions you depend on, and ensures those exact versions are the ones that get installed wherever you go.

## What software supports environments?

- R: `renv` package
- Python: `venv` or `virtualenv` module
- Julia: `Pkg` module

## "But I use Stata!"

## Hold on...

## Understanding search paths

Generically, all "environments" simply modify where the specific **software searches** (the "search path") for its components, and in particular any supplementary components (packages, libraries, etc.).[^searchpaths]

[^searchpaths]: Formally, this is true for operating systems as well, and in some cases, the operating system and the programming language interact (for instance, in Python).

## Search paths {auto-animate=true}


:::: {.columns}

::: {.column width=30%}

- R: `.libPaths()`

:::

::: {.column width=70%}

```{.r code-line-numbers="2-3"}
> .libPaths()
[1] "C:/Users/lv39/AppData/Local/R/win-library/4.3"
[2] "C:/Users/lv39/AppData/Local/Programs/R/R-4.3.2/library"

```

:::

::::

## Search paths {auto-animate=true}

:::: {.columns}

::: {.column width=30%}

- R: `.libPaths()`
- Python: `sys.path`

:::

::: {.column width=70%}

```{.python code-line-numbers="4-9"}
>>> import sys
>>> from pprint import pprint
>>> pprint(sys.path)
['',
'C:\\Users\\lv39\\AppData\\Local\\Programs\\Python\\Python312\\python312.zip',
'C:\\Users\\lv39\\AppData\\Local\\Programs\\Python\\Python312\\DLLs',
'C:\\Users\\lv39\\AppData\\Local\\Programs\\Python\\Python312\\Lib',
'C:\\Users\\lv39\\AppData\\Local\\Programs\\Python\\Python312',
'C:\\Users\\lv39\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages']
```

:::

::::

## Search paths {auto-animate=true}

:::: {.columns}

::: {.column width=30% .smaller}

- R: `.libPaths()`
- Python: `sys.path`
- Julia: `DEPOT_PATH` ([Julia docs](https://docs.julialang.org/en/v1/manual/code-loading/))

:::

::: {.column width=70%}

```{.julia code-line-numbers="3-5" .smaller}
julia> DEPOT_PATH
3-element Vector{String}:
"C:\\Users\\lv39\\.julia"
"C:\\Users\\lv39\\.julia\\juliaup\\julia-1.10.0+0.x64.w64.mingw32\\local\\share\\julia"
"C:\\Users\\lv39\\.julia\\juliaup\\julia-1.10.0+0.x64.w64.mingw32\\share\\julia"
```

:::

::::


## "Yes, but what about Stata?"

> We now have the **ingredients** to understand (project) environments in Stata.
Loading

0 comments on commit 4fc689d

Please sign in to comment.