Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: Differencing problem |

Date |
Thu, 27 Jun 2013 15:49:23 +0100 |

As they say in London, but for different reasons, Mind the gap! As far as d. is concerned, you have no value for 1999, so it can only shrug its shoulders and return missing. Set delta to 10 years, and everyone will be happy. Nick njcoxstata@gmail.com On 27 June 2013 15:31, Michael Betz <betz.40@buckeyemail.osu.edu> wrote: > Sure. Here it is: > > . xtset cbsa year > panel variable: cbsa (strongly balanced) > time variable: year, 1990 to 2000, but with gaps > delta: 1 unit > > The only two years in the data are 1990 and 2000. > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Jeph Herrin > Sent: Thursday, June 27, 2013 8:59 AM > To: statalist@hsphsun2.harvard.edu > Subject: Re: st: Differencing problem > > Can you share the output of -xtset- ? > > > On 6/27/2013 8:09 AM, Michael Betz wrote: >> Right. Whenever I've done this before that is exactly what I would get too. Now the value of the difference for the second observation is missing in each instance. Not sure what is going on. >> >> -----Original Message----- >> From: owner-statalist@hsphsun2.harvard.edu >> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox >> Sent: Thursday, June 27, 2013 4:26 AM >> To: statalist@hsphsun2.harvard.edu >> Subject: Re: st: Differencing problem >> >> Nothing obviously wrong there. >> >> With panels length 2 what I expect is what I get, just one value of the difference for the second observation. >> >> . set obs 10 >> obs was 0, now 10 >> >> . gen y = runiform() >> >> . egen id = seq(), block(2) >> >> . egen t = seq(), to(2) >> >> . xtset id t >> panel variable: id (strongly balanced) >> time variable: t, 1 to 2 >> delta: 1 unit >> >> . gen dy = d.y >> (5 missing values generated) >> >> . l >> >> +-------------------------------+ >> | y id t dy | >> |-------------------------------| >> 1. | .1369841 1 1 . | >> 2. | .6432207 1 2 .5062366 | >> 3. | .5578017 2 1 . | >> 4. | .6047949 2 2 .0469932 | >> 5. | .684176 3 1 . | >> |-------------------------------| >> 6. | .1086679 3 2 -.575508 | >> 7. | .6184582 4 1 . | >> 8. | .0610638 4 2 -.5573944 | >> 9. | .5552388 5 1 . | >> 10. | .8714491 5 2 .3162102 | >> +-------------------------------+ Nick njcoxstata@gmail.com >> >> >> On 27 June 2013 02:56, Michael Betz <betz.40@buckeyemail.osu.edu> wrote: >>> . d college_ >>> >>> storage display value >>> variable name type format label variable label >>> ------------------------------------------------------------------------------------------------------------------------------------ >>> college_ float %9.0g >>> >>> . su college_ >>> >>> Variable | Obs Mean Std. Dev. Min Max >>> -------------+------------------------------------------------------- >>> -------------+- >>> college_ | 716 94970.41 257294.9 3479 3707827 >>> >>> -----Original Message----- >>> From: owner-statalist@hsphsun2.harvard.edu >>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox >>> Sent: Wednesday, June 26, 2013 6:53 PM >>> To: statalist@hsphsun2.harvard.edu >>> Subject: Re: st: Differencing problem >>> >>> I would bet No. Show us the results of >>> >>> d var >>> su var >>> >>> Nick >>> njcoxstata@gmail.com >>> >>> On 26 June 2013 23:38, Michael Betz <betz.40@buckeyemail.osu.edu> wrote: >>> >>>> The code you sent works fine. I am using -xtset- to define the panel data. Will that make a difference? >>> >>> Sergiy Radyakin >>> >>>> See if this works. The problem may be with the time variable. Sergiy >>>> >>>> sysuse auto,clear >>>> generate t=_n >>>> tsset t >>>> generate x=d.mpg >>>> list mpg x >>> >>> On Wed, Jun 26, 2013 at 4:20 PM, Michael Betz <betz.40@buckeyemail.osu.edu> wrote: >>> >>>>> I am trying to use the "d." operator to get differenced >>>>> observations but am having some trouble. When I try to calculate >>>>> differenced observations using >>>>> >>>>> gen newvar=d.(var) >>>>> >>>>> Stata returns each observation as missing. My data has observations for each variable in each of two time periods and variation exists over the two time periods. I've used the "d." before without problems so I'm not sure what I'm missing here. Any help is appreciated. >>> >>> * >>> * 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/ >>> >>> >>> >>> * >>> * 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/ >> >> * >> * 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/ >> >> >> >> * >> * 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/ >> >> > * > * 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/ > > > > * > * 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/ * * 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/

**Follow-Ups**:**RE: st: Differencing problem***From:*Michael Betz <betz.40@buckeyemail.osu.edu>

**References**:**st: Differencing problem***From:*Michael Betz <betz.40@buckeyemail.osu.edu>

**Re: st: Differencing problem***From:*Sergiy Radyakin <serjradyakin@gmail.com>

**RE: st: Differencing problem***From:*Michael Betz <betz.40@buckeyemail.osu.edu>

**Re: st: Differencing problem***From:*Nick Cox <njcoxstata@gmail.com>

**RE: st: Differencing problem***From:*Michael Betz <betz.40@buckeyemail.osu.edu>

**Re: st: Differencing problem***From:*Nick Cox <njcoxstata@gmail.com>

**RE: st: Differencing problem***From:*Michael Betz <betz.40@buckeyemail.osu.edu>

**Re: st: Differencing problem***From:*Jeph Herrin <stata@spandrel.net>

**RE: st: Differencing problem***From:*Michael Betz <betz.40@buckeyemail.osu.edu>

- Prev by Date:
**st: Re: How to delete studentized residuals with absolute values greater than or equal to two after conducting areg procedure?** - Next by Date:
**re: Re: st: Using AIPW for missing data purposes in RCTs?** - Previous by thread:
**RE: st: Differencing problem** - Next by thread:
**RE: st: Differencing problem** - Index(es):