R Under development (unstable) (2024-10-26 r87273 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(tsDyn) > > mod.lstar <- lstar(log10(lynx), m=2, mTh=c(0,1), control=list(maxit=3000)) Using maximum autoregressive order for low regime: mL = 2 Using maximum autoregressive order for high regime: mH = 2 Performing grid search for starting values... Starting values fixed: gamma = 11.15385 , th = 3.337486 ; SSE = 4.337664 Optimization algorithm converged Optimized values fixed for regime 2 : gamma = 11.15383 , th = 3.339199 ; SSE = 4.337643 > mod.lstar Non linear autoregressive model LSTAR model Coefficients: Low regime: const.L phiL.1 phiL.2 0.4891014 1.2465399 -0.3664328 High regime: const.H phiH.1 phiH.2 -1.0240758 0.4232669 -0.2546088 Smoothing parameter: gamma = 11.15 Threshold Variable: Z(t) = + (0) X(t) + (1) X(t-1) Value: 3.339 > deviance(mod.lstar) [,1] [1,] 4.337643 > c(AIC(mod.lstar),BIC(mod.lstar)) [1] -356.6509 -334.7613 > > mod.lstar2 <- lstar(log10(lynx), m=1, control=list(maxit=3000)) Using maximum autoregressive order for low regime: mL = 1 Using maximum autoregressive order for high regime: mH = 1 Using default threshold variable: thDelay=0 Performing grid search for starting values... Starting values fixed: gamma = 100 , th = 3.23744 ; SSE = 12.59824 Grid search selected lower/upper bound gamma (was: 1 100 ]). Might try to widen bound with arg: 'starting.control=list(gammaInt=c(1,200))' Optimization algorithm converged Optimized values fixed for regime 2 : gamma = 100.0031 , th = 3.235652 ; SSE = 12.59746 > mod.lstar2 Non linear autoregressive model LSTAR model Coefficients: Low regime: const.L phiL.1 0.2884595 0.9280287 High regime: const.H phiH.1 -0.6726318 0.1331190 Smoothing parameter: gamma = 100 Threshold Variable: Z(t) = + (1) X(t) Value: 3.236 > deviance(mod.lstar2) [,1] [1,] 12.59746 > c(AIC(mod.lstar2),BIC(mod.lstar2)) [1] -239.1082 -222.6910 > > ## include: none > mod.lstar_noConst <- lstar(log10(lynx), m=2, control=list(maxit=1000), include="none") Using maximum autoregressive order for low regime: mL = 2 Using maximum autoregressive order for high regime: mH = 2 Using default threshold variable: thDelay=0 Performing grid search for starting values... Starting values fixed: gamma = 3.538462 , th = 2.719919 ; SSE = 4.933078 Optimization algorithm converged Optimized values fixed for regime 2 : gamma = 2.456908 , th = 2.707843 ; SSE = 4.907455 > mod.lstar_noConst Non linear autoregressive model LSTAR model Coefficients: Low regime: phiL.1 phiL.2 1.4005126 -0.2253725 High regime: phiH.1 phiH.2 0.7660504 -1.0552844 Smoothing parameter: gamma = 2.457 Threshold Variable: Z(t) = + (1) X(t) + (0) X(t-1) Value: 2.708 > deviance(mod.lstar_noConst) [,1] [1,] 4.907455 > c(AIC(mod.lstar_noConst),BIC(mod.lstar_noConst)) [1] -346.5805 -330.1633 > > ## include: trend > mod.lstar_trend <- lstar(log10(lynx), m=2, control=list(maxit=1000), include="trend") Using maximum autoregressive order for low regime: mL = 2 Using maximum autoregressive order for high regime: mH = 2 Using default threshold variable: thDelay=0 Performing grid search for starting values... Starting values fixed: gamma = 3.538462 , th = 2.712901 ; SSE = 4.899802 Optimization algorithm converged Optimized values fixed for regime 2 : gamma = 2.575672 , th = 2.697974 ; SSE = 4.880102 > mod.lstar_trend Non linear autoregressive model LSTAR model Coefficients: Low regime: trend.L phiL.1 phiL.2 1.825193e-05 1.403688e+00 -2.333263e-01 High regime: trend.H phiH.1 phiH.2 0.0006932109 0.7390089035 -1.0305204430 Smoothing parameter: gamma = 2.576 Threshold Variable: Z(t) = + (1) X(t) + (0) X(t-1) Value: 2.698 > deviance(mod.lstar_trend) [,1] [1,] 4.880102 > c(AIC(mod.lstar_trend),BIC(mod.lstar_trend)) [1] -343.2177 -321.3281 > > ## include: both > mod.lstar_both <- lstar(log10(lynx), m=2, control=list(maxit=1000), include="both") Using maximum autoregressive order for low regime: mL = 2 Using maximum autoregressive order for high regime: mH = 2 Using default threshold variable: thDelay=0 Performing grid search for starting values... Starting values fixed: gamma = 100 , th = 2.565527 ; SSE = 4.581837 Grid search selected lower/upper bound gamma (was: 1 100 ]). Might try to widen bound with arg: 'starting.control=list(gammaInt=c(1,200))' Optimization algorithm converged Optimized values fixed for regime 2 : gamma = 100.0001 , th = 2.568063 ; SSE = 4.580635 > mod.lstar_both Non linear autoregressive model LSTAR model Coefficients: Low regime: const.L trend.L phiL.1 phiL.2 0.3869417359 0.0002595822 1.2409824738 -0.3277026131 High regime: const.H trend.H phiH.1 phiH.2 0.7981219886 0.0001995693 0.3034500606 -0.6346479944 Smoothing parameter: gamma = 100 Threshold Variable: Z(t) = + (1) X(t) + (0) X(t-1) Value: 2.568 > deviance(mod.lstar_both) [,1] [1,] 4.580635 > c(AIC(mod.lstar_both),BIC(mod.lstar_both)) [1] -346.4371 -319.0751 > > ## grid attributes > mod.lstar3 <- lstar(log10(lynx), m=2, control=list(maxit=3000), starting.control=list(gammaInt=c(1,1000), nTh=100)) Using maximum autoregressive order for low regime: mL = 2 Using maximum autoregressive order for high regime: mH = 2 Using default threshold variable: thDelay=0 Performing grid search for starting values... Starting values fixed: gamma = 871.9231 , th = 2.560424 ; SSE = 4.564989 Optimization algorithm converged Optimized values fixed for regime 2 : gamma = 871.9231 , th = 2.560332 ; SSE = 4.564987 > mod.lstar3 Non linear autoregressive model LSTAR model Coefficients: Low regime: const.L phiL.1 phiL.2 0.3992404 1.2466373 -0.3316956 High regime: const.H phiH.1 phiH.2 0.7821303 0.3009462 -0.6246129 Smoothing parameter: gamma = 871.9 Threshold Variable: Z(t) = + (1) X(t) + (0) X(t-1) Value: 2.56 > deviance(mod.lstar3) [,1] [1,] 4.564987 > c(AIC(mod.lstar3),BIC(mod.lstar3)) [1] -350.8272 -328.9377 > > > mod.lstar_ALL <- list(mod.lstar=mod.lstar, mod.lstar2=mod.lstar2, + mod.lstar_noConst=mod.lstar_noConst,mod.lstar_trend=mod.lstar_trend, + mod.lstar_both=mod.lstar_both,mod.lstar3=mod.lstar3) > > vec_min_size <- function(x, size = 1, enforce = TRUE) { + l <- length(x) + if(l > > sapply(mod.lstar_ALL, function(x) c(AIC=AIC(x), BIC=BIC(x), deviance=deviance(x))) mod.lstar mod.lstar2 mod.lstar_noConst mod.lstar_trend AIC -356.650870 -239.10818 -346.580507 -343.217691 BIC -334.761283 -222.69098 -330.163316 -321.328104 deviance 4.337643 12.59746 4.907455 4.880102 mod.lstar_both mod.lstar3 AIC -346.437120 -350.827247 BIC -319.075136 -328.937660 deviance 4.580635 4.564987 > sapply(mod.lstar_ALL, function(x) vec_min_size(coef(x),8)) mod.lstar mod.lstar2 mod.lstar_noConst mod.lstar_trend mod.lstar_both const.L 0.4891014 0.2884595 1.4005126 1.825193e-05 0.3869417359 phiL.1 1.2465399 0.9280287 -0.2253725 1.403688e+00 0.0002595822 phiL.2 -0.3664328 -0.6726318 0.7660504 -2.333263e-01 1.2409824738 const.H -1.0240758 0.1331190 -1.0552844 6.932109e-04 -0.3277026131 phiH.1 0.4232669 100.0031347 2.4569077 7.390089e-01 0.7981219886 phiH.2 -0.2546088 3.2356515 2.7078431 -1.030520e+00 0.0001995693 gamma 11.1538344 NA NA 2.575672e+00 0.3034500606 th 3.3391985 NA NA 2.697974e+00 -0.6346479944 mod.lstar3 const.L 0.3992404 phiL.1 1.2466373 phiL.2 -0.3316956 const.H 0.7821303 phiH.1 0.3009462 phiH.2 -0.6246129 gamma 871.9230770 th 2.5603319 > sapply(mod.lstar_ALL, getTh) mod.lstar.th mod.lstar2.th mod.lstar_noConst.th 3.339199 3.235652 2.707843 mod.lstar_trend.th mod.lstar_both.th mod.lstar3.th 2.697974 2.568063 2.560332 > sapply(mod.lstar_ALL, function(x) vec_min_size(coef(x,hyperCoef=FALSE),8)) mod.lstar mod.lstar2 mod.lstar_noConst mod.lstar_trend mod.lstar_both const.L 0.4891014 0.2884595 1.4005126 1.825193e-05 0.3869417359 phiL.1 1.2465399 0.9280287 -0.2253725 1.403688e+00 0.0002595822 phiL.2 -0.3664328 -0.6726318 0.7660504 -2.333263e-01 1.2409824738 const.H -1.0240758 0.1331190 -1.0552844 6.932109e-04 -0.3277026131 phiH.1 0.4232669 NA NA 7.390089e-01 0.7981219886 phiH.2 -0.2546088 NA NA -1.030520e+00 0.0001995693 NA NA NA NA 0.3034500606 NA NA NA NA -0.6346479944 mod.lstar3 const.L 0.3992404 phiL.1 1.2466373 phiL.2 -0.3316956 const.H 0.7821303 phiH.1 0.3009462 phiH.2 -0.6246129 NA NA > sapply(mod.lstar_ALL, function(x) vec_min_size(coef(x,hyperCoef=FALSE, regime = "L"), 4)) mod.lstar mod.lstar2 mod.lstar_noConst mod.lstar_trend mod.lstar_both const.L 0.4891014 0.2884595 1.4005126 1.825193e-05 0.3869417359 phiL.1 1.2465399 0.9280287 -0.2253725 1.403688e+00 0.0002595822 phiL.2 -0.3664328 NA NA -2.333263e-01 1.2409824738 NA NA NA NA -0.3277026131 mod.lstar3 const.L 0.3992404 phiL.1 1.2466373 phiL.2 -0.3316956 NA > sapply(mod.lstar_ALL, function(x) vec_min_size(coef(x,hyperCoef=FALSE, regime = "H"), 4)) mod.lstar mod.lstar2 mod.lstar_noConst mod.lstar_trend mod.lstar_both const.H -1.0240758 -0.6726318 0.7660504 0.0006932109 0.7981219886 phiH.1 0.4232669 0.1331190 -1.0552844 0.7390089035 0.0001995693 phiH.2 -0.2546088 NA NA -1.0305204430 0.3034500606 NA NA NA NA -0.6346479944 mod.lstar3 const.H 0.7821303 phiH.1 0.3009462 phiH.2 -0.6246129 NA > sapply(mod.lstar_ALL, function(x) head(x$model,2)) $mod.lstar yy const.L phiL.1 phiL.2 const.H phiH.1 phiH.2 1 2.767156 1 2.506505 2.429752 3.931706e-05 0.0000985484 9.553071e-05 2 2.940018 1 2.767156 2.506505 9.254479e-05 0.0002560859 2.319640e-04 $mod.lstar2 yy const.L phiL.1 const.H phiH.1 1 2.506505 1 2.429752 9.980313e-36 2.424969e-35 2 2.767156 1 2.506505 2.150693e-32 5.390722e-32 $mod.lstar_noConst yy phiL.1 phiL.2 phiH.1 phiH.2 1 2.767156 2.506505 2.429752 0.9494498 0.9203763 2 2.940018 2.767156 2.506505 1.4842116 1.3444070 $mod.lstar_trend yy trend.L phiL.1 phiL.2 trend.H phiH.1 phiH.2 1 2.767156 1 2.506505 2.429752 0.3791494 0.9503398 0.921239 2 2.940018 2 2.767156 2.506505 1.0888603 1.5065231 1.364617 $mod.lstar_both yy const.L trend.L phiL.1 phiL.2 const.H trend.H phiH.1 1 2.767156 1 1 2.506505 2.429752 0.002116716 0.002116716 0.00530556 2 2.940018 1 2 2.767156 2.506505 0.999999998 1.999999995 2.76715586 phiH.2 1 0.005143096 2 2.506505027 $mod.lstar3 yy const.L phiL.1 phiL.2 const.H phiH.1 phiH.2 1 2.767156 1 2.506505 2.429752 4.142784e-21 1.038391e-20 1.006594e-20 2 2.940018 1 2.767156 2.506505 1.000000e+00 2.767156e+00 2.506505e+00 > > proc.time() user system elapsed 4.39 0.42 4.79