From | David Airey <[email protected]> |
To | [email protected] |
Subject | st: intraclass correlations |
Date | Thu, 19 Feb 2004 10:31:29 -0600 |
Here May has picked up MSE from the test of A. Should she not have picked up MSE immediately after the anova command via the ereturn list?
OK, now for two random factors. For these formulas I must turn to the
comprehensive experimental design text by Winer et. al. "Statistical
Principles of Experimental Design" (page 413). The formula is what you
would expect it to be: ICC=variance of A/(total variance). So again, we
count the number of repetitions, and this time the number of levels of
each factor, compute the variance components, and then ICC.
This time I am going to generate my own balanced dataset. Again, if your
design is not balanced, you just have to work harder to get the variance
components (the formulas for this are in Winer).
*----two random factors--------------*
*--- generate balanced data
clear
set obs 36
generate A=int(_n/6+1)
replace A=1 if A==7
table A
bysort A: generate B=int(_n/2+1)
replace B=1 if B==4
generate response=uniform()
*----------------
local depvar="response"
local A="A"
local B="B"
table `A' `B'
local N=r(N)
display `N'
egen tag=tag(`A')
egen sum=sum(tag)
local p= sum[1]
display `p'
drop sum tag
egen tag=tag(`B')
egen sum=sum(tag)
local q= sum[1]
display `q'
drop sum tag
local n=`N'/(`p'*`q')
display `n'
anova `depvar' `A' `B' `A'*`B'
test `A'
local MSA=r(ss)/r(df)
display `MSA'
local MSE=r(rss)/r(df_r)
display `MSE'
test `B'Secondly, I came across a more general formula for the intraclass correlation in a text by Kirk:
local MSB=r(ss)/r(df)
display `MSB'
test `A'*`B'
local MSAB=r(ss)/r(df)
display `MSAB'
local sigA=(`MSA'-`MSAB')/(`n'*`q')
local sigB=(`MSB'-`MSAB')/(`n'*`p')
local sigAB=(`MSAB'-`MSE')/`n'
local ICC=(`sigA')/(`sigA'+`sigB'+`sigAB'+`MSE')
display `ICC'
*---------------------
Notice, we have to work a bit harder to get the mean squares for each of
the factors this time, since they are not in the saved results after
-anova-. But, that is where -test- comes in handy, because they are in
the results after -test-.
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |