I have written an predictor function on R and I tried several combinations of inputs in the function to see how the output would change.
The problem is that my function takes 4 numeric parameters and I want to test my function by plugging all possible combinations of elements obtained from specified vectors ( vectors have different lengths)
I've tried using replicate, apply and sapply functions but I couldn't get the output that I wanted to see. I can do for loops for each parameter but when it comes to several parameters i need several loops and I don't know how to store the values after this many loops.
So my function looks like this;
predictVAR(Dataset, ColumnNumber, Correlation, Lags, FcastHorizon)
And while keeping the Dataset constant ( or i can just remove it from parameter list and assign it as the default data frame in function)
- ColumnNumber takes values between 1 and 20 ( each of these are the corresponding variables from Dataset)
- Correlation will take values in seq(0.15,0.9,by=0.15)
- Lags will take values in c(10, 20, 30, 50, 80, 100)
- and finally FcastHorizon will take values from list c(20,252)
So if I started doing this manually and evaluate each combination from these specified vectors, it would look like
- predictVAR(1, 0.1, 10, 20) => predictVAR(1, 0.1, 10, 252) => predictVAR(1, 0.1, 20, 20) => predictVAR(1, 0.1, 20, 252) . . . . and finally;=> predictVAR(20, 0.9,100 ,252)
By the end of process, I should obtain 20*6*6*2=1440 different outputs and the corresponding input specifications.
Could you help me about what function would help me to obtain the results? I have read topics about the family of apply functions but I need to evaluate the model with all cross combinations and I couldn't find a solution so far.
Regards