Bookmark and Share

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


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

st: Re: Correlation of repeated baseline measures in sampsi


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: Re: Correlation of repeated baseline measures in sampsi
Date   Thu, 24 Mar 2011 13:14:36 +0900

Helen Connolly wrote:

I'm using the sampsi command to calculate sample size for a two-sample
study with 12 monthly baseline measurements and 12 monthly follow-up
measurements.  I have data from a previous study and can calculate mean
and standard deviations for both samples.

My question is, how do I calculate correlation of baseline measurements
(r0), correlation of follow-up measurements (r1), and correlation
between baseline and follow-up measurements (r01)?  These require a
single measure (not a covariance matrix).  In all the references I have
seen, there are statements like "correlation of baseline measurements
calculated from previous study", but I see no reference as to how this
is done.  Can someone please help?

--------------------------------------------------------------------------------

You can estimate the three correlation coefficients using -xtmixed-, applying 
the same model set-up to your previous study's data that you'll be using for the
study whose sample-size requirements you're trying to estimate.  I believe that
it would look something like that below, but you'll want to verify its 
correctness.

You might want to forgo -sampsi- in favor of simulation for your sample-size
estimation.  It will allow greater flexibility in your covariance assumptions, 
such as entertaining the possibility of longitudinal structure.

Al Feiveson has written about using simulation in power analysis with Stata,
including an FAQ, "How can I use Stata to calculate power by simulation?", 
www.stata.com/support/faqs/stat/power.html and a journal article, "Power by 
simulation", www.stata-journal.com/article.html?article=st0010 .

Joseph Coveney

version 11.1

clear *
set more off

*
* Create fictional dataset with known parameters
*
tempname Pre Post PrePost C
// r0 is 0.75
matrix define `Pre' = J(12, 12, 0.75) + I(12) * 0.25
// r1 is 0.5
matrix define `Post' = J(12, 12, 0.50) + I(12) * 0.50
// r01 is 0.25
matrix define `PrePost' = J(12, 12, 0.25)
matrix define `C' = (`Pre', `PrePost' \ `PrePost', `Post')
drawnorm double(scorePre1-scorePre12 scorePost1-scorePost12), ///
    corr(`C') n(500) seed(`=date("2011-03-01", "YMD")')

*
* pid is patient ID, treatment is treatment-group indicator,
* period indicates pretreatment versus posttreatment
* (a.k.a., baseline versus follow-up),
* month is month-within-period,
* score is response variable (a.k.a., measurement)
*
generate int pid = _n
generate byte treatment = _n > _N / 2
quietly reshape long scorePre scorePost, i(pid) j(month)
quietly reshape long score, i(pid month) j(PrePost) string
label define PrePost 0 Pre 1 Post
encode PrePost, generate(period) label(PrePost) noextend

*
* Fit hierarchical model to data
*
xtmixed score i.treatment##i.month || pid: || period: , ///
    residuals(independent, by(period)) nolrtest variance nolog

*
* Estimate r0, r1 and r01 from the data
*
// Scouting for names
matrix list e(b)

// Recover variance components
scalar define sigma2_pid =  exp(_b[lns1_1_1:_cons])^2
scalar define sigma2_period = exp(_b[lns2_1_1:_cons])^2
scalar define sigma2_ePost = exp(_b[lnsig_e:_cons] + _b[r_lns2ose:_cons])^2
scalar define sigma2_ePre = exp(_b[lnsig_e:_cons])^2

/* Construct covariance matrixes and solve for correlation coefficients */

// Pretrreatment correlation
scalar define sigma2_11 = sigma2_pid + sigma2_period + sigma2_ePre
scalar define sigma2_12 = sigma2_pid + sigma2_period
matrix define block_Pre = (sigma2_11, sigma2_12 \ sigma2_12, sigma2_11)
matrix define R0 = corr(block_Pre)
matrix list R0

// Posttreatment correlation
scalar define sigma2_11 = sigma2_pid + sigma2_period + sigma2_ePost
matrix define block_Post = (sigma2_11, sigma2_12 \ sigma2_12, sigma2_11)
matrix define R1 = corr(block_Post)
matrix list R1

// Pretreatment-posttreatment correlation
scalar define sigma2_11 = sigma2_pid + sigma2_period + sigma2_ePre
scalar define sigma2_22 = sigma2_pid + sigma2_period + sigma2_ePost
scalar define sigma2_12 = sigma2_pid
matrix define block_PrePost = (sigma2_11, sigma2_12 \ sigma2_12, sigma2_22)
matrix define R01 = corr(block_PrePost)
matrix list R01

exit


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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