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]
Re: st: Generating (simple) spatial variables (excluding the country of observation)
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Generating (simple) spatial variables (excluding the country of observation)
Date
Thu, 24 Feb 2011 01:46:57 +0000
Here is a recipe:
Total of others = Total of all - Total (value) of this one
Mean of others = Total of others / (Count of all - 1)
The argument is expanded in excruciating detail within an FAQ:
FAQ . . Creating variables recording prop. of the other members of a group
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
4/05 How do I create variables summarizing for each
individual properties of the other members of a
group?
http://www.stata.com/support/faqs/data/members.html
In your case, this looks like (allowing for the possibility of an
unbalanced panel)
bysort year: gen nothers = _N - 1
bysort year : egen total = total(capital)
gen meanothers = (total - capital) / nothers
The first line assumes no missings on -capital-. If there are missings
of capital, you need
bysort year : egen n = count(capital)
bysort year : egen total = total(capital)
gen meanothers = (total - capital) / (n - 1)
and so that's the more general code.
Nick
On Wed, Feb 23, 2011 at 8:49 PM, Waedlich Felix <[email protected]> wrote:
> I have a panel data set with 140 countries over a time period if 28 years and I want to analyze determinants of capital regulation.
>
> I want to estimate to what extent the level of regulation is influenced by the observable levels in specific reference groups (cultural, regional, etc.) Therefore I planned to generate variables based on the average restrictivness in these groups, which I will use as explanatory variable for my regression.
> Practically i have a dependent variable (capital) and several dummy variables which are supposed to serve as a filter to generate specific regulation averages for each country and year. I.e. all European countries like Belgium, France, etc. will look at the same level of restrictivness in 1978.
> Since, I am rather unexperienced with Stata, I could only came up with this egen code:
>
> . bysort year: egen mean_capital=mean(capital)
>
> So it looks like this:
>
> +---------------------------------+
> | mean_capital country year |
> |---------------------------------|
> 1. | 3.848485 UNITED STATES 1978 |
> 2. | 3.825243 UNITED STATES 1979 |
> 3. | 3.847619 UNITED STATES 1980 |
> 4. | 3.839623 UNITED STATES 1981 |
> 29. | 3.848485 CANADA 1978 |
> 30. | 3.825243 CANADA 1979 |
> 31. | 3.847619 CANADA 1980 |
> 32. | 3.839623 CANADA 1981 |
>
> Theoretically, I need to generate this variable excluding the regulation level of the country I am observing. Meaning if there are four countries in one region, each country will only weigh in the level of regulation of the other 3 countries, but not his own regulation level.
>
>
> Does anybody has a clue?
*
* 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/