I use loop for a function,
AllModel <- AllData[c(2:8)]
alladvancedfit <- data.frame(matrix(, nrow=7, ncol=1))
for (Model in AllModel) {
advancedfit.model <- Arima(AllData$x1,order=c(0,1,2),xreg=Model)
inSampleAdvancedFitMAE <- mean(abs(advancedfit.model$residuals))
}
AllModel capture this data set
v1 v2 v3 v4 v5 v6 v7
1 39 4 84 75 41 6 83
2 40 6 86 77 44 6 84
3 39 5 82 73 40 6 81
4 37 5 100 71 39 6 90
5 39 5 83 70 37 5 79
6 44 6 82 78 40 6 78
7 41 5 76 76 40 7 78
8 40 5 74 72 42 6 81
And the result is lists of output.
[1] 61.01004
[1] 61.23916
[1] 60.78099
[1] 61.15394
[1] 61.16968
[1] 61.30191
[1] 61.00637
Would like to put this into one data frame. Try to rbind it inside the loop but so far it is unsuccessful.