Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Estimating the (possibly negative) intracluster correlation

From   Steve Samuels <>
Subject   Re: st: Estimating the (possibly negative) intracluster correlation
Date   Sun, 5 Sep 2010 22:20:34 -0400

Here's a do-file to estimate a possibly negative ICC; it's based on
the definition of the ICC as the correlation of all pairs of
observations within groups (Cochran, Sampling Techniques, Third Ed,
1977, Wiley page 209)

Steven J. Samuels
18 Cantine's Island
Saugerties NY 12477
Voice: 845-246-0774
Fax:    206-202-4783

**************************CODE BEGINS**************************
sysuse auto, clear
replace rep78=1 in 1

tab rep78
keep if rep78 <3
sort rep78
gen id1 = _n
loneway mpg rep78
keep id1 mpg  rep78
tempfile t1
save `t1'
rename mpg mpgx
rename id1 id2
joinby rep78 using `t1'
sort id1 id2  // use for check
drop if id1 == id2
list id1 id2 if rep78==1  //check
corr mpg mpgx
***************************CODE ENDS***************************

On Sun, Sep 5, 2010 at 8:44 PM, Bert Jung <> wrote:
> Dear Statalisters,
> I am interested in estimating an intracluster correlation, if possible
> conditional on several covariates, that could be negative.  I wondered
> if anyone knows a command or strategy to do this?
> As background: I am estimating a simple OLS -regress- model and find
> that the default (unclustered, not robust) standard errors are
> *higher* than the clustered s.e.  A potential cause is model
> misspecification that can induce negative intracluster correlation, as
> discussed in  I
> hope to diagnose the problem, starting with a closer look at the
> intracluster correlation.  (I will also work on a better
> specification, of course.)
> -loneway- calculates the intraclass correlation as ratio of two
> variances, hence constraining the correlation to be >=0.  I am looking
> for an alternative way that also allows me to control for covariates.
> Thanks in advance for any pointers,
> Bert
> *
> *   For searches and help try:
> *
> *
> *

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index