Statalist


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

st: Re: Help with stata syntax for creating groups (Panel data)


From   Maarten buis <[email protected]>
To   stata list <[email protected]>
Subject   st: Re: Help with stata syntax for creating groups (Panel data)
Date   Thu, 10 Sep 2009 22:18:29 +0000 (GMT)

--- On Thu, 10/9/09, Muhammad Riaz wrote privately:
> I am stuck at a point, I wandered if I can ask for
> your help with stata syntax. 
> I have got a total score for patients over 4 periods
> of time. the graphical display shows that there
> are some patients with scores that
> increase over time, others with scores that decrease, and
> others with scores that remain approximately the
> same.
>  
> I want to create three
> groups:
>  1=subjects with total score
> decreasing over time, 2=subjects with total score decreasing
> over time, 3=subjects with total score remains
> approximately the same over time.

First off, don't sent these type of questions privately, but 
to the Statalist, as is discussed in the Statalist FAQ:
http://www.stata.com/support/faqs/res/statalist.html#private

The conceptually tricky point in your question is to define
"approximately the same", in the example below I defined that
as a non-significant linear trend at the 10% level. 

*--------------- begin example --------------
clear
input id 	period 	tot_score
10011 	1 	3
10011 	2 	3
10011 	3 	2
10011 	4 	1
10022 	1 	4
10022 	2 	3
10022 	3 	4
10022 	4 	7
10031 	1 	1
10031 	2 	2
10031 	3 	2
10031 	4 	6
10032 	1 	6
10032 	2 	7
10032 	3 	4
10032 	4 	5
end

tempfile a
sort id period
save `a', replace

statsby _b[period] _se[period] e(df_r), ///
   clear by(id): reg tot_score period
gen p = 2*ttail(_stat_3, abs(_stat_1/_stat_2))
gen byte neg = _stat_1 < 0 & p < .1
gen byte zero = p>.1
gen byte pos = _stat_1 > 0 & p < .1
keep id neg zero pos
sort id
merge id using `a'
assert _merge == 3
drop _merge
sort id period
list, sepby(id)
*------------------ end example ----------------------
( For more on how to use examples I sent to statalist see:
http://www.maartenbuis.nl/stata/exampleFAQ.html )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------



      

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index