PROTO EASTER EFFECT

Use this forum to post complete RATS "procedures". Please be sure to include instructions on using the procedure and detailed references where applicable.

PROTO EASTER EFFECT

Postby rmendez » Fri Jan 05, 2007 2:12 pm

Corrections and Improvements Wellcomed

Regards,
Rodolfo

*
* @ProtoEasterEffect(options) start end dummy
*
* EasterEffect generate a monthly dummy with the fraction of
* easter season corresponding to each month. It is intended to
* control by easter effect in the estimation of ARIMA models.
* The code is based on an algorithm proposed by Carl Friedrich Gauss.
* References:
* Wikipedia (http://en.wikipedia.org/wiki/Computus)
*
* Parameters:
*
* dummy = (output) SERIES[REAL] of fractions
* start = (input) beginhing of sample
* end = (input) end of sample
* Options:
* length = easter season's length
*
* Revision Schedule:
* 01/05/2007 Written by Rodolfo Méndez & José Felix Izquierdo, BBVA Research Department
*
*
*
procedure EasterEffect start end dummy
type series *dummy
type integer start end

option real length 10

local rect matrix
local integer a b c d e m n march yearaux year aux startaux endaux
local real z

compute aux = %year(end)-%year(start)+1


dim matrix(aux,2)

ewise matrix(i,j) = 0.0

set series / = %NA
set series start end = 0.0

do year = %year(start),%year(end)
{
compute a = %mod(year,19)
compute b = %mod(year,4)
compute c = %mod(year,7)
compute dvalor = 19*a+24
compute d = %mod(dvalor,30)
compute evalor = 2*b+4*c+6*d+5
compute e = %mod(evalor,7)

compute march = 22+d+e
compute z = march-31.0
compute yearaux = year-%year(start)+1

if (z>0 .and. length-z>0)
{
compute matrix(yearaux,1) = (length-z)/length
compute matrix(yearaux,2) = z/length
}

else if (z>0 .and. length-z<=0)
compute matrix(yearaux,2) = 1.0

else
compute matrix(yearaux,1) = 1.0

}

end


medit(hlabels=||'MARCH','APRIL'||) matrix



compute startaux = start-%month(start)+1
compute endaux = end+(12-%month(end))

set dummy startaux endaux = 0.0
set dummy * startaux-1 = %NA
set dummy endaux+1 * = %NA


compute firstmarch = startaux+2
compute firstapril = startaux+3
compute lastmarch = endaux-9
compute lastapril = endaux-8

compute march = startaux+2-12
compute april = startaux+3-12

do date = 1,%year(end)-%year(start)+1
compute march = march+12
compute april = april+12
set dummy march march = matrix(date,1)
set dummy april april = matrix(date,2)
end



end
"What we cannot speak of we must pass over in silence." Wittgenstein
rmendez
 
Posts: 12
Joined: Wed Nov 08, 2006 3:22 pm
Location: Madrid

Return to RATS Procedures

Who is online

Users browsing this forum: No registered users and 1 guest