Skip to content

Instantly share code, notes, and snippets.

@bsaul
bsaul / perez_simulation
Created July 8, 2015 18:58
An example of the simcausal package to recreate a part of the simulation in Perez-Heydrich et al 2014
library(simcausal)
#### Custom Distribution Functions ####
rnorm_trunc <- function(n, mean, sd, minval = 0)
{
out <- rnorm(n = n, mean = mean, sd = sd)
minval <- minval[1]
out[out < minval] <- minval
out
}