Page 2 of 2

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Tue Dec 03, 2024 10:15 am
by TomDoan
ac_1 wrote: Mon Dec 02, 2024 1:13 pm
TomDoan wrote: Sun Dec 01, 2024 7:35 am If you first difference an equation that doesn't not need it, you induce a moving average term of the form (1-L)eps which will show high negative autocorrelation. (Just take the equation and difference it to see). It won't be as big a problem if the process had a AR root relatively near 1; it should show some negative residual autocorrelation, but it might not be large enough to show in contrast to the usual residual autocorrelation.
Thanks.

1st-differencing y1: linear trend (i.e. a stationary process around a deterministic trend or trend-stationary process) produces a high negative autocorrelation in the residuals at lag 1. Can that not be handled w.r.t. fit and forecasts? TSay(2010) p.588 models linear regression with ARMA errors.
It induces a unit root in the MA part which is not invertible, and breaks most assumptions underlying the handling of ARMA errors. The best remedy for overdifferencing is to not overdifference in the first place.

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Wed Dec 04, 2024 3:16 am
by ac_1
TomDoan wrote: Fri Nov 29, 2024 10:39 am
ac_1 wrote: Fri Nov 29, 2024 1:59 am I have included a TRENDSQ term to the 4th, y4: quadratic trend process and removed the constant.

Code: Select all

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  AR{1}                         0.982196673  0.008053562    121.95805  0.00000000
2.  TREND                        10.036218055  0.018950239    529.60905  0.00000000
3.  TRENDSQ                       0.025009592  0.000032593    767.33484  0.00000000
The AR{1} term is near 1.0, however TREND is "a" and TRENDSQ is "b", why is that?
I think it would help you to figure that out yourself. Solve the recursion that you used to create the data.

Actually, re-instating and re-estimating y4. I have retrieved the parameters.

Code: Select all

Dependent Variable Y4
     Variable            Coeff
***********************************
1.   Constant         10.034877321
2.   Y4{1}             1.000000000
3.   TREND             0.049989299

Thus, y1 to y3 are estimated in levels as I have recently specified, and y4 estimated with BOXJENK(REGRESSORS) and diffs = 1.

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Wed Dec 04, 2024 3:22 am
by ac_1
TomDoan wrote: Mon Dec 02, 2024 2:10 pm My suggestion is that you go back to Nelson and Plosser and read the mathematical background. They go over the difference between trend stationary and difference stationary series (basically what you are simulating here) and how the wrong choice can cause problems (what you are discovering here).

Note that @BJDIFF is not designed to allow for a trend stationary series.
These are constructed series, aim being how best to model them, and also to retrieve the parameters.

I have re-familiarised myself with Nelson and Plosser. Why would I model the 4 constructed series in logs? But if I was to, would I have to log the trend term as-well? Also, there may be strong autocorrelation in the residuals. Furthermore, @BJTRANS the criterion (the higher value is better) suggests NONE, all series.

Regarding @BJDIFF, in addition I use the unit roots tests with CONSTANT, and TREND.

Again, let me know if the estimated fits and forecasts are wrong.

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Wed Dec 04, 2024 7:25 am
by TomDoan
To reiterate: Nelson and Plosser's result was that the typical trending economic series was best described as a difference stationary series when in logs. If you are trying to generate something like that, you would do the simulation and then exp up to get a simulated trending economic series. If you are just interested in the representation of the linear trend itself, you wouldn't need that extra step. If, on the other hand, you are trying to figure out how to handle actual data, you would exp your simulated data and see whether it properly is classified as needing log transformation.

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Thu Dec 05, 2024 1:53 am
by ac_1
Thanks Tom.
TomDoan wrote: Wed Dec 04, 2024 7:25 am To reiterate: Nelson and Plosser's result was that the typical trending economic series was best described as a difference stationary series when in logs.
If you are trying to generate something like that, you would do the simulation and then exp up to get a simulated trending economic series.
If you are just interested in the representation of the linear trend itself, you wouldn't need that extra step.
Yes, I am interested in both.

I can follow the AR(2) example here: https://estima.com/webhelp/topics/simul ... ction.html

And also do something like

Code: Select all

