'Sarima show only plots
I have the following code that I am running in R:
```{r}
library(astsa)
data = c(1:500)
mo1 = sarima(data,0,0,2)
```
It produces both the five plots I am interested in and output from the nonlinear optimization routine. I don't want the output from the nonlinear optimization however to turn it off using details=FALSE I will also turn off the plots which I need.
When I run this code in the console, the plots are put into a pdf and the optimization output is printed to STDOUT. This is good because I can have the plots and optimization separately which is what I need, however I want to do this in RStudios. How can this be done?
Solution 1:[1]
It looks like the details argument is used to both return the trace output from the optimisers -- see the lines in sarima:
trc = ifelse(details, 1, 0)
and various
optim.control = list(trace = trc, REPORT = 1, reltol = tol)
and to produce the plots
if (details) {
< code for plots>
}
A couple of options to produce the plots but no optimiser output would be to:
capture the output from the optimiser:
mo1 = capture.output(sarima(data,0,0,2))but then you either have to parse the captured output to get the fit statistics or need to run
sarimaa second time (mo1 = sarima(data,0,0,2, details=FALSE)) to get the statistics.change the body of the function to change what the argument
detailsdoes:body(sarima)[[18]] = quote(trc <- abs(details-1)) mo1 = sarima(data,0,0,2, details = TRUE)Another option would be to request that the authors change the function to separate the optimiser trace and plot commands (i.e. add a
plot=TRUEtype argument to the function signature and changeif(details)toif(plot)).
Solution 2:[2]
It's been a couple of years but this will produce only the plots when knitted:
```{r results='hide',fig.keep='all'}
sarima(data,0,0,2)
```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | SCDCE |
