Hi,
My issue is that I want to use the forecast::checkresiduals function inside my function, however, it contains a print command, and I am not able to prevent printing the full test description, even if I only want to see the p.value.
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 3.6.3
#> Warning: package 'ggplot2' was built under R version 3.6.3
#> Warning: package 'tibble' was built under R version 3.6.3
#> Warning: package 'tidyr' was built under R version 3.6.3
#> Warning: package 'dplyr' was built under R version 3.6.3
#> Warning: package 'forcats' was built under R version 3.6.3
data('JohnsonJohnson')
mod <- forecast::auto.arima(JohnsonJohnson)
#> Registered S3 method overwritten by 'quantmod':
#> method from
#> as.zoo.data.frame zoo
f <- function(x) {
p <- forecast::checkresiduals(x, plot = F)$p.value
return(p)
}
f(mod)
#>
#> Ljung-Box test
#>
#> data: Residuals from ARIMA(3,1,1)(0,1,0)[4]
#> Q* = 5.6193, df = 4, p-value = 0.2294
#>
#> Model df: 4. Total lags used: 8
#> [1] 0.229439
Created on 2020-12-22 by the reprex package (v0.3.0)
Thank you for your answer in Advance,
Marcell