Dummies/Cycle Variables for Intraday data
Posted: Wed Mar 10, 2010 12:30 pm
For intraday data, the %PERIOD function returns the period number (based at 1) within the day. This can be used to construct dummies and other variables which are functions of the intraday period alone. Note that this requires the data to be regular enough to use the PPD option for a fixed number of periods per day. The following generates intraday linear and quadratic trends and a series of sine and cosine waves. By defining the latter as a VEC[SERIES], you can include the entire batches in a regression, as shown in the test regression at the end.
n is the number of periods per day; nc is the number of harmonics for the sine and cosine functions.
n is the number of periods per day; nc is the number of harmonics for the sine and cosine functions.
Code: Select all
compute n=60,nc=9
calendar(ppd=n,d) 2010:1:1
all 2010:3:10
*
compute n1 = (n+1)/2.0
compute n2 = (n+1)*(n+2)/6.0
set linear = %period(t)/n1
set quad = %period(t)^2/n2
dec vect[series] sins(nc)
dec vect[series] coss(nc)
do p=1,nc
set sins(p) = sin(2*%pi*p*%period(t)/n)
set coss(p) = cos(2*%pi*p*%period(t)/n)
end do p
*
set test = %ran(1.0)
linreg test
# constant linear quad sins coss