Bookmark and Share

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: calculate the standard deviation for a list of lagged values


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: calculate the standard deviation for a list of lagged values
Date   Wed, 15 Jan 2014 10:59:02 +0000

<>

The help for -egen- is explicit:

"Explicit subscripting (using _N and _n), which is commonly used with
generate, should not be used with egen"

-mvsumm- (SSC) should help. You need to -tsset- or -xtset- your data
first. For that you need a numeric panel identifier.

By the way, note that -egen-'s -std()- function does not, in any
event, calculate the standard deviation. That is what -sd()- does.

Nick
[email protected]

On 15 January 2014 03:37, Larry Sen <[email protected]> wrote:

> I have a dataset about the firm's sales values in each year. The
> structure of my dataset looks like this:
>
> YEAR    FIRM_ID    SALES
> 1975        01                100
> 1976        01                200
> 1977        01                120
> 1978        01                130
> 1977        02                130
> 1978        02                150
> 1979        02                160
> 1980        02                180
> 1972        03                110
> 1973        03                130
> 1974        03                120
> 1975        03                190
>
>
> For each observation, I want to calculate the stand deviation of the
> sales using the previous ten years sales number. How can I do that?
>
> I tried to use by firm_id: eegen sales_sd=std(sales) in[_n-11]/[_n-1]
>
> But its not working :(.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index