robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.11k stars 341 forks source link

ets() print method splits the call object representation #956

Closed cgiachalis closed 5 months ago

cgiachalis commented 5 months ago

Notice the Call: when printing the ets object.

fit <- forecast::ets(USAccDeaths, damped = TRUE, additive.only = FALSE,  model = "ZZZ", opt.crit = "lik", ic = "aicc")

fit
#> ETS(M,Ad,M) 
#> 
#> Call:
#>  forecast::ets(y = USAccDeaths, model = "ZZZ", damped = TRUE,   <-------HERE
#> 
#>  Call:
#>      additive.only = FALSE, opt.crit = "lik", ic = "aicc")   <-------HERE
#> 
#>   Smoothing parameters:
#>     alpha = 0.4912 
#>     beta  = 0.0069 
#>     gamma = 1e-04 
#>     phi   = 0.9757 
#> 
#>   Initial states:
#>     l = 9957.0912 
#>     b = -51.0211 
#>     s = 0.9981 0.9707 1.0266 0.9919 1.1116 1.1912
#>            1.0897 1.0388 0.9384 0.9123 0.8233 0.9074
#> 
#>   sigma:  0.0331
#> 
#>      AIC     AICc      BIC 
#> 1140.126 1153.031 1181.106

This is due to this code line https://github.com/robjhyndman/forecast/blob/e565f31665bb9f55758cb2513dfa2bfd151a3dfb/R/ets.R#L1104

An one-liner fix would be:

cat("Call:", deparse(fit$call), sep = "\n")
#> Call:
#> forecast::ets(y = USAccDeaths, model = "ZZZ", damped = TRUE, 
#>     additive.only = FALSE, opt.crit = "lik", ic = "aicc")

Other objects don't have this issue as they're both concatenating and printing: https://github.com/robjhyndman/forecast/blob/e565f31665bb9f55758cb2513dfa2bfd151a3dfb/R/bats.R#L359-L360

robjhyndman commented 5 months ago

Thanks. Fixed in https://github.com/robjhyndman/forecast/commit/1f537ebddf318050f7c5ed362bf92cf618041edc