Skip to content

Instantly share code, notes, and snippets.

@puterleat
Created November 18, 2015 21:43
Show Gist options
  • Save puterleat/2f831bd499cb8ad7f26f to your computer and use it in GitHub Desktop.
Save puterleat/2f831bd499cb8ad7f26f to your computer and use it in GitHub Desktop.
clear all
set seed 123
* recruit subjects (if only this easy...)
set obs 2000
* assign to groups
gen mbct = mod(_n, 2)
* depression baseline score
gen d0 = rnormal(0,1)
* generate probability of relapse note - no interaction term here
gen p = max(min(.5*d0 + .3*mbct, .99), 0.01)
gen y = rbinomial(1,p)
summ y
* ns interaction term in the logistic regression
logistic y mbct##c.d0
* but get ES estimates in probability domainfo 1 SD above and below mean baseline
margins, dydx(mbct) at(d0=(-1(1)1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment