I have real daily market data which I'm looking at to create a model for forecasting. The model that I created (below) used autoregressive terms within a linear regression.

I was sharing this with a colleague and he said "autoregressive variables are correlated with the other variables in multiple linear setting which creates multicollinarity problem, creating unreliable result."

So I'm turning to the group for help. Here is the data and the analysis that I performed in R.

#Read in Data
MarketData = read.table('http://sharp-waterfall-3397.herokuapp.com/MarketCategories6.txt', header=TRUE,na.strings = "NA", sep=",")
MarketData$Month <- as.factor(MarketData$Month)
MarketData$Weekday <- as.factor(MarketData$Weekday)


I'm using the PERregress library to help with the autoregression using the back() function and to help with the residual diagnostics:


Subsetting the data for model building and prediction purposes:

Total = MarketData
MarketData = MarketData[1:268,]

Here is a regression with everything that I can think of. Note you can have higher autoregressive terms but this will start to mask events since R will ignore the first several rows. Also just an FYI for some reason the residual analysis is breaking which I liked to look for points with undue leverage.

#Market1Category1 Regression for the markets with everything that I can think of it
Market1Category1Output=lm(Market1Category1 ~ Trend+Month2+Month3+Month4+
                          back(Market1Category1)+back(Market1Category1, 2))

Here is the final equation. I'd like to say that I reduced the variables using partial f-test but I couldn't find an easy way to do this so if you know a function please let me know. Basically I looked at the change in adjusted $R^2$.

#Final regression equation 
Market1Category1Output=lm(Market1Category1 ~ Month5+Month6+Month7+
                          back(Market1Category1)+back(Market1Category1, 6))

Here is a plot of the actuals in green vs the predictions in blue but there's a problem:

plot(Time, Market1Category1, col='green')
points(Time, predict(Market1Category1Output, MarketData), col='blue', pch=20)

The issue is that predict will use the data values instead of it's predicted values for the autoregressive terms. In order to make it use predicted terms I created this loop. If you know a better way let me know.

dataSet2 <- Total
dataSet2[8:length(dataSet2$Time),"Market1Category1"] <- NA
    for (i in (1:(length(dataSet2$Time)-7))) {
  dataSet2[6+i+1,"Market1Category1"] <- 1
  dataSet2[6+i+1,"Market1Category1"] <- predict(Market1Category1Output, 

Here is the plot again with the results in blue using the predicted results for the autoregressive terms (with the exception of the first 7 since the model needs those to predict):

plot(Total$Time, Total$Market1Category1, col='green')
points(dataSet2$Time, dataSet2$Market1Category1, col='blue', pch=20)

So here are my questions in order of importance:

  1. Does using autoregressive and linear terms violate any fundamental assumptions?
  2. What issues can this cause and what analysis/steps should I do take to avoid these problems?
  3. Is there a better approach to modeling this timeseries?
  4. Is there a more efficient approach?
  5. Given the residuals what steps would you take?

Finally two questions which is just causing me more work than possibly necessary:

  1. As you can see instead of using the factors for weekday and month I'm using separate conditional variables. I'm doing this because if I use the factor and a level turns out to be insignificant (e.g., Monday for days of the week). I can't remove it. Perhaps there's a way?
  2. Is there a quick way to run a partial F-statistic to understand whether removing a variable makes sense?

closed as off-topic by mkt, Michael Chernick, StatsStudent, kjetil b halvorsen, Peter Flom Jun 20 at 9:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – mkt, Michael Chernick, StatsStudent, Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.