Time Series Analysis in Finance with SAS Examples of ARIMA and GARCH_第1頁
Time Series Analysis in Finance with SAS Examples of ARIMA and GARCH_第2頁
Time Series Analysis in Finance with SAS Examples of ARIMA and GARCH_第3頁
Time Series Analysis in Finance with SAS Examples of ARIMA and GARCH_第4頁
Time Series Analysis in Finance with SAS Examples of ARIMA and GARCH_第5頁
已閱讀5頁,還剩13頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、time series analysis in finance with sas examples of arima and garchtime series analysis in finance with sasexamples of arima and garch byhongchao wangin this presentation i am going to show you how to apply time series analysis in modeling financial data1. specifically, i will work with you on exam

2、ples of simple arima and garch models , which are widely used in the financial industry. part i: an arma model examplelet us first apply the arma to model the deflator data series . before writing the sas program, you may want to plot the data, which helps you observe the pattern of the data. certai

3、nly you can plot the data with sas program, but i would say it is easy to do it in excel. i did the following plots with excel, but dont worry, i will give you the sas code for plots in the presentation, and you will understand why i used excel. let us take a look at them. as you can see in figure 1

4、, the original data series is strongly trended, i.e. the mean is changing over time. figures 2 through 4 plot the log of gnp deflator series and its first and second differences. the log of original series and first differences are obviously non-stationary, but the second differencing appears to hav

5、e rendered the series stationary. figure 1 quarter data of price deflator figure 2 log price deflatorfigure 3 first difference of log(deflator) figure 4 second difference of log(deflator)with what we observed in the plots, let us now write the sas program. below is the code, write/copy and run it:op

6、tions ls = 70;/this option sets the line size, which must be between 64 256)options pagesize=55; /55 lines in each page)options obs=137; /read in no more than 137 lines of data, including the first line, which is usually variable names.options errors=2; /the program stops if there are more than two

7、errorstitle an arma example; /this gives a title which is at the top of the outputdata temp; / designate a work-space “temp”infile data.dat firstobs=2; /infile indicates where the data set is and imports the file. obviously, it is easier to have data file in the same folder with the “.sas” fileinput

8、 qtr gnp m1 p; /input gives each column of data a variable name. if the data in date column is word format in stead of numbers, we should use $ after it.y=log(p); / take log of p and name it y.run;proc arima data=temp; / yes, this is the “prototype” of arima model in sasidentify var=y; / first work

9、on y, which means we first ran arima procedure on y, i.e. calculate the acf, pacf and etc on y.identify var=y(1); / difference the series onceidentify var=y(1,1); /consecutive differencing to obtain (1-l)2yestimate p=4 method=ml; / estimate model ar(4)estimate q=4 method=ml; / estimate model ma(4)es

10、timate p=2 q=3 method=ml; / estimate model arma(2,3)estimate p=2 q=(1,3) method=ml; /estimate model arma(2,3), but ma only takes on lag 1 and 3estimate p=2 q=1 method=ml; / estimate model arma(2,1)estimate p=2 method=ml; / estimate model ar(2)run;/ the following part is the code for plots correspond

11、ing to those i showed above proc timeplot data=temp; / timeplot function plots the data and show you the trend of the data, ie, the ko price is going up or downplot p:plot y;run;take a look at the results in the “.lst” file. does it make sense to you? let us discuss it. i attached the results which

12、i am going to talk about in the tables in appendix. the first 24 autocorrelations of the log of the price deflator series are shown in table 1 of appendix. the autocorrelations of the original series show the signature of a strongly trended, non-stationary series. the first difference (table 2) also

13、 exhibits non-stationarity, because the autocorrelations are still very large after a lag of 10 periods. the second difference (table 3) appears to be stationary, with mild negative autocorrelation at the first lag, but essentially none after that. intuition might suggest that further differencing w

14、ould reduce the autocorrelation further, but it would be incorrect, which can be shown statistically. just keep in mind that in the real life you almost never difference a time series data more than twice. before the estimation can begin, we need to decide on (identify) the specific number and type

15、of arima parameters to be estimated. the major tools used in the identification phase are plots of the series, correlograms of auto correlation (acf), and partial autocorrelation (pacf). the decision is not straightforward and in less typical cases requires not only experience but also a good deal o

16、f experimentation with alternative models. however, a majority of empirical time series patterns can be sufficiently approximated using one of the 5 basic models that can be identified based on the shape of the autocorrelogram (acf) and partial auto correlogram (pacf). the following brief summary is

17、 based on practical recommendations of pankratz (1983). also, note that since the number of parameters (to be estimated) is almost never greater than 3 or 4, it is often practical to try alternative models on the same data. one autoregressive (p) parameter: acf - exponential decay; pacf - spike at l

18、ag 1, no correlation for other lags. two autoregressive (p) parameters: acf - a sine-wave shape pattern or a set of exponential decays; pacf - spikes at lags 1 and 2, no correlation for other lags. one moving average (q) parameter: acf - spike at lag 1, no correlation for other lags; pacf - damps ou

19、t exponentially. two moving average (q) parameters: acf - spikes at lags 1 and 2, no correlation for other lags; pacf - a sine-wave shape pattern or a set of exponential decays. one autoregressive (p) and one moving average (q) parameter: acf - exponential decay starting at lag 1; pacf - exponential

20、 decay starting at lag 1. since we believe that the series differenced twice (or after two consecutive differences) is stationary, we observe the acf (see table 3) and pacf (see table 4) to identify the possible model(s) we can try and test.from the acf, ma(3) is identified and ar(2) is identified f

21、rom the pacf (although ar(13) is possible). the model can possibly be arma(3,2). furthermore, the estimation of ma(4) (see table 5) shows that the fourth ma parameter is not significant at all. but the third ma is marginally significant. the estimation of ar(4) (see table 5) shows that the last two

22、ar parameters are not significant. now we can estimate either ar(2) or ma(3). the parameters estimated should be significant and the residuals must be a white noise series to claim the model is adequate. if there are two (or more) competing models, then we may want to investigate their ex post forec

23、ast performance to decide which model is better. once we try arma(2,3) by estimating all three ma parameters (with p=2, q=3), ma parameters are not significant. we end up having ar(2) as the best model (see table 6).now you shall understand that when you write a sas code like this, you have to work

24、back and forth to check which model works and which not, if not, find out where you can improve and come back with the improved one, then run and check again, until you get the model you feel comfortable with. dont be frustrated, remember that is the fun part of modeling in the real life after you g

25、et such a job.part ii: an arch(1) model examplenow, let me briefly introduce the arch(1) technique. we work on the same data set and fit the following “simplistic” model to demonstrate the computation. where dlogpt is the quarterly rate of change in the log of the price level, measured as 100(logpt

26、logpt-1); dlog m1t is the rate of growth of the money stock, measured by m1; and dlogyt is the quarter rate of the growth in the output, measured by gdp. the excess growth of the money stock is measured directly and is included in the regression. the lagged value of the inflation rate (i assume) wil

27、l carry the effects of previous external shocks of the economy. new shocks will be part of the disturbance. i will first give you the sas code, and then use the four-step approach to show you how to complete the analysis. be ready to refer to the sas code, four-step approach, and attached print-outs

28、 back and forth, which is the best way to understand the materials. options obs=137;options errors=2;data temp;infile data.dat firstobs=2;input qtr y m1 p;lagp=lag1(p); /lag( ), a function which takes the previous value of yt, i.e., yt-1. lag1( ), one step back; lag2( ), two step back)dlogp=100*(log

29、(p)-log(lagp); / log(p) create a new variable which is the log of pdlaglogp=lag1(dlogp);lagm1=lag1(m1);dlogm1=100*(log(m1)-log(lagm1);lagy=lag1(y);dlogy=100*(log(y)-log(lagy);dlogm1y=dlogm1-dlogy;dlaglogm1y=lag1(dlogm1y);run;/* step 1 */proc reg data=temp;ols: model dlogp=dlaglogm1y dlaglogp; / “ols

30、:” names the print-out of this partoutput out=tempres r=res; / calls out the residuals of this modelrun;/* step 2 */data temp2;set tempres; / include data in temprers (the residuals) into temp2 data setesqr=res*res; / esqr is the square of the residuallag_esqr=lag1(esqr); run;proc reg data=temp2;sqr

31、_res: model esqr=lag_esqr; run;/* step 3 and 4 */proc print data=temp2; / if you want to know whats in the data set now, use this proc autoreg data=temp2; / proc autoreg and garch=(q=1) below is for arch(1)model dlogp=dlaglogm1y dlaglogp/garch=(q=1); / arch(1)run;here is the four-step procedure to i

32、mplement the simple arch(1) method in sas. ordinary least squares (refer to appendix table 7) regression of squared residual obtained from the about ols regression on a constant and lagged value (appendix table 8)= 0.16402 + 0.12662 on the output, arch0 is the constant term and arch1 is the coefficient of the square of the lagged residual term. the arch(1) model is (table 9)= 0.1665 + 0.1031 the estimated regression now is (table 9) reference:/.statsoft3/textbook/sttimser.htmlw. greene, “econometric analysis”, prentice hall.other useful sources: “l(fā)ittle sas book: a primer”, 2nd ed., i

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論