Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Georgia Ntani <gn@mrc.soton.ac.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Generating correlated binary data for given ICC |

Date |
Fri, 30 Nov 2012 10:18:40 +0000 |

Dear Statalisters

/* Set up 10 clusters with 30 obs per cluster */ set obs 300 gen cluster=1 if _n<=30 forvalues i=2(1)10 { replace cluster=`i' if _n<=`i'*30 & cluster==. }

gen x1=1 if cluster<=5 replace x1=0 if x1==.

generate x2 = invnorm(uniform())

preserve

di sqrt(0.01*_pi^2)/0.97 set seed 54325821 clear all corr2data u01 u02 u03 u04 u05 u06 u07 u08 u09 u010, n(30) /// means(0 0 0 0 0 0 0 0 0 0) sds(.319 .319 .319 /// .319 .319 .319 .319 .319 .319 .319) gen sn=_n reshape long u0 , i(sn) j(cluster) drop sn sort cluster u0 save randomerror.dta, replace restore sort cluster merge cluster using randomerror drop _merge /* Probability of the outcome from the random effects logistic model */ gen prob=exp(x1*0.47+x2*0.3665+u0)/(1+exp(x1*0.47+x2*0.3665+u0)) /* Binary outcome from the Bernoulli distribution with probability prob */ gen u=runiform() gen y = (u > prob)

xtlogit y i.x1 x2, i(cluster) quad(30) or

Any help on this would be greatly appreciated. Many thanks Georgia * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**Re: st: question simultaneous probit equations** - Next by Date:
**Re: st: question simultaneous probit equations** - Previous by thread:
**st: smooth quntile lines in graph** - Next by thread:
**st: Problems running spost9_ado on Stata 10 with _ms_omit_info** - Index(es):