Skip to content

Instantly share code, notes, and snippets.

@rmcelreath
Last active June 18, 2021 18:39
Show Gist options
  • Select an option

  • Save rmcelreath/3c358c51facce46cf8645df378a01cdb to your computer and use it in GitHub Desktop.

Select an option

Save rmcelreath/3c358c51facce46cf8645df378a01cdb to your computer and use it in GitHub Desktop.
Code examples for RFDT
set.seed(1908)
N <- 200 # number of pairs
U <- rnorm(N) # simulate confounds
# birth order and family sizes
B1 <- rbinom(N,size=1,prob=0.5) # 50% first borns
M <- rnorm( N , 2*B1 + U )
B2 <- rbinom(N,size=1,prob=0.5)
D <- rnorm( N , 2*B2 + U + 0*M ) # change the 0 to turn on causal influence of mom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment