Serving the Quantitative Finance Community

 
User avatar
wdai03
Topic Author
Posts: 1
Joined: June 1st, 2011, 1:26 pm

How do you test for unit root in an ARMA model?

June 3rd, 2011, 2:36 am

I know for the augmented fuller test, we use the formula Z_t= alpha + phi*Z_t-1 + rho1(Delta Z_t-1) + rho2(Delta Z_t-2) ... rho(p-1) (Delta Z_t-(p-1)) + a_tfor an AR(P) model(rho probably isn't the correct symbol but my knowledge of the greeks isn't very good, but the formula should be familiar)However, what if the model is for example is ARMA(4, 5), how do you deal with the MA section in the ADF test?The specific question in context is I'm trying to test cointegration between a number of stocks, and the first thing that is required is to test for unit roots, but i have no idea how to do it when there's an MA tail in the model. I've also read somewhere that we should be testing the log prices for unit roots or something, but I can't see how this will make sense in a pairs trade, since we'll just be buying and shorting stocks directly. Am I missing something here? I'm a bit new at thisThanks!
 
User avatar
rprat
Posts: 0
Joined: December 12th, 2009, 9:45 am

How do you test for unit root in an ARMA model?

June 3rd, 2011, 6:55 am

If i am not wrong, you have to test for cointegration between the returns of the series, not the prices of the stocks. To test for unit roots I always have used R whick has ADF in different packages. It tests for diferent lengths and provides summary of result independent of the series MA, AR or others. Hope it helps.
 
User avatar
blade
Posts: 0
Joined: June 18th, 2002, 3:28 pm

How do you test for unit root in an ARMA model?

June 3rd, 2011, 9:31 am

Errr..... think you guys are going down the wrong track here. Ok, I'll give my viewpoint but am sure there are more expert people than me out there. If you look at prices of stocks, they are what is known as an I(1) process, ie any shocks to the system ( error terms to you and me ) have a persistence. We need I(0) processes to be able to do stuff like ARMA modeling, regression etc - we need at least weak stationarity. Look at the acf of a price vs return series to see what I mean. One way of getting to an I(0) process where the errors will die away at a certain interval, is to difference the series and work on the differences. If you take logs of the prices first then that difference will be your returns. Another way is to remove the trend if the series is trend stationary. Now... I think it was Engle and Granger who first did this, but they found that certain bits of data retained a common factor and some combination of data X and Y ( X = a + bY ) would be an I(0) process. You could then use this term in whatever you wanted as it was now I(0). Now they started doing regressions to find a and b and find cointegrated processes, but started to find cointegrations in data that clearly had no cointegration visually. The regression itself biased the results towards cointegration. So they (or possibly dickey-fuller am not sure) came up with a test to check for spurious cointegrations. The main idea behind the test is to reject the fact that the error term Z ( Z = X - a - bY ), was not just a random walk (unit root) but errors actually died away. So you run the regression, do adf on the residuals and then reject unit root on data which is significantly -ve on the t-stat, and as you can see the t-stat values are pretty stringent for df, definitely above the standard regression values. The tests were then augmented ( adf ) to allow for serial autocorrelation, and other tests which allowed incorporation of heteroskedasticity etc like Phillips-Perron were developed. So .... in a nutshell1) Get price series ... perhaps use logs of price series but on short history's it shouldn't matter too much (ie where price change is not that massive)2) Run your residual .... and also ask yourself the question what should be X and what should be Y in my regression3) Check your residuals with df, adf, or whatever to check if they are cointegrated. 4) Then figure out how to trade or do whatever you want with the pair. There should be plenty on the web on this, but I hope I can at least push you in the right direction.
 
User avatar
wdai03
Topic Author
Posts: 1
Joined: June 1st, 2011, 1:26 pm

How do you test for unit root in an ARMA model?

June 3rd, 2011, 10:42 am

Thanks for the help guys!I'm trying to get a better understanding of how the cointegration is actually calculated though. R gives the answer but i'm a bit confused on the actual process.I get the basic understanding of how cointegration works. First you need to check if the two time series of I(1), which is done using the dicky-fuller test. If they are both I(1) then you can regress one on another, take the error, and check if they are I(0) i.e. stationary. This can be done using the dicky-fuller test again. The idea is that stationary series have mean reverting characteristics. In the end i guess what i'm really confused about is:1) Why do people tend to look at the log price? I know that after taking a differencing it effectively represents continuous returns, but I can't really see how that helps with anything, cause all you get is the continuous return from each price change. However, I've heard that if the log of a time series is stationary, than the actual time series will also be stationary. I hope someone could really explain this concept since it's really confusing. 2) How do you conduct a dicky-fuller on an ARMA (p,q) model when q>=1? The augmented Dicky-Fuller is aimed at AR's specifically but what if there is also an MA component to the time series? Regardless whether we are testing whether the price series or the error terms after the regression is, we need to know what (P) is first in order to use the ADF test (right?). But what if the series isn't a simple Autoregressive model but an ARMA?3) Do we actually need to test to see if the price series is I(1)? I see its not included in the steps of your post, blade. Is it enough to simply test whether the error term after the regression is I(0), or do we still need to check the price series to see if it is I(1) first? I know most papers claim that stocks are typically I(1), but is it common practice to check it first anyways before we proceed to the Engle-Granger test (i.e. the regression and the DF test on the residuals)?
 
User avatar
wdai03
Topic Author
Posts: 1
Joined: June 1st, 2011, 1:26 pm

