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: RE: Variable Estimation
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: Variable Estimation
Date
Sun, 7 Nov 2010 17:13:06 +0000
This is difficult to follow.
For example, where does the r(n) you refer to come from?
You seem to be trying to put the mean into a variable, but what you will have in -r_m- is itself a variable, the mean so far, not in general the overall mean. Also, your calculation assumes no missing values.
I suggest you read the documentation for -summarize- and -egen-.
Nick
[email protected]
Léon Bueckins
I try to estimate the following variable, basing upon this equation: http://cl.ly/34Px
But somehow I can't get it to work properly, so I may need some help. The problem is that N is different for each t.
*get number of groups per t
bysort igroup : g trun =_n
local nGroups =r(n)
*get mean return per t = r_m,t
g r_m = (sum(return))/_n
*get csad
g csad = (abs(return - r_m))/`nGroups'
*
* 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/