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: Accumulated mean and standard deviation
From
Pedro Nakashima <[email protected]>
To
[email protected]
Subject
st: Accumulated mean and standard deviation
Date
Sun, 8 Jan 2012 13:50:07 -0200
Hi everybody
I need to replicate the following data:
clear*
input x mean sd
2 2 .
4 3 1.4142
1 2.33 1.5275
3 2.55 1.2909
end
The variables mean and sd are like a mix of sum() and egen functions.
For the variable "mean", in each observation j, its entry is the mean
of the values of the variable "x" from observation 1 up to observation
j.
For example:
2 is the mean of 2
3 is the mean of 4 and 2
2.33 is the mean of 1, 4 and 2
2.55 is the mean of 3, 1, 4 and 2
The same is true for the variable sd, but here we consider the
standard deviation.
Does anyone know how to solve this problem?
Many thanks,
Pedro Nakashima.
*
* 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/