Skip to content

Instantly share code, notes, and snippets.

View JonasMoss's full-sized avatar

Jonas Moss JonasMoss

View GitHub Profile
@JonasMoss
JonasMoss / H.R
Created July 12, 2019 13:54
Define functions inside enclosing environment.
#' Hide non-function variables from function.
#'
#' @param ... Named functions and function definitions.
#' @return Nothing.
H = function(...) {
function_names = names(as.list(substitute((...)))[-1])
function_defs = list(...)
envir = parent.env(parent.frame())
@JonasMoss
JonasMoss / causality_first_meeting.md
Last active August 28, 2019 09:24
Causality Reading Group: Proposed Reading Materials

First Reading

On the Consistency Rule in Causal Inference Axiom, Definition, Assumption, or Theorem? (Pearl, 2010, 4 page) One of the big problems with the causality literature is the terminology and the lack of foundationas for everyone to agree on.(Think about a vector space -- everyone agrees what it is. That's where we want to be.) The consistency rule appears to me to be the corner-stone of an axiomatic development of causality theory.

The following papers are mentioned in the Pearl paper and are a part of the assignment:

  1. The consistency statement in causal inference: a definition or an assumption

  2. Concerning the consistency assumption in causal inference

@JonasMoss
JonasMoss / talent.csv
Created September 22, 2021 10:45
Talent data set.
country points talent
1 Spain 1485 85
2 Germany 1300 76
3 Brazil 1242 48
4 Portugal 1189 16
5 Argentina 1175 35
6 Switzerland 1149 9
7 Uruguay 1147 9
8 Colombia 1137 3
9 Italy 1104 67
@JonasMoss
JonasMoss / bullshit.csv
Created September 23, 2021 14:31
Bullshit
free_market_ideology bullshit_receptivity
1 40 3.1
2 30 2.66666666666667
3 70 3.3
4 10 1.9
5 50 3.56666666666667
6 35 3.93333333333333
7 50 2.03333333333333
8 50 2.53333333333333
9 25 1
@JonasMoss
JonasMoss / exercise.py
Created November 2, 2021 13:05
Exercise function!
from collections import Counter
def f(i, s):
total = np.cumsum([0] + list(Counter(coding(s)).values()))
total = total / total[-1]
values = np.diff(total)
return values[i-1]
coding(data_student['apply'],f
@JonasMoss
JonasMoss / defaults.py
Created November 4, 2021 09:59
Default values in Python for EBA3500.
### Here's some more info about default values!
### Especially when they are difficult to understand.
### An easy example of default values.
def f(x, a = True):
if a:
return (x + 1)
if not a:
return (x + 2)