* ARMA(1,1): y(t) = 2.0 + 0.8*y(t-1) + e(t) - 0.9*e(t-1)

set e 1 nburn+nobs = %ran(sigma)

compute c1 = +2.0
compute phi1 = +0.8
compute theta1 = +0.9

set(first=0.0) y 1 nburn+nobs = c1 + phi1*y{1} + e - theta1*e{1}
But how do I know the model produces a Difference Stationary series?

In otherwords, how do I simulate an I(d), d>=1 series, original (mean), and in logs (mean or median) then exp up to get a simulated trending economic series in RATS?
I have seen elsewhere simulating Trend Stationary (mean trend is deterministic) and Difference Stationary (mean trend is stochastic) stationary processes, from sample paths as a plot - the advantage being an idea regarding constant/non-constant variance.


Peter C Philips has the Nelson and Plosser data set http://korora.econ.yale.edu/phillips/. I'd like to replicate their results.

TomDoan wrote: Wed Dec 04, 2024 7:25 am If, on the other hand, you are trying to figure out how to handle actual data, you would exp your simulated data and see whether it properly is classified as needing log transformation.
Yes, I have exp'd y1, y2 and y3, and @BJTRANS works well, the higher the better - all 3 being classified as log t/f's. I cannot exp y4 the quadratic trend, I get huge numbers.

However, there is a problem with y3: stochastic trend

Code: Select all

comp a = 10.0; * constant
comp b = 0.05; * trend
comp phi1 = +0.8; * |phi1|<1

set(first=0.0) stochtrend 1 nburn+nobs = b+1.0*stochtrend{1}+u
set(first=0.0) z 1 nburn+nobs = phi1*z{1}+u
set(first=0.0) y3 1 nburn+nobs = stochtrend + z

linreg(define=eq3lreg) y3 nburn+1 nburn+nobs resids_eq3lreg
# constant y3{1} trend
disp eq3lreg

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  Constant                     0.7276644490 0.3331950424      2.18390  0.02943640
2.  Y3{1}                        0.9421979581 0.0149556923     62.99929  0.00000000
3.  TREND                        0.0036719563 0.0011482076      3.19799  0.00147213


boxjenk(print,ar=||1||,diffs=0,ma=0,REGRESSORS,define=eq3bjreg,MAXL) y3 nburn+1 nburn+nobs resids_eq3bjreg
# constant trend
disp eq3bjreg

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  AR{1}                        0.9426198998 0.0147187934     64.04193  0.00000000
2.  Constant                     9.1138779282 4.6456132996      1.96182  0.05034063
3.  TREND                        0.0680146981 0.0097594203      6.96913  0.00000000
Instead
If phi1 = +0.1, the magnitude of the AR(1) Coeff does not change.
If phi1 = -0.8, the sign of the AR(1) Coeff does not change. Similarly if I increase phi1 to e.g. -0.3.
Why?

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Thu Dec 05, 2024 1:58 am
by ac_1
In enders4p186.rpf, to estimate Figure 4.2: Four Series With Trends I would

(a) rw: boxjenk(ar=0,diffs=1,ma=0)

(b) dr: boxjenk(constant,ar=0,diffs=1,ma=0)

(c) ts:

linreg ts
# constant trend

OR

boxjenk(ar=0,diffs=0,ma=0,GLS) ts
# constant trend

Correct?

How do I estimate (d) rwn ?

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Thu Dec 05, 2024 7:27 am
by TomDoan
I told you how to simulate the trending series back right at the beginning of the thread:

viewtopic.php?p=19506#p19506

Add stationary noise to the first, and you get a trend stationary series; add stationary noise to the second and you get a difference stationary series.
ac_1 wrote: Thu Dec 05, 2024 1:58 am How do I estimate (d) rwn ?
That creates an ARIMA(0,1,1) process where the MA coefficient depends upon the variances of the two noises. (Difference the generated series and you get eps(t)+eta(t)-eta(t-1) where eta is the added noise).

BOXJENK(DIFFS=1,MA=1,NOCONST) rwn
ac_1 wrote: Thu Dec 05, 2024 1:53 am Yes, I have exp'd y1, y2 and y3, and @BJTRANS works well, the higher the better - all 3 being classified as log t/f's. I cannot exp y4 the quadratic trend, I get huge numbers.
That, of course, is the reason that the quadratic trend isn't considered to be a reasonable model---eventually the quadratic term will dominate. However, you should be able to reduce (obviously rather substantially) the coefficient on the quadratic term to get something that is reasonable.

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Thu Dec 05, 2024 10:03 am
by TomDoan
ac_1 wrote: Thu Dec 05, 2024 1:53 am However, there is a problem with y3: stochastic trend

Code: Select all

comp a = 10.0; * constant
comp b = 0.05; * trend
comp phi1 = +0.8; * |phi1|<1

set(first=0.0) stochtrend 1 nburn+nobs = b+1.0*stochtrend{1}+u
set(first=0.0) z 1 nburn+nobs = phi1*z{1}+u
set(first=0.0) y3 1 nburn+nobs = stochtrend + z

linreg(define=eq3lreg) y3 nburn+1 nburn+nobs resids_eq3lreg
# constant y3{1} trend
disp eq3lreg

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  Constant                     0.7276644490 0.3331950424      2.18390  0.02943640
2.  Y3{1}                        0.9421979581 0.0149556923     62.99929  0.00000000
3.  TREND                        0.0036719563 0.0011482076      3.19799  0.00147213


boxjenk(print,ar=||1||,diffs=0,ma=0,REGRESSORS,define=eq3bjreg,MAXL) y3 nburn+1 nburn+nobs resids_eq3bjreg
# constant trend
disp eq3bjreg

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  AR{1}                        0.9426198998 0.0147187934     64.04193  0.00000000
2.  Constant                     9.1138779282 4.6456132996      1.96182  0.05034063
3.  TREND                        0.0680146981 0.0097594203      6.96913  0.00000000
Instead
If phi1 = +0.1, the magnitude of the AR(1) Coeff does not change.
If phi1 = -0.8, the sign of the AR(1) Coeff does not change. Similarly if I increase phi1 to e.g. -0.3.
Why?
Because you are estimating a completely incorrect model. y3 is going to be have ARIMA(1,1,1) model with just a constant not an AR(1) with constant and trend.

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Thu Dec 05, 2024 2:36 pm
by TomDoan
ac_1 wrote: Thu Dec 05, 2024 1:53 am Peter C Philips has the Nelson and Plosser data set http://korora.econ.yale.edu/phillips/. I'd like to replicate their results.
There's a copy of nelsonplosser.rat in the RATS examples directory. (And in a couple of the example programs as well).

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Sat Dec 07, 2024 11:43 am
by ac_1
ac_1 wrote: Thu Dec 05, 2024 1:58 am In enders4p186.rpf, to estimate Figure 4.2: Four Series With Trends I would

(a) rw: boxjenk(ar=0,diffs=1,ma=0)

(b) dr: boxjenk(constant,ar=0,diffs=1,ma=0)

(c) ts:

linreg ts
# constant trend

OR

boxjenk(ar=0,diffs=0,ma=0,GLS) ts
# constant trend

Correct?

How do I estimate (d) rwn ?
Sorry typo, the ts estimations should not have a constant.

TomDoan wrote: Thu Dec 05, 2024 7:27 am
That creates an ARIMA(0,1,1) process where the MA coefficient depends upon the variances of the two noises. (Difference the generated series and you get eps(t)+eta(t)-eta(t-1) where eta is the added noise).

BOXJENK(DIFFS=1,MA=1,NOCONST) rwn
Thanks.

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Sat Dec 07, 2024 12:28 pm
by ac_1
ac_1 wrote: Wed Dec 04, 2024 3:16 am
TomDoan wrote: Fri Nov 29, 2024 10:39 am
ac_1 wrote: Fri Nov 29, 2024 1:59 am I have included a TRENDSQ term to the 4th, y4: quadratic trend process and removed the constant.

Code: Select all

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  AR{1}                         0.982196673  0.008053562    121.95805  0.00000000
2.  TREND                        10.036218055  0.018950239    529.60905  0.00000000
3.  TRENDSQ                       0.025009592  0.000032593    767.33484  0.00000000
The AR{1} term is near 1.0, however TREND is "a" and TRENDSQ is "b", why is that?
I think it would help you to figure that out yourself. Solve the recursion that you used to create the data.

Actually, re-instating and re-estimating y4. I have retrieved the parameters.

Code: Select all

Dependent Variable Y4
     Variable            Coeff
***********************************
1.   Constant         10.034877321
2.   Y4{1}             1.000000000
3.   TREND             0.049989299
Above, I managed to recover the parameters simulating the series as

set(first=0.0) y4 1 nburn+nobs = a + 1.0*y4{1} + b*trend + u


Could I also simulate y4: RWD plus Linear Trend as

set(first=0.0) y1 1 nburn+nobs = a + b*trend + u
set(first=1.0) rw 1 nburn+nobs = 1.0*rw{1} + u
set(first=0.0) y4 1 nburn+nobs = y1 + rw

If so, how to estimate?

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Sat Dec 07, 2024 12:39 pm
by ac_1
For Nelson and Plosser simulation I have

Code: Select all

all 700

seed 123

compute nsteps=200
compute nburn=200
compute nobs=500

set u 1 nburn+nobs = %ran(1.0)
set trend 1 nburn+nobs+nsteps = t

comp a = 10.0; * constant
comp b = 0.05; * trend
comp phi1 = +0.8; * |phi1|<1

set(first=0.0) stochtrend 1 nburn+nobs = b+1.0*stochtrend{1}+u
set(first=0.0) z 1 nburn+nobs = phi1*z{1}+u
set(first=0.0) y3 1 nburn+nobs = stochtrend + z

set(first=0.0) ly3 1 nburn+nobs = log(y3)

boxjenk(print,constant,ar=||1||,diffs=1,ma=||1||,define=eq3_bjd,MAXL) ly3 nburn+1 nburn+nobs resids_eq3_bjd
disp eq3_bjd
Which is just y3 in logs and then exp to get the forecasts. Correct?

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Sat Dec 07, 2024 2:52 pm
by TomDoan
ac_1 wrote: Sat Dec 07, 2024 12:39 pm For Nelson and Plosser simulation I have

Code: Select all

all 700

seed 123

compute nsteps=200
compute nburn=200
compute nobs=500

set u 1 nburn+nobs = %ran(1.0)
set trend 1 nburn+nobs+nsteps = t

comp a = 10.0; * constant
comp b = 0.05; * trend
comp phi1 = +0.8; * |phi1|<1

set(first=0.0) stochtrend 1 nburn+nobs = b+1.0*stochtrend{1}+u
set(first=0.0) z 1 nburn+nobs = phi1*z{1}+u
set(first=0.0) y3 1 nburn+nobs = stochtrend + z

set(first=0.0) ly3 1 nburn+nobs = log(y3)

boxjenk(print,constant,ar=||1||,diffs=1,ma=||1||,define=eq3_bjd,MAXL) ly3 nburn+1 nburn+nobs resids_eq3_bjd
disp eq3_bjd
Which is just y3 in logs and then exp to get the forecasts. Correct?
No. 100% no. First, you're using the same shocks for the two components. You don't want to do that---those should be independent processes.
Second, the difference stationary series is supposed to represent the log of an economic series. You don't take the log of it; you take the exp of it to get something with the behavior of an economic time series.

Re: simulate, estimate and forecast OOS univariate models incorporating a linear trend term

Posted: Sat Dec 07, 2024 5:24 pm
by TomDoan
ac_1 wrote: Sat Dec 07, 2024 12:28 pm Could I also simulate y4: RWD plus Linear Trend as

set(first=0.0) y1 1 nburn+nobs = a + b*trend + u
set(first=1.0) rw 1 nburn+nobs = 1.0*rw{1} + u
set(first=0.0) y4 1 nburn+nobs = y1 + rw

If so, how to estimate?
1. Doesn't RWD mean Random Walk with DRIFT? Where's the drift?
2. You are using the same shock in the two component processes. Don't do that.
3. A trend stationary process + a difference stationary process is a difference stationary process. You can verify that by taking the first difference of the sum of the two and seeing what happens. If you again read carefully through Nelson and Plosser, you will see that taking first differences and seeing what happens is how they look at the processes.