I totally forgot to mention: John Stuart Mill, the progenitor of what we today identify as utilitarianism, was himself tortured mercilessly, by his father John Mill (bffs with Jeremy Bentham) for the “greater good of society”!
Blasting Off Into Causality!
DGPs and the Emergence of Order
Who can guess the state of this process after 10 steps, with 1 person?
10 people? 50? 100? (If they find themselves on the same spot, they stand on each other’s heads)
100 steps? 1000?
The Result: 16 Steps
Code
library(tibble)library(ggplot2)library(ggExtra)library(dplyr)library(tidyr)# From McElreath!gen_histo <-function(reps, num_steps) { support <-c(-1,1) pos <-replicate(reps, sum(sample(support,num_steps,replace=TRUE,prob=c(0.5,0.5))))#print(mean(pos))#print(var(pos)) pos_df <-tibble(x=pos) clt_distr <-function(x) dnorm(x, 0, sqrt(num_steps)) plot <-ggplot(pos_df, aes(x=x)) +geom_histogram(aes(y =after_stat(density)), fill=cbPalette[1], binwidth =2) +stat_function(fun = clt_distr) +theme_dsan("quarter") +theme(title=element_text(size=16)) +labs(title=paste0(reps," Random Walks, ",num_steps," Steps") )return(plot)}gen_walkplot <-function(num_people, num_steps, opacity=0.15) { support <-c(-1, 1)# Unique id for each person pid <-seq(1, num_people) pid_tib <-tibble(pid) pos_df <-tibble() end_df <-tibble() all_steps <-t(replicate(num_people, sample(support, num_steps, replace =TRUE, prob =c(0.5, 0.5)))) csums <-t(apply(all_steps, 1, cumsum)) csums <-cbind(0, csums)# Last col is the ending positions ending_pos <- csums[, dim(csums)[2]] end_tib <-tibble(pid =seq(1, num_people), endpos = ending_pos, x = num_steps)# Now convert to tibble ctib <-as_tibble(csums, name_repair ="none") merged_tib <-bind_cols(pid_tib, ctib) long_tib <- merged_tib %>%pivot_longer(!pid)# Convert name -> step_num long_tib <- long_tib %>%mutate(step_num =strtoi(gsub("V", "", name)) -1)# print(end_df) grid_color <-rgb(0, 0, 0, 0.1)# And plot! walkplot <-ggplot( long_tib,aes(x = step_num,y = value,group = pid,# color=factor(label) ) ) +geom_line(linewidth = g_linesize, alpha = opacity, color = cbPalette[1]) +geom_point(data = end_tib, aes(x = x, y = endpos), alpha =0) +scale_x_continuous(breaks =seq(0, num_steps, num_steps /4)) +scale_y_continuous(breaks =seq(-20, 20, 10)) +theme_dsan("quarter") +theme(legend.position ="none",title =element_text(size =16) ) +theme(panel.grid.major.y =element_line(color = grid_color, linewidth =1, linetype =1) ) +labs(title =paste0(num_people, " Random Walks, ", num_steps, " Steps"),x ="Number of Steps",y ="Position" )}wp1 <-gen_walkplot(500, 16, 0.05)ggMarginal(wp1, margins ="y", type ="histogram", yparams =list(binwidth =1))
The Result: 64 Steps
Code
library(ggExtra)wp2 <-gen_walkplot(5000,64,0.008) +ylim(-30,30)ggMarginal(wp2, margins ="y", type ="histogram", yparams =list(binwidth =1))
“Mathematical/Scientific Modeling”
Thing we observe (poking out of water): data
Hidden but possibly discoverable through deeper investigation (ecosystem under surface): model / DGP
So What’s the Problem?
Non-probabilistic models: High potential for being garbage
tldr: even if SUPER certain, using \(\Pr(\mathcal{H}) = 1-\varepsilon\) with tiny \(\varepsilon\) has literal life-saving advantages(Finetti 1972)
Probabilistic models: Getting there, still looking at “surface”
Of the \(N = 100\) times we observed event \(X\) occurring, event \(Y\) also occurred \(90\) of those times
Causal models: Does \(Y\) happen because of\(X\) happening? For that, need to start modeling what’s happening under the surface making \(X\) and \(Y\)“pop up” together so often
Causal Inference
The Intuitive But Boring Problem of Causal Inference
Jeff’s ABHYSIOWDCI claim: If we care about intervening to reduce social ills, this literally has negative value (Goes up to zero value if you don’t publish it though! 😉)
(Annoying But Hopefully You’ll See the Importance Once We Digest Causal Inference… a standard term in The Sciences)
Complications: Selection
Tldr: Why did this person (unit) end up in the treatment group? Why did this other person (unit) end up in the control group?
Are there systematic differences?
“““Vietnam”“” “““War”“” Draft: Why can’t we just study [men who join the military] versus [men who don’t], and take the difference as a causal estimate?
The Solution: Matching
(W02 we looked at propensity score matching… kind of the Naïve Bayes of matching)
Controlled experiment: we can ensure (since we have control over the assignment mechanism) the only systematic difference between \(C\) and \(T\) is: \(T\) received treatment, \(C\) did not
In an observational study, we’re “too late”! Thus, we no longer refer to assignment but to selection
Our job is to reverse engineer the selection mechanism, then correct for its non-randomness. Spoiler: “transform” observational \(\rightarrow\) experimental via weighting.
That’s the gold at end of rainbow. The rainbow itself is…
\(X\) and \(Y\) are diseases which occur independently, no interrelationship, with probability \(1/3\)
Either\(X\)or\(Y\) sufficient for admission to hospital, \(Z\)
We have: \(X \rightarrow Z \leftarrow Y\) [🚨 Collider alert!]
What’s the Issue?
If we only have data on patients (\(Z = 1\)), observing \(X = 1\) lowers \(\Pr(Y = 1)\), despite the fact that \(X \perp Y\)!
\(X \perp Y\), but \((X \not\perp Y) \mid Z\)
The moral: controlling for stuff does not necessarily solve problem of causal inference, and can actually make it worse (inducing correlations where they don’t actually exist) 😭
The Causal Trinity: When Controlling for Stuff Helps
Fork: Controlling helps!
Confounder: Controlling helps!
Collider: Controlling makes things worse 😞
The Final Diagrammatic Boss: SWIGs
Single World Intervention Graphs
References
Finetti, Bruno de. 1972. Probability, Induction and Statistics: The Art of Guessing. J. Wiley.