;ex1.pro: ;Procedure: Shows an example of regression routine "ZREGR.PRO". ; The original time series being modeled is cos(2i). ; The regression model includes 6 harmonics, one of them ; is cos(2.05i) which is close to the original time series.' ; This procedure also plots (makes a postscript file) both ; time series. ;To run: ; Save this procedure as ex1.pro, get into IDL and then ; type .r ex1. You will need the IDL procedure ZREGR.PRO ; in your current directory. IERROR=1 N=20 & M=7 T=fltarr(N) & F=fltarr(N,M) TMIN=-1.1 & TMAX=1.1 for i=1,N do begin T(i-1)=cos(2.*i) ; <== Original time series' F(i-1,0)=1.0 F(i-1,1)=cos(2.05*i) F(i-1,2)=sin(0.4*i) F(i-1,3)=cos(0.6*i) F(i-1,4)=sin(0.8*i) F(i-1,5)=cos(0.3*i) F(i-1,6)=sin(0.9*i) endfor ZREGR,IERROR,N,M,T,TMIN,TMAX,F,WK,A,AINV,S,C,RESID,COV print,'i, T(i), T_model(i)' for i=0,N-1 do begin print, i, T(i), T(i)-RESID(i) endfor set_plot,'ps' device,/landscape !p.font=1 !xtitle='Time series index' !ytitle='Time series value' !p.title='Original time series (solid) and model time series (dashed)' plot,T,thick=3,xthick=3,ythick=3,charsize=1.3,xcharsize=1.3,$ ycharsize=1.3,/xs oplot,t-resid,linestyle=1,thick=6 device,/close end