In my dataset I have many variables, and for each of them I want to run a prediction; here is a portion of the dataset:
Market_82 Market_83 Market_84 Market_85 Total YEAR_ MONTH_ DATE_
14481 7000 5649 6818 536413 1999 1 JAN 1999
15162 7272 5750 6943 558797 1999 2 FEB 1999
15961 7668 5901 7130 582077 1999 3 MAR 1999
16933 7869 5944 7333 605332 1999 4 APR 1999
17758 8057 6009 7637 630019 1999 5 MAY 1999
18266 8428 6177 7930 654694 1999 6 JUN 1999
19058 8587 6313 8145 678877 1999 7 JUL 1999
19881 8823 6430 8270 702958 1999 8 AUG 1999
20996 8922 6718 8363 727667 1999 9 SEP 1999
21851 9178 6908 8596 752467 1999 10 OCT 1999
22681 9306 7011 8777 776867 1999 11 NOV 1999
23769 9439 7264 8914 801741 1999 12 DEC 1999
model = arima(dataset, order=c(1,1,1))
fcast <- forecast(model, h2)
I think I need to write a loop to perform this analysis for all variables, but I'm a newbie and don't know how to write correctly a loop.
Can anybody help?