[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Linear regression for individual subjects
I have a dataset that contains pain scores for people with heel pain. We
measured heel pain at 0, 2, 4, 6, and 12 weeks post-initiation of
treatment for heel pain. My data is organized such that I have six
variables: ID, time (which has the values 0, 2, 4, 6, and 12), and the
four pain scores (V1, V2, V3, and V4). What I am trying to do is to fit
a line for each pain score for each ID over time (i.e. pain score vs.
time). However, I am not sure how to do this. I suspect this involves
writing a do file, which may or may not be a problem for me. The problem
I have is that because I need a line to be fit (i.e. a beta 0
(intercept) and a beta 1 (slope)) for each individual, I need to iterate
a command for each observation, namely: regress v1 time if obs==x, where
x is the observation number. How does iteration work in Stata? Is there
a for loop equivalent?
* For searches and help try: