This program estimates the usual (HAT) autocorrelation coefficient (already supported by Eviews) and estimates the autocorrelation using the "STAR" estimator p(tau)*. The only difference with HAT estimator, is that the STAR divides by (T-Tau), the HAT divides by T. Both have the same asympotic propertys, but in finite samples the can differ substantialy.
Code: Select all
'ACF HAT and STAR
'-------------------------------------
!T=50
!M=!T-1 'Maximum orden of autocorrelations, Max=T-1
'-------------------------------------
pagecreate u 1 !T
mode quiet
genr x=nrnd
genr x=x-@mean(x)
stomna(x,xv)
scalar R0=@var(x)
table ACF_table
ACF_table(1,1)="ACF HAT AND STAR"
ACF_table(2,1)="Tau"
ACF_table(2,2)="ACF Hat"
ACF_table(2,3)="ACF STAR"
for !Tau=1 to !M
genr rezago=x(-!Tau)
stomna(rezago,lag)
for !h=1 to !T
if lag(!h)=NA then
statusline ACF: !Tau !h
lag(!h)=0
endif
next
scalar ACF_gorro=((1/!T)*@transpose(xv)*lag)/R0
ACF_table(2+!Tau,1)=!Tau
ACF_table(2+!Tau,2)=ACF_gorro
scalar ACF_estrella=((1/(!T-!Tau))*@transpose(xv)*lag)/R0
ACF_table(2+!Tau,3)=ACF_estrella
next
ACF_table.setformat(b) f.3
ACF_table.setformat(c) f.3
References
Priestley, M. B. (1981). Spectral analysis and time series: probability and mathematical statistics (No. 04; QA280, P7.).