[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: FW: grouping observations and performing cals
Yes, there are (much) easier ways to do this.
Your basic strategy of getting mean and standard
deviation first is I think correct.
I understand that you want disjoint windows.
Your example is of window length 2. (I presume
that it is just a toy example. I would not
put much store by sds of pairs of values.
Also if the sd is zero, your ratio is indeterminate.)
You can coarsen your time variable by
gen T = floor(time/2)
0 and 1 map to 0, 2 and 3 map to 1, etc.
Then it is
egen mean = mean(X), by(T)
egen sd = sd(X), by(T)
gen unstablemeasure = mean/sd
This can be generalised to window lengths
other than 2 and you can offset time
I have some data in the following format
I need to compute y= Mean(X)/SD(X) for different time windows.
-5,-4 would be window 1
-3,-2 would be window 2 etc.
My present solution is this ( example for window 1)
Egen a=mean(X) if time>=-5 & time<=-4 (and so on for all the different
Egen b=sd(x) if if time>=-5 & time<=-4 (and so on for all the different
Is there an easier way to do this???
* For searches and help try: