Thanks for your help Scott,
This is sort of what I was looking for, but rather than calculating the
predicted values for missing data, I'm trying to use the available data
to measure the proportion of each individuals observation time (each
person has a variable number of observations and a variable total period
(calendar days) of observation) that their blood pressures were above a
set threshold.
Put another way, if time is on the X axis, Systolic BP on the Y axis, I
can easily draw a graph with connected BP's over time. Now if I draw a
horizontal line at say 140 on the y axis, how do I calculate the
proportion of the total period of observation that blood pressures are
above the threshold value.
Thanks again
AO
>>> [email protected] 04/25/07 9:52 PM >>>
I don't completely follow this, but if you want the predicted values for
each pt_id you can use -levelsof- and -foreach- to loop through the
groups.
Note: you have repeated time values for pt_id =2, 01 Aug 06.
Perhaps this will help:
clear
input pt_id str9 appt_date str9 appt_status bp_systolic
1 "21 Apr 05" "No Show" .
1 "07 Jun 05" "Completed" 140
1 "11 Jan 06" "Completed" 150
1 "16 Feb 06" "Completed" 150
1 "30 Mar 06" "Canceled" .
1 "02 May 06" "Canceled" .
1 "09 May 06" "Completed" 138
1 "11 Jul 06" "Completed" 142
1 "19 Sep 06" "Completed" 150
2 "30 May 06" "No Show" .
2 "11 Jul 06" "Completed" 176
2 "25 Jul 06" "Completed" 121
2 "01 Aug 06" "Canceled" .
2 "01 Aug 06" "Completed" 101
2 "15 Aug 06" "Completed" 118
2 "22 Aug 06" "Canceled" .
2 "12 Sep 06" "Completed" 136
2 "14 Nov 06" "Completed" 137
2 "16 Jan 07" "Completed" 113
2 "06 Feb 07" "No Show" .
2 "03 May 06" "Canceled" .
2 "25 Jul 06" "Canceled" .
2 "01 Aug 06" "Canceled" .
2 "07 Feb 07" "Canceled" .
end
gen date = date(appt_d, "dm20y")
format date %d
sort pt date appt_s
by pt (date): drop if date == date[_n+1]
tsset pt date
qui {
gen expect_bp = .
levelsof pt, local(levels)
foreach l of local levels {
reg bp date if pt == `l'
predict foo if pt == `l', xb
replace expect = foo if pt == `l'
drop foo
}
}
mark tag if expect>140
l, sepby(pt) ab(20)
Scott
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Andrew O'Connor DO
> Sent: Wednesday, April 25, 2007 7:32 AM
> To: [email protected]
> Subject: st: Using Stata to calculate proportion of observation time
above
> a threshold value i.e. "time in range"
>
> I'm hoping someone can help me with a data problem (Nik sorry I
emailed
> you directly rather than putting on the list).
>
> A person I work with was able to calculate this in SAS and I'm
hopefully
> able to do the same in STATA. I'm trying to use stata to calculate a
> time in range for blood pressure data
> here is what my data looks like
> ------------------------------
> -----------------------------------------------------------------
> Pt_ID Appt_date appt_status bp_systolic
> 1 21 Apr 05 No Show
> 1 07 Jun 05 Completed 140
> 1 11 Jan 06 Completed 150
> 1 16 Feb 06 Completed 150
> 1 30 Mar 06 Canceled
> 1 02 May 06 Canceled
> 1 09 May 06 Completed 138
> 1 11 Jul 06 Completed 142
> 1 19 Sep 06 Completed 150
> 2 30 May 06 No Show
> 2 11 Jul 06 Completed 176
> 2 25 Jul 06 Completed 121
> 2 01 Aug 06 Canceled
> 2 01 Aug 06 Completed 101
> 2 15 Aug 06 Completed 118
> 2 22 Aug 06 Canceled
> 2 12 Sep 06 Completed 136
> 2 14 Nov 06 Completed 137
> 2 16 Jan 07 Completed 113
> 2 06 Feb 07 No Show
> 2 03 May 06 Canceled
> 2 25 Jul 06 Canceled
> 2 01 Aug 06 Canceled
> 2 07 Feb 07 Canceled
>
--------------------------------------------------------------------------
> -----------------------------
> Basically I assume a linear slope (interpolated) between successive
> dates, set a threshold, then ask STATA to calculate the proportion of
> total observation time that the curve was above my threshold.
>
> I think this falls under the cross sectional time series definition.
> Basically what I'm trying to do is each individual (where iis Pt_ID)
has
> a unique observation time (tis Appt_date) and a set of observed
systolic
> blood pressures (bp_systolic). There are no set observation times,
this
> is observational data. For each time, I assume a linear slope of
blood
> pressure change to the next observation time. I need to calculate the
> area that the slope measure predicts blood pressure over my threshold
> (say 140 for example). Slopes can be positive or negative or flat.
> Each individual has a variable number of observations, they are not
> equally spaced, and missing data is a possibility.
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
The MetroHealth System: Saving lives in Northeast Ohio for 170
years as the region's leader in critical care, community health
and rehabilitation. Visit us at http://www.MetroHealth.org for
a complete list of services, health care providers, and
locations.
This email and all attachments that may have been included are
intended only for the use of the party to whom/which the email
is addressed and may contain information that is privileged,
confidential, or exempt from disclosure under applicable law.
If you are not the addressee or the employee or agent of the
intended recipient, you are hereby notified that you are
strictly prohibited from printing, storing, disseminating,
distributing, or copying this communication. If you have
received this notification in error, please contact the
Director of Risk/Privacy Management at (216)778-5728. For a copy
of our Notice of Privacy Practices, please visit:
http://www.metrohealth.org/general/privacy.asp
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/