How do you test for unit root in an ARMA model?

June 3rd, 2011, 10:46 am

p.s. it'd be very helpful if anyone knows which paper first showed that stocks tend to be I(1). I'm hoping to have some sort of example that shows how we can test for unit roots in the price series of stocks, it'll make the concepts much more easier to understand
 
User avatar
blade
Posts: 0
Joined: June 18th, 2002, 3:28 pm

How do you test for unit root in an ARMA model?

June 3rd, 2011, 12:16 pm

1) Log price is to do with long term characteristics, and on the fact that your returns are log returns if you are holding the pair etc. I wouldn't worry too much about this. Just use log prices ... and the difference is returns. If you really want to investigate, take something long term like sp500 and say dow. Try the cointegration with or without logging and see what happens over say like 10-20 years. If nothing else just draw the graph and plot both prices of log and non long and you'll see what I mean. 2) Dickey Fuller is not an ARMA model. You are kind of thinking about this the wrong way I think. Dickey-Fuller is the test. If you want to fit an ARMA model to the residuals/returns then that's fine but it's not related to the DF test, you are just fitting an ARMA model. People alot of the time do fit ARMA models to returns, and VARMA models to multivariate returns but then it's not necessarily cointegration. There may be cointegration in the system, but you can fit an ARMA model to a non-cointegrated system as well. Technically just a VARMA fit to a cointegrated system will be incorrect but you really need to go through all the steps to understand this. Also you can fit an ARIMA model to a price series, but it's still doing the differencing internally and it's not cointegration. 3) Ok, sorry in theory you should check that price series is I(1) to start with. I assumed that and you're right some stock prices are I(0) all by themselves. I see you are using R.... if you want to see the difference between and I(1) and I(0) process then get a price series and do an acf on log(x). Then r <- diff(x) to get differenced values and do acf on this. See how the error terms disappear as the lags in increase in the latter but very much stay there in the log price series ? A time series book should explain some of this stuff, and I think market models by Alexander goes through this. There should be some stuff on the web as well. I do think you should do some work on some non - finance data sets and start to understand this stuff before trying to create a trading strategy with it. It seems simple, especially when R does the work, but there's alot more to it than you think. Just so you don't think I am putting you down, I was exactly the same when I started doing this stuff, but had to backtrack and really understand it for things to really fall into place, and I think I still have a lot to learn ....
 
User avatar
wdai03
Topic Author
Posts: 1
Joined: June 1st, 2011, 1:26 pm

How do you test for unit root in an ARMA model?

June 10th, 2011, 4:41 am

Thanks for your help blade, and i appreciate your thoughtfulness, but you're just making me as confused as ever. I still don't really understand what the whole log thing is about. I mean i get that the normal procedure is to just look at log prices, but telling me not to worry about this doesn't really help. Telling me to just see what you mean doesn't let me know at all what i'm looking for. I know your disclaimer in your first post so i don't want you to take this the wrong way, but your not really providing me with any conclusive help. And i'm not sure what is it that gave you the idea that I thought Dicky Fuller is an Arma Model. I clearly said "conduct a Dicky Fuller on an ARMA model". I mean come on, this is just a bit demeaning. I've already fitted the time series I want to an ARMA model using the Akaike Criteria, and i'm asking how to conduct the Dicky Fuller Test on a ARMA(4,5) model. And yes, I understand this is only part of the cointegration test. And for 3), the ACF shows correlation, not error. I'm not too sure what you mean. The decreasing thing isn't error, its the correlation between each lag, which depends on the prior values and their error terms. I hope I don't sound ungrateful. I'm learnt time series pretty vigrously as my major is especially heavy in statistics and we covered ARMA and a lot of the theories behind it. Unfortunately we didn't cover cointegration, and this problem has been bothering me for a while now since I can't find any solid examples. Could someone give me a hand?
Last edited by wdai03 on June 9th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
blade
Posts: 0
Joined: June 18th, 2002, 3:28 pm

How do you test for unit root in an ARMA model?

June 10th, 2011, 8:38 am

Ok, now I am confused. I was going to answer your questions but I think we will just end up going back and forth and you will be more confused. Are you learning or have you learnt time series ? Because some of this stuff is pretty fundamental. Think if you are struggling with this sort of stuff maybe it'd be better to pick up a time series book and start from the beginning ? Here's a link to some stuff on pairs trading I've seen before on the web and covers the basics, but again it may confuse you. http://www.yats.com/doc/cointegration-en.pdfBut with some of the fundamental questions maybe get a time series book ? Hamilton is pretty severe but I think there are some more introductory time series books out there. Not sure what's online but am sure there's stuff there as well. btw, I kind of did the same thing a few years ago when I starting analyzing market data. Jump in and apply techniques, thinking I did it right, but I was doing it wrong. Everyone who told me otherwise was just being stupid and pedantic. I didn't need all that introductory stuff, I was smart so I could just jump on to the super sexy advanced techniques. I had to spend alot of time going back and understanding all the fundamentals and now I think I am starting to do it right, but still have a lot to learn. The more I learn the more I realise I don't know, so don't take offence when people give you advice, there's probably something in what they are saying and maybe you don't get it straightaway. I often have to go back to high school books on some topics to get the basics correct. At the same time on the internet everyone with its general anonymity seems to be an expert, so what's important is you listen to the advice, do your own analysis and find what works and doesn't. I was just trying to steer you in the right direction. Try to find data sets outside of finance to work with as well, as looking at different data sets may help your understanding.