I need to apply all the combinations of the elements of a vector to a particular function, and use these elements as inputs for this function as well. I would like it to be somewhat fast, but any combination of apply and its different flavors has proved fruitless so far.
In short, I have a time series, and I need to fit an ARIMA model to describe this process. The function arima from the package stats requires a set of inputs, since I do not want to do this manually, a function that could do that for me seems in order.
I have so far tried this:
library(stats)
#need a vector to cycle and use as inputs in the function
nums <- c(0:3)
#random time series
x <- rnorm(1000,mean=1,sd=1)
#attempt 1
lapply(nums, arima(x, order=c(nums,nums,nums)))
#attempt 2
lapply(nums, arima(x))
#attempt 3
#create another vector, as to start cycle with 1 rather than 0
nums2 <- c(1:3)
lapply(nums2, arima(randomtimeseries, c(nums, nums, nums)))
This has to be done this way as this is to be run as a cron job, so no input to be added by a user in order to simplify the above process.