Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify print output for x13/regarima #57

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

AQLT
Copy link
Contributor

@AQLT AQLT commented Jul 24, 2024

I propose to simplify the print output of the /RegARIMA and seasonal adjustment models. A message with a reference to the summary() method is added (which can be disabled with the summary_info option). This is linked to rjdverse/rjd3toolkit#56.

library(rjd3x13)
y <- rjd3toolkit::ABS$X0.2.09.10.M
reg <- regarima(y)
x13_mod <- x13(y)
summary(reg$result)
#> Log-transformation: yes 
#> SARIMA model: (2,1,1) (0,1,1)
#> 
#> Coefficients
#>           Estimate Std. Error  T-stat Pr(>|t|)    
#> phi(1)     0.34740    0.06502   5.343 1.53e-07 ***
#> phi(2)     0.21733    0.06000   3.622 0.000329 ***
#> theta(1)  -0.69937    0.05115 -13.672  < 2e-16 ***
#> btheta(1) -0.48038    0.06993  -6.869 2.45e-11 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Regression model:
#>                   Estimate Std. Error T-stat Pr(>|t|)    
#> td               0.0023233  0.0006844  3.395 0.000755 ***
#> easter           0.0520113  0.0084894  6.127 2.14e-09 ***
#> TC (2000-06-01)  0.1590340  0.0288578  5.511 6.38e-08 ***
#> AO (2000-07-01) -0.2900774  0.0400551 -7.242 2.26e-12 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> Number of observations: 425, Number of effective observations: 412, Number of parameters: 9
#> Loglikelihood: 746.7517, Adjusted loglikelihood: -2120.875
#> Standard error of the regression (ML estimate): 0.03927991 
#> AIC: 4259.75, AICc: 4260.198, BIC: 4295.939
x13_mod
#> Model: X-13
#> Log-transformation: yes 
#> SARIMA model: (2,1,1) (0,1,1)
#> 
#> SARIMA coefficients:
#>    phi(1)    phi(2)  theta(1) btheta(1) 
#>    0.3474    0.2173   -0.6994   -0.4804 
#> 
#> Regression model:
#>              td          easter TC (2000-06-01) AO (2000-07-01) 
#>        0.002323        0.052011        0.159034       -0.290077 
#> 
#> Seasonal filter: S3X3
#> Trend filter: 23 terms Henderson moving average
#> 
#> For a more detailed output, use the 'summary()' function.
options(summary_info = FALSE)
x13_mod
#> Model: X-13
#> Log-transformation: yes 
#> SARIMA model: (2,1,1) (0,1,1)
#> 
#> SARIMA coefficients:
#>    phi(1)    phi(2)  theta(1) btheta(1) 
#>    0.3474    0.2173   -0.6994   -0.4804 
#> 
#> Regression model:
#>              td          easter TC (2000-06-01) AO (2000-07-01) 
#>        0.002323        0.052011        0.159034       -0.290077 
#> 
#> Seasonal filter: S3X3
#> Trend filter: 23 terms Henderson moving average
summary(reg)
#> Method: RegARIMA 
#> Log-transformation: yes 
#> SARIMA model: (2,1,1) (0,1,1)
#> 
#> Coefficients
#>           Estimate Std. Error  T-stat Pr(>|t|)    
#> phi(1)     0.34740    0.06502   5.343 1.53e-07 ***
#> phi(2)     0.21733    0.06000   3.622 0.000329 ***
#> theta(1)  -0.69937    0.05115 -13.672  < 2e-16 ***
#> btheta(1) -0.48038    0.06993  -6.869 2.45e-11 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Regression model:
#>                   Estimate Std. Error T-stat Pr(>|t|)    
#> td               0.0023233  0.0006844  3.395 0.000755 ***
#> easter           0.0520113  0.0084894  6.127 2.14e-09 ***
#> TC (2000-06-01)  0.1590340  0.0288578  5.511 6.38e-08 ***
#> AO (2000-07-01) -0.2900774  0.0400551 -7.242 2.26e-12 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> Number of observations: 425, Number of effective observations: 412, Number of parameters: 9
#> Loglikelihood: 746.7517, Adjusted loglikelihood: -2120.875
#> Standard error of the regression (ML estimate): 0.03927991 
#> AIC: 4259.75, AICc: 4260.198, BIC: 4295.939
summary(x13_mod) # previous output
#> Model: X-13
#> Log-transformation: yes 
#> SARIMA model: (2,1,1) (0,1,1)
#> 
#> Coefficients
#>           Estimate Std. Error  T-stat Pr(>|t|)    
#> phi(1)     0.34740    0.06502   5.343 1.53e-07 ***
#> phi(2)     0.21733    0.06000   3.622 0.000329 ***
#> theta(1)  -0.69937    0.05115 -13.672  < 2e-16 ***
#> btheta(1) -0.48038    0.06993  -6.869 2.45e-11 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Regression model:
#>                   Estimate Std. Error T-stat Pr(>|t|)    
#> td               0.0023233  0.0006844  3.395 0.000755 ***
#> easter           0.0520113  0.0084894  6.127 2.14e-09 ***
#> TC (2000-06-01)  0.1590340  0.0288578  5.511 6.38e-08 ***
#> AO (2000-07-01) -0.2900774  0.0400551 -7.242 2.26e-12 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> Number of observations: 425, Number of effective observations: 412, Number of parameters: 9
#> Loglikelihood: 746.7517, Adjusted loglikelihood: -2120.875
#> Standard error of the regression (ML estimate): 0.03927991 
#> AIC: 4259.75, AICc: 4260.198, BIC: 4295.939
#> 
#> Decomposition
#> Monitoring and Quality Assessment Statistics: 
#>     M stats
#> m1    0.071
#> m2    0.075
#> m3    2.119
#> m4    0.134
#> m5    1.632
#> m6    0.117
#> m7    0.053
#> m8    0.163
#> m9    0.050
#> m10   0.146
#> m11   0.143
#> q     0.465
#> qm2   0.513
#> 
#> Final filters: 
#> Seasonal filter: S3X3
#> Trend filter: 23 terms Henderson moving average
#> 
#> Diagnostics
#> Relative contribution of the components to the stationary
#> portion of the variance in the original series,
#> after the removal of the long term trend (in %)
#> 
#>            Component
#>  cycle        13.284
#>  seasonal     86.948
#>  irregular     0.752
#>  calendar      0.245
#>  others        0.295
#>  total       101.524
#> 
#> Residual seasonality tests
#>                 P.value
#>  seas.ftest.i     0.998
#>  seas.ftest.sa    0.997
#>  seas.qstest.i    0.001
#>  seas.qstest.sa   0.000
#>  td.ftest.i       0.000
#>  td.ftest.sa      0.000
#> 
#> 
#> Final
#> Last values
#>          series       sa    trend      seas       irr
#> Sep 2016 1393.5 1556.806 1548.194 0.8951022 1.0055624
#> Oct 2016 1497.4 1549.534 1546.816 0.9663552 1.0017571
#> Nov 2016 1684.3 1530.373 1546.901 1.1005815 0.9893151
#> Dec 2016 2850.4 1567.050 1548.130 1.8189590 1.0122211
#> Jan 2017 1428.5 1508.199 1549.876 0.9471559 0.9731099
#> Feb 2017 1092.4 1557.942 1551.664 0.7011816 1.0040459
#> Mar 2017 1370.3 1563.584 1553.159 0.8763842 1.0067116
#> Apr 2017 1522.6 1581.406 1553.982 0.9628142 1.0176473
#> May 2017 1452.4 1553.376 1553.920 0.9349956 0.9996498
#> Jun 2017 1557.2 1556.929 1553.056 1.0001743 1.0024936
#> Jul 2017 1445.5 1527.804 1551.625 0.9461293 0.9846474
#> Aug 2017 1303.1 1546.399 1550.102 0.8426674 0.9976109

@TanguyBarthelemy
Copy link
Contributor

Thank you very much for this pull request. I accept it immediately!

@TanguyBarthelemy TanguyBarthelemy merged commit e0a5200 into rjdverse:develop Aug 19, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants