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

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

From |
Dani Tilley <tilleydani@yahoo.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Difference operator will not calculate the correct difference |

Date |
Sun, 8 Aug 2010 23:04:13 -0700 (PDT) |

The problem is with what you expect it to be. The second difference is not the difference between x and L2.x; it's the difference in the first difference of x. So, d2.age=(age - l1.age) - (l1.age - l2.age). ----- Original Message ---- From: Duha Altindag <daltin2@tigers.lsu.edu> To: statalist@hsphsun2.harvard.edu Sent: Mon, August 9, 2010 12:48:52 AM Subject: st: Difference operator will not calculate the correct difference 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/ * * 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/

**References**:**st: Difference operator will not calculate the correct difference***From:*Duha Altindag <daltin2@tigers.lsu.edu>

- Prev by Date:
**st: re: Contingency tables etc. in Stata and SPSS** - Next by Date:
**st: Stata and SPSS** - Previous by thread:
**st: Difference operator will not calculate the correct difference** - Next by thread:
**st: re: Contingency tables etc. in Stata and SPSS** - Index(es):