Bookmark and Share

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]

st: Difference operator will not calculate the correct difference


From   Duha Altindag <daltin2@tigers.lsu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Difference operator will not calculate the correct difference
Date   Sun, 8 Aug 2010 23:48:52 -0500

Greetings,
I thought the difference operator, D, worked like the following:
dn.x = x(t)-x(t-n)
n is an integer.
However, Stata is getting me something different, I couldn't figure out what.
Please, run the following to replicate the problem:

********begin*********
clear
use http://www.stata-press.com/data/r11/nlswork.dta
xtset  idcode year
g d2_age=age-l2.age
list  idcode year age l2.age d2_age d2.age ,noobs
*********end***********

And compare d2_age and D2.age columns.

------------------------------------------+
  |                        L2.            D2.|
  | idcode   year   age   age   d2_age   age |
  |------------------------------------------|
  |      1     70    18     .        .     . |
  |      1     71    19     .        .     . |
  |      1     72    20    18        2     0 |
  |      1     73    21    19        2     0 |
  |      1     75    23    21        2     . |
  |------------------------------------------|
  |      1     77    25    23        2     . |
  |      1     78    26     .        .     . |
  |      1     80    28    26        2     . |
  |      1     83    31     .        .     . |
  |      1     85    33    31        2     . |
  |------------------------------------------|
  |      1     87    35    33        2     . |
  |      1     88    37     .        .     . |
  |      2     71    19     .        .     . |
  |      2     72    20     .        .     . |
  |      2     73    21    19        2     0 |
  |------------------------------------------|

Am I missing something?
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index