A functional approach, using tidyverse purrr package
x<- datasets::lh
permuted_inputs <- purrr::cross2(0:3,0:3)
my_results <- purrr::map(.x=permuted_inputs,
.f= ~ arima(x,
order=c(.x[[1]],0,.x[[2]]),
method="ML")
)
purrr::walk2(.x = my_results,
.y = permuted_inputs,
.f = ~cat(
"p: ",.y[[1]], " , " ,
"q: ",.y[[2]], " , " ,
"aic:",.x$aic,"\n"))