On Sat, 12 Dec 2015, Marc O'Callaghan wrote:
My apologies, I did mean February to April and not March to April,
which does
not help.
" [...] works for the March-April selection, it doesn't work for the second
> variant, February-March-April, since that does not have a fixed number of
> observations per year. In the latter case you'd have to drop back to a
> custom frequency-1 time series
>
> setobs 1 1 --special-time-series
>
> after sub-sampling on the months in question, to turn the data
> into what gretl takes to be a time series. "
[...]
You may be interested in knowing I am working on a climatalogy
project, which involves studying recurring meteorological events
over several years. For this I only need the period of year at
which said phenomenon generally occurs, however the data I order
(from Meteoswiss, as it were) is structured in such a way that I
cannot request only the same three-month period over many years -
for one year it works all right, but for more they just send you
the whole yearly series.
Ah, now it's clear where you're coming from -- and you've got me
interested!
I think you best policy, in outline, is:
1) Set up a full-year daily calendar for your data.
2) Import the data using gretl's "join" command. (This assumes the
data are available in comma-separated or another delimited text
format.)
3) Subsample on 90 days per year starting on each February 1. (I
don't suppose you care whether day 90 happens to be called April 31
or May 1.) Then save the reduced dataset.
If you do the above (and therefore end up with a fixed number of
days per year) then you have the choice of treating the data as (a
rather special) time series or as a panel, which might be preferable
for some sorts of analysis.
Here's a toy example using daily maximum temperature data recorded
in Leuchars in Scotland, 2013-2015, courtesy of NOAA. The data file
looks like the following (temperature is in tenths of degrees
Celsius):
date,TMAX
20130101,73
20130105,105
20130108,115
...
It's 7-day per week data, but with irregular missing values. I start
by creating a suitable "blank" dataset:
nulldata 1073 # sufficient number of observations
setobs 7 2013-01-01 # 7-day daily
then do a "join":
join leuchars.csv TMAX --tkey=",%Y%m%d"
To understand the details of "join" you'll have to read the chapter
on "Joining data sources" in the Gretl User's Guide, but basically
this says to import the TMAX variable, matching rows to gretl's
calendar using the first ("date") column, interpreted as YYYYMMDD.
Now, here's the hansl code to get down to 90 days per year:
<hansl>
series year = $obsmajor
series month = $obsminor
series day = $obsmicro
# days in May to January, inclusive
scalar skip = 6*31 + 3*30
# initialize the restriction series
series trimester = 0
i = 1
loop while i <= $nobs --quiet
if month[i] == 2 && day[i] == 1
# mark 90 days from February 1
loop j=1..90 --quiet
trimester[i] = 1
i++
endloop
# for efficiency, skip forward (handling leap years)
i += skip - (day[i]==2)
else
i++
endif
endloop
# restrict to the wanted "trimester"
smpl trimester > 0 --restrict
</hansl>
We can then impose a special time series interpretation, check that
things have gone OK, and save the reduced dataset:
<hansl>
# periodicity 90, starting in 2013
setobs 90 2013.1 --special-time-series
# yrday should run from 1 to 90
series yrday = $obsminor
# do the data look right?
print year month day yrday TMAX --byobs
# if so, save in native format
store trimester.gdt
</hansl>
To treat the dataset as a panel, if you wish:
setobs 90 1.1 --stacked-time-series
Allin Cottrell