Simulate an Individual (Augmented) Dickey-Fuller Model
sim_df_mod.Rd
sim_df_mod()
is designed as a helper function, to be used
internally in this package in sadf_test()
. But, you can use it here to
simulate a time series and perform a(n Augmented) Dickey-Fuller test.
Arguments
- x
a numeric vector corresponding to a series to replicate/simulate
- ts_type
a type of time-series to simulate (either 'ndnt', 'dnt', or 'dt')
- df_lags
a numeric vector for the number of lags to calculate for the test.
- classic_df
logical, defaults to FALSE. If FALSE, the function calculates an "Augmented" Dickey-Fuller test on a simulated series with the number of lagged first differences requested in the
df_lags
argument. IfTRUE
, the classic Dickey-Fuller test is executed without the lagged first differences.- wn
logical, defaults to FALSE. If FALSE, generates a random walk of some description for a DF/ADF test. If TRUE, series to be simulated for a DF/ADF test is white noise.
Value
sim_df_mod()
returns the output of a linear model (with class
lm
) that performs a(n Augmented) Dickey-Fuller test on a simulated time
series. This is mostly for internal use, but it might pique the user's
interest to see such a test in action independent of simulated summaries
generated by sadf_test()
.
Details
classic_df = TRUE
suppresses the need to specify df_lags = 0
, but
df_lags
cannot be 0 if classic_df = FALSE
.
This might change in future iterations, but it's worth clarifying the values assigned to the parameters of a drift and trend. The drift is randomly generated from a Rademacher distribution for both the times series with drift and drift-and-trend. The series with a deterministic trend divides the value from the Rademacher distribution by 10. My rationale is largely based on what I've seen other pedagogical guides do, the extent to which they talk about simulating values for these types of random walks.
Examples
set.seed(8675309) # don't want new numbers in documentation every time...
sim_df_mod(rnorm(25), ts_type = 'ndnt', classic_df = TRUE)
#>
#> Call:
#> lm(formula = f_d_x ~ l1_fx - 1)
#>
#> Coefficients:
#> l1_fx
#> -0.01491
#>
sim_df_mod(rnorm(25), ts_type = 'ndnt', df_lags = 2, classic_df = FALSE)
#>
#> Call:
#> lm(formula = d_fx_t ~ l1_fx - 1 + adf_diff_lags_fake)
#>
#> Coefficients:
#> l1_fx adf_diff_lags_fake1 adf_diff_lags_fake2
#> 0.1184 -0.4047 -0.4403
#>