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: xtmixed with repeated measurements at each time point


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: Re: xtmixed with repeated measurements at each time point
Date   Fri, 27 Jan 2012 12:21:47 +0900

Ricardo Ovaldia wrote:

I have longitudinal data where each patient is tested with two different methods
at 4 discrete time points. We are interested in testing whether the two methods
differ (compare means). Because the observations are conditionally independent
at each time point, I used a pair t-test to test means at each time point.
However, that approach ignores the longitudinal nature of the data, so I was
wandering how I can use -xtmixed- to compare the two methods while taking into
account that each patient is tested twice, once with each method, at each time
point.

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

You can try something like that below.  (I don't have Stata 12 on this machine,
but I believe that the illustration should still work under the new release.)
If you're willing to forgo considering autocorrelation between time points, then
you can test for a method difference using -anova-, too, the advantage there
being that you can get by with a smaller sample size than you can with
-xtmixed-.

I'm not sure that testing for a mean difference is the best way to assess
relative merits of measurement methods, if that's your objective.  The method's
means might be statistically significantly different from each other, but
trivially so from a practical standpoint, as in the example below.  Even if the
means are substantially different, the two measurement methods can still be
considered equally informative if one's values can reliably be expressed as a
simple (say, linear) function of the other's.  There are a lot of other factors
to consider when comparing an established measurement method and a new candidate
replacement method--you might want to look into the pharmaceutics literature for
"analytical method validation".  Although the topic there is laboratory assays
for assuring medicine quality, similar principles apply more broadly to the
technical qualification and practical assessment of measurement methods, in
general.  Also see the help-file for the user-written command -concord- (use
-findit- if it's not already installed on your machine) for entry points into
the measurement-method-comparison literature from another standpoint.

Joseph Coveney

version 11.2

clear *
set more off
set seed `=date("2012-01-26", "YMD")'
set obs 200

generate int patient_nr = _n
generate double patient_u = 25 * rnormal()
generate double session_u = .
tempname beta_time_point beta_method beta_cons
scalar define `beta_cons' = 100
scalar define `beta_time_point' = 100
scalar define `beta_method' = 1.01

forvalues time_point = 1/4 {
	quietly replace session_u = 10 * rnormal()
	forvalues method = 1/2 {
		generate double response`method'`time_point' = ///
			`beta_cons' + ///
			`beta_time_point' * `time_point' + ///
			`beta_method' * `method' + ///
			patient_u + session_u + 2 * rnormal()
	}
}

quietly reshape long response1 response2, i(patient_nr) j(time_point)
quietly reshape long response, i(patient_nr time_point) j(method)

*
* Considering intersession autocorrelation
*
quietly tabulate time_point, generate(time)
xtmixed response i.time_point##i.method || patient_nr: time1 time2 ///
	time3 time4, noconstant covariance(unstructured) reml nolrtest nolog
estimates store Longitudinal
xtmixed response i.time_point##i.method || patient_nr: time1 time2 ///
	time3 time4, noconstant covariance(exchangeable) reml nolrtest nolog
lrtest Longitudinal
// Alternative specification for above
xtmixed response i.time_point##i.method || patient_nr: R.time_point ///
	, covariance(exchangeable) reml nolrtest nolog
// Alternative specification for below
xtmixed response i.time_point##i.method || patient_nr: time1 time2 ///
	time3 time4, covariance(identity) || patient_nr: , reml nolrtest nolog
lrtest Longitudinal

*
* Considering simple interoccasion variability (IOV)
*
xtmixed response i.time_point##i.method || patient_nr: || time_point: ///
	, reml nolrtest nolog
estimates store IOV
xtmixed response i.time_point##i.method || patient_nr: ///
	, reml nolrtest nostderr nolog
lrtest IOV

*
* Considering difference between methods' variability
*
xtmixed response i.time_point##i.method || patient_nr: || time_point: ///
	, residuals(independent, by(method)) reml nolrtest nolog
estimates store Heteroscedastic
xtmixed response i.time_point##i.method || patient_nr: || time_point: ///
	, reml nolrtest nolog
lrtest Heteroscedastic

*
* Fixed-effects interaction term
*
xtmixed response i.time_point##i.method || patient_nr: R.time_point ///
	, covariance(exchangeable) mle nolrtest nostderr level(90) nolog
estimates store Full
xtmixed response i.time_point i.method || patient_nr: R.time_point ///
	, covariance(exchangeable) mle nolrtest nostderr nolog
lrtest Full

*
* Considering overall mean difference between methods
*
estimates restore Full
margins method, post
test 1.method = 2.method
forvalues i = 1/2 {
	display in smcl as text "Method `i': " _continue
	display as result %3.0f _b[`i'.method]
}

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