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: calculation of area under curve with stata
From
"Joseph Coveney" <[email protected]>
To
<[email protected]>
Subject
st: Re: calculation of area under curve with stata
Date
Mon, 14 Oct 2013 19:01:52 +0900
Elmir Omerovic wrote:
I am analyzing the blood pressure (BP) levels from the three different
groups of animals. BP was measured repeatedly in every animal at 10
different time points within 90 minutes from the start of the experiment.
The animals were exposed to 3 different drugs (each group n=8).
I understand that one way to compare the effect of the drugs on blood
pressure within the whole experimental period would be to calculate the area
under the curve and to use this value in a linear mixed model.
I would be very grateful if someone could help me with step-by-step
instructions how to calculate AUC in stata.
--------------------------------------------------------------------------------
You'd probably want to use -integ-, and so you can take a look at the help file
and entry in the user's manual for that command. If your first observation is a
pretreatment (baseline) value, then you could consider subtracting it from the
succeeding measurements and integrating the change scores, or you could use the
first value as a covariate in the model and integrate only posttreatment
measurements.
After integration, you'll have only a single value for each animal, and so you
won't be using a linear mixed model. (I've seen this advocated as a way to
avoid mixed models.)
Joseph Coveney
. clear *
. set more off
. set seed `=date("2013-10-14", "YMD")'
. quietly set obs `=3 * 8'
. generate grp = mod(_n, 3)
. generate double u_i = rnormal()
. generate byte pid = _n
. forvalues i = 0/9 {
2. generate double mbp`i' = 100 - ///
> grp * (5 - abs(5 - `i')) / 2 + ///
> 5 * rnormal()
3. }
. quietly reshape long mbp, i(pid) j(tim)
.
. *
. * Begin here
. *
. sort pid tim
. quietly generate double ibp = .
. tempvar tmpvar0
. quietly levelsof pid, local(pids)
. foreach pid of local pids {
2. quietly integ mbp tim if pid == `pid', generate(`tmpvar0')
3. quietly replace ibp = `tmpvar0' if pid == `pid'
4. drop `tmpvar0'
5. }
.
. // list grp pid tim mpb ibp, noobs sepby(pid)
. quietly by pid: keep if _n == _N
. anova ibp grp
Number of obs = 24 R-squared = 0.2714
Root MSE = 16.3467 Adj R-squared = 0.2020
Source | Partial SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 2090.0102 2 1045.0051 3.91 0.0360
|
grp | 2090.0102 2 1045.0051 3.91 0.0360
|
Residual | 5611.47898 21 267.213285
-----------+----------------------------------------------------
Total | 7701.48918 23 334.847356
.
. exit
end of do-file
*
* 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/