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 |
Aaron Kirkman <ak1795mailserv@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Why does this scalar calculation return the wrong value when using time series operators? |

Date |
Tue, 6 Nov 2012 15:25:06 -0600 |

Dear Statalist, I'm performing a simple linear regression on time series data and calculating the t-statistic for coefficients afterwards. However, I noticed that when using time series operators, the t-statistic always calculates to be one, even though the values from the regression are correct. For example, this code: ---------- clear all set seed Xc0114d4971eea6310add269363d61a6d00042c5f local y0 0 set obs 200 quietly { gen y = . gen t = _n tsset t replace y = cond(t == 1, `y0', L.y + rnormal()) regress D.y L.y } di _b[L.y] di _se[L.y] di _b[L.y] / _se[L.y] scalar t = _b[L.y] / _se[L.y] // t = Beta / SE di t ---------- outputs the following: -.02092465 // _b[L.y] .01391362 // _se[L.y] -1.5038971 // _b[L.y] / _se[L.y] 1 // scalar "t" The first three numbers are the correct values from the regression, but the calculation for the t-statistic is incorrect. If I remove the time series operators from the code and instead refer to observations numbers (I would prefer to use time series operators, but just as an example), the resulting t-statistic is correct: ---------- clear all set seed Xc0114d4971eea6310add269363d61a6d00042c5f local y0 0 set obs 200 quietly { gen y = . gen ly = . gen dy = . replace y = cond(_n == 1, `y0', y[_n - 1] + rnormal()) replace ly = y[_n - 1] replace dy = y - ly regress dy ly } di _b[ly] di _se[ly] di _b[ly] / _se[ly] scalar t = _b[ly] / _se[ly] // t = Beta / SE di t ---------- This code outputs the correct t-statistic of -1.5038971 -.02092465 // _b[L.y] .01391362 // _se[L.y] -1.5038971 // _b[L.y] / _se[L.y] -1.5038971 // scalar "t" I read through "[U] 13.5 Accessing coefficients and standard errors" and --help scalar--, but I don't see anything in either of those manuals that would cause the problem. Any ideas? Aaron Kirkman * * 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: Why does this scalar calculation return the wrong value when using time series operators?***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Why does this scalar calculation return the wrong value when using time series operators?***From:*Scott Merryman <scott.merryman@gmail.com>

- Prev by Date:
**st: Calculate product from two dta files** - Next by Date:
**Re: st: RE: getting the nth column name** - Previous by thread:
**st: Calculate product from two dta files** - Next by thread:
**Re: st: Why does this scalar calculation return the wrong value when using time series operators?** - Index(es):