[Gretl-users] change frequency

Sven Schreiber svetosch at gmx.net
Thu Nov 19 04:15:04 EST 2009


Isn't djclose.gdt just a 5-day weekly dataset? I mean, menu Add -> periodic dummies would seem to do the trick -- I suspect there was a misunderstanding about the term "irregular", no?

-sven


-------- Original-Nachricht --------
> Datum: Wed, 18 Nov 2009 22:59:37 -0500 (EST)
> Von: Allin Cottrell <cottrell at wfu.edu>
> An: Gretl list <gretl-users at lists.wfu.edu>
> Betreff: Re: [Gretl-users] change frequency

> 
> On Thu, 19 Nov 2009, yinung at Gmail wrote:
> 
> > How can I generate a Monday dummy if the daily data is on a irregular
> > week base, for example, djclose.gdt?
> 
> You can't expect this to be super-simple, can you?  But here
> goes...
> 
> <script>
> function scalar day_of_week (scalar yr, scalar mo, scalar day)
>     # returns 0 = monday, 1 = Tuesday, ...
>     # See Uspensky and Heaslet, Elementary Number Theory (1939)
> 
>     scalar c, d, i1, i2, i3
> 
>     if (mo < 3)
> 	yr--
> 	mo += 10
>     else
> 	mo -= 2;
>     endif
> 
>     c = yr / 100
>     d = yr % 100
>     i1 = int(floor(2.6 * mo - 0.2) % 7)
>     i2 = int(floor(d / 4.0) % 7)
>     i3 = int(floor(c / 4.0) % 7)
> 
>     return ((day%7)+i1+(d%7)+i2+i3-((2*c)%7))%7
> end function
> 
> open djclose.gdt
> 
> scalar T = $nobs
> scalar yr, mo, day
> string datestr
> series monday = 0
> 
> set messages off
> 
> loop i=1..T -q
>   smpl i i
>   outfile date.txt --write
>   print djclose -o
>   outfile --close
>   string date = $(tail -n+4 date.txt | head -1 | awk '{print $1}')
>   sscanf date, "%d/%d/%d", &yr, &mo, &day
>   printf "yr = %d, mo = %d, day = %d\n", yr, mo, day
>   scalar dow = day_of_week(yr, mo, day)
>   if dow == 0
>      monday[i] = 1
>   endif
> endloop
> 
> smpl --full
> print djclose monday -o
> </script>
> 
> If you're on MS Windows and don't have the basic text-processing
> tools tail, head and awk, go to gnuwin32.sourceforge.net for
> salvation.
> 
> Allin Cottrell
> _______________________________________________
> Gretl-users mailing list
> Gretl-users at lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users


More information about the Gretl-users mailing list