SlideShare a Scribd company logo
BITS: Serie Storiche in Matlab

                      Emmanuele Somma

               Supporto Informatico per l’Area Ricerche
                            Banca d’Italia


                        21 Gennaio 2008




E. Somma (SIA-BdI)           WMBB 2008              21/01/2008   1/96
Piano della presentazione


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   2/96
Le serie storiche in MATLAB


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   3/96
Serie storica Insieme di informazioni omogenee riferite a momenti diversi
              in successione temporale.

                                 t1   v1
                                 t2   v2
                                 .
                                 .    .
                                      .
                                 .    .
                                 tn   vn




          E. Somma (SIA-BdI)    WMBB 2008         21/01/2008                4/96
Serie storica Insieme di osservazioni numeriche riferite a momenti diversi
              in successione temporale periodica.

                                 tp    v1
                                 t2p   v2
                                 .
                                 .     .
                                       .
                                 .     .
                                 tnp   vn




          E. Somma (SIA-BdI)     WMBB 2008         21/01/2008                5/96
L’oggetto timeseries


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   6/96
Un array dei dati



Un array di dati
x = [-0.2   -0.3 13;
     -0.1   -0.4 15;
      NaN    2.8 17;
      0.5   0.3 NaN;
     -0.3   -0.1 15]

Un array casuale di dati
x = rand(4,4);




          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   7/96
Un paio di timeseries
ts_pos = timeseries(x(:,1:2), 1:5, ’name’, ’Position’)
getdatasamplesize(ts_pos)

ts_vel = timeseries(x(:,3), 1:5, ’name’, ’Velocity’);
getdatasamplesize(ts_vel)




        E. Somma (SIA-BdI)   WMBB 2008   21/01/2008      8/96
Altre timeseries
%% Import the sample data
load count.dat

count1 = timeseries(count(:,1), 1:24,’name’, ’intersection1’);
count2 = timeseries(count(:,2), 1:24,’name’, ’intersection2’);
count3 = timeseries(count(:,3), 1:24,’name’, ’intersection3’);

get(count1)




        E. Somma (SIA-BdI)   WMBB 2008   21/01/2008       9/96
Definizione delle unit` di misura
                     a
count1.DataInfo.Units          =   ’cars’;
count1.TimeInfo.Units          =   ’hours’;
count2.TimeInfo.Units          =   ’hours’;
count3.TimeInfo.Units          =   ’hours’;




          E. Somma (SIA-BdI)         WMBB 2008   21/01/2008   10/96
Definizione del metodo d’interpolazione
count1.DataInfo.Interpolation = tsdata.interpolation(’zoh’);
        % zero-order hold




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008     11/96
Aggiunta di eventi
%% Construct and add the first event to all time series
e1 = tsdata.event(’AMCommute’,8);
                     % Construct the first event at 8 AM
e1.Units = ’hours’; % Specify the time units of the time
count1 = addevent(count1,e1); % Add the event to count1
count2 = addevent(count2,e1); % Add the event to count2
count3 = addevent(count3,e1); % Add the event to count3




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008       12/96
Aggiunta di eventi
%% Construct and add the second event to all time series
e2 = tsdata.event(’PMCommute’,18);
                     % Construct the first event at 6 PM
e2.Units = ’hours’; % Specify the time units of the time
count1 = addevent(count1,e2); % Add the event to count1
count2 = addevent(count2,e2); % Add the event to count2
count3 = addevent(count3,e2); % Add the event to count3




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008       13/96
Collezioni di timeseries
tsc = tscollection({count1 count2},’name’, ’count_coll’)

tsc = addts(tsc, count3)

tsc1 = removets(tsc1,’intersection3’)




          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008      14/96
Ricampionamento della collezione
tsc1 = resample(tsc,1:2:24)
tsc1 = resample(tsc,1:0.5:24)
tsc1 = resample(tsc1,tsc1.Time)




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   15/96
Modifica dei contenuti degli elementi della collezione
tsc1 = addsampletocollection(tsc1,’time’,3.25,...
       ’intersection1’,5)

tsc1 = delsamplefromcollection(tsc1,’index’,...
       find(isnan(tsc1.intersection2.Data)));

tsc1 = addsampletocollection(tsc1,’time’,3.25,...
       ’intersection1’,5);




          E. Somma (SIA-BdI)   WMBB 2008       21/01/2008   16/96
Modifica dei contenuti degli elementi della collezione
plot(tsc1.intersection1); hold on;
plot(tsc1.intersection2)




          E. Somma (SIA-BdI)   WMBB 2008       21/01/2008   17/96
E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   18/96
L’oggetto fints


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   19/96
Creazione fints
dates = (datenum(’05/11/99’):datenum(’05/11/99’)+100)’;
data_series1 = exp(randn(1, 101))’;
data_series2 = exp(randn(1, 101))’;
data = [data_series1 data_series2];
myfts = fints(dates, data);
myfts
myfts =
 desc: (none)
 freq: Unknown (0)
 ’dates: (101)’     ’series1: (101)’     ’series2: (101)’
 ’11-May-1999’      [         0.6488]    [         0.1105]
 ’12-May-1999’      [         0.1891]    [         2.6814]
 ’13-May-1999’      [         1.1335]    [         0.5953]
 [...]


         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008     20/96
Trasformazione
srs2 = myfts.series2

srs2_vec = fts2mat(myfts.series2)

format long g

srs2_mtx = fts2mat(myfts.series2, 1)




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   21/96
Indicizzazione elementi
format short
myfts(’05/11/99’)
myfts.series2(’05/11/99’)
myfts.series2({’05/11/99’, ’05/21/99’, ’05/31/99’})
myfts (’05/11/99::05/15/99’)
myfts.series2(1)
myfts.series2([1, 3, 5])
myfts.series2(16:20)




          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   22/96
Operazioni
addup        =   myfts1       +   newfts
subout       =   myfts1       -   newfts
addscalar    =   myfts1       +   10000
submtx       =   myfts1       -   randn(20, 4)




         E. Somma (SIA-BdI)            WMBB 2008   21/01/2008   23/96
Operazioni
newfts2   = fints(myfts1.dates, fts2mat(myfts1/10000),...
            {’Rat1’,’Rat2’, ’Rat3’,’Rat4’}, 1, ’New FTS’)

addother = myfts1 + fts2mat(newfts2);




          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008       24/96
BITS - Bank of Italy Time Series


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   25/96
L’oggetto tsmat


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   26/96
Costruzione tsmat
TSMAT = tsmat(1980,1,12,count)
tsmat( macro index (year), micro index (period), frequency, d

Parametri
    macro index            double (used as integer)
    micro index            double (used as integer)
    frequency              numero di elementi in      una     divisione   macro
                             1    Year
                             2    Semester
                             4    Quarter
                             12 Month
                             52 Week
                            365 Day
    data matrix            NOBS×NSERIES
                           SERIES colonne
                           OSSERV righe

            E. Somma (SIA-BdI)       WMBB 2008        21/01/2008              27/96
Esempio
 A = tsmat(1980,1,12,rand(20,1))
 Tsmat object
     Size: [20   1]
Frequency: 12
    Start: 1980     1
      End: 1981     8
   Labels: T1

  B = tsmat(1980,1,12,rand(20,1))

 BG = tsmat(1980,1,365,rand(220,1))
Tsmat object
      Size: [220    1]
 Frequency: 365
     Start: Tue Jan-01-1980
       End: Thu Aug-07-1980
    Labels: T1
          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   28/96
Caricamento dati
load count.dat
TSC = tsmat(1980,1,365,count)
Tsmat object
      Size: [24   3]
 Frequency: 365
     Start: Tue Jan-01-1980
       End: Thu Jan-24-1980
    Labels: T1 T2 T3




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   29/96
Struttura
struct(TSC)
ans =
         matdata:            [24x3 double]
      start_year:            1980
    start_period:            1
            freq:            365
       last_year:            1980
     last_period:            24
            meta:            [1x1 struct]
       meta_cols:            [1x1 struct]




            E. Somma (SIA-BdI)       WMBB 2008   21/01/2008   30/96
I Valori
TSC.matdata
ans =
    11    11            9
     7    13           11
    14    17           20
    11    13            9
    43    51           69
    38    46           76
    61   132          186
    [...]




           E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   31/96
I metadati di base
    .freq                      frequenza delle osservazioni
    .start                     indice dell’oss. iniziale (anno,periodo)
    .start year                anno dell’oss. iniziale
    .start period              periodo dell’oss. iniziale
    .last                      indice dell’oss. finale (calcolato)
    .last year                 anno dell’oss. finale (calcolato)
    .last period               periodo dell’oss. finale (calcolato)
    .range                     vettore degli indici iniziale e finale
    .dates                     vettore delle date in formato num. Matlab
    .matdata                   matrice dei valori della collezione

Ad es.
datestr(TSC.dates)
ans =
01-Jan-1980
02-Jan-1980
03-Jan-1980
[...]
          E. Somma (SIA-BdI)            WMBB 2008        21/01/2008        32/96
I metadati ’estesi’
    .meta              metadati della collezione
    .meta cols         metadati delle colonne

I metadati di colonna obbligatori
    ’label’       nome della serie

Ad es.
TSC.meta
ans =
    release: 733425
TSC.meta_cols
ans =
    label: {’T1’ ’T2’          ’T3’}




          E. Somma (SIA-BdI)           WMBB 2008   21/01/2008   33/96
Visualizzare una serie con tstab
tstab(S1 [, S2 ...]) dove S1,...,S2 sono oggetti tsmat
A=tsmat(1980,1,12,rand(5,1))
B=tsmat(1980,3,12,rand(5,1))
tstab(A,B)
tsStart: 1980     1
tsRelease: 18-Jan-2008
Frequency: 12 (monthly)
Date
                       T1          T1
                 18/01/08    18/01/08
1980-M-001         0.0377         NaN
1980-M-002         0.8852         NaN
1980-M-003         0.9133      0.2619
1980-M-004         0.7962      0.3354
1980-M-005         0.0987      0.6797
1980-M-006            NaN      0.1366
1980-M-007            NaN      0.7212
         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008     34/96
Creazione della tsmat


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   35/96
tsmat: Come si usa
>>




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   36/96
tsmat: Come si usa
>> ts = tsmat(1980,1,12,rand(3,4))




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   36/96
tsmat: Come si usa
>> ts = tsmat(1980,1,12,rand(3,4))
Tsmat object
      Size: [3 4]
     Start: 1980     1
       End: 1980     3
    Labels: T1 T2 T3 T4
>>




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   36/96
tsmat: Come si usa
>> ts = tsmat(1980,1,12,rand(3,4))
Tsmat object
      Size: [3 4]
     Start: 1980     1
       End: 1980     3
    Labels: T1 T2 T3 T4
>> get(ts)




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   36/96
tsmat: Come si usa
>> ts = tsmat(1980,1,12,rand(3,4))
Tsmat object
      Size: [3 4]
     Start: 1980     1
       End: 1980     3
    Labels: T1 T2 T3 T4
>> get(ts)
         matdata: [3x4 double]
      start_year: 1980
    start_period: 1
            freq: 12
       last_year: 1980
     last_period: 3
            meta: [1x1 struct]
       meta_cols: [1x1 struct]



         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   36/96
tsmat: Come si usa
>>




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   37/96
tsmat: Come si usa
>> tstab(ts)




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   37/96
tsmat: Come si usa
>> tstab(ts)
tsStart: 1980     1
tsRelease: 17-Jul-2007
Frequency: 12 (monthly)
Date
                        T1          T2          T3              T4
                 17/07/07     17/07/07    17/07/07        17/07/07
1980-M-001          0.6822      0.1509      0.8600          0.4966
1980-M-002          0.3028      0.6979      0.8537          0.8998
1980-M-003          0.5417      0.3784      0.5936          0.8216




         E. Somma (SIA-BdI)   WMBB 2008      21/01/2008              37/96
tsmat: Come si usa
>> tstab(ts)
tsStart: 1980     1
tsRelease: 17-Jul-2007
Frequency: 12 (monthly)
Date                                      LABELS
                       T1           T2           T3               T4
                 17/07/07     17/07/07     17/07/07         17/07/07
1980-M-001         0.6822       0.1509       0.8600           0.4966
1980-M-002         0.3028       0.6979       0.8537           0.8998
1980-M-003         0.5417       0.3784       0.5936           0.8216




         E. Somma (SIA-BdI)   WMBB 2008        21/01/2008              37/96
tsmat: Come si usa
>> tstab(ts)
tsStart: 1980     1
tsRelease: 17-Jul-2007                    RELEASES
Frequency: 12 (monthly)
Date
                        T1          T2            T3               T4
                 17/07/07     17/07/07      17/07/07         17/07/07
1980-M-001          0.6822      0.1509        0.8600           0.4966
1980-M-002          0.3028      0.6979        0.8537           0.8998
1980-M-003          0.5417      0.3784        0.5936           0.8216




         E. Somma (SIA-BdI)   WMBB 2008         21/01/2008              37/96
tsmat Etichette di colonna
ts = tsmat(1980,1,12,rand(3,4), ...
             {’PRICE’, ’STOCK’, ’EXCHANGE’, ’UNIT’});

tstab(ts)
tsStart: 1980     1
tsRelease: 18-Jul-2007
Frequency: 12 (monthly)
Date
                     PRICE       STOCK    EXCHANGE            UNIT
                 18/07/07     18/07/07    18/07/07        18/07/07
1980-M-001          0.0495      0.5221      0.3751          0.5979
1980-M-002          0.5667      0.1171      0.8234          0.9492
1980-M-003          0.1219      0.7699      0.0466          0.2888




         E. Somma (SIA-BdI)   WMBB 2008      21/01/2008              38/96
tsmat Etichette di colonna automatiche
ts = tsmat(1980,1,12,rand(3,4),’PRICE’);


tstab(ts)
tsStart: 1980     1
tsRelease: 18-Jul-2007
Frequency: 12 (monthly)
Date
                   PRICE1       PRICE2       PRICE3          PRICE4
                 18/07/07     18/07/07     18/07/07        18/07/07
1980-M-001          0.8702      0.1923       0.9339          0.8952
1980-M-002          0.0269      0.7157       0.1372          0.9424
1980-M-003          0.5195      0.2507       0.5216          0.3351




         E. Somma (SIA-BdI)   WMBB 2008       21/01/2008              39/96
tsmat Rilasci di colonna
ts = tsmat(1980,1,12,rand(3,4),’PRICE’, ...
       { ’01-Jan-2007’ ’02-Jan-2007’ ’07-Jan-2007’ ’09-Jan-2007’ });

tstab(ts)
tsStart: 1980     1
Frequency: 12 (monthly)
Date
                   PRICE1       PRICE2      PRICE3          PRICE4
                 01/01/07     02/01/07    07/01/07        09/01/07
1980-M-001          0.5962      0.5972      0.9561          0.8121
1980-M-002          0.3290      0.1614      0.5955          0.6101
1980-M-003          0.4782      0.8295      0.0287          0.7015




         E. Somma (SIA-BdI)   WMBB 2008      21/01/2008              40/96
tsmat Distribuzione dei rilasci su tutte le colonne
ts = tsmat(1980,1,12,rand(3,4), ...
          {’PRICE’, ’STOCK’, ’EXCHANGE’, ’UNIT’}, ...
          ’01-Jan-2002’ );
tstab(ts)
tsStart: 1980     1
tsRelease: 18-Jul-2007
Frequency: 12 (monthly)
Date
                     PRICE      STOCK    EXCHANGE        UNIT
                 01/01/02    01/01/02    01/01/02    01/01/02
1980-M-001          0.4374     0.1359      0.3987      0.8686
1980-M-002          0.4712     0.5325      0.3584      0.6264
1980-M-003          0.1493     0.7258      0.2853      0.2412




          E. Somma (SIA-BdI)   WMBB 2008        21/01/2008      41/96
Indicizzazione per l’accesso


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   42/96
Indicizzazione
    Metadati fondamentali tramite ’.’ (es. TSC.start)
    Osservazione tramite ’()’ (es. TSC([2:5, [1:end])
    Lead/Lag tramite ’{}’ (es. TSC{-1})




          E. Somma (SIA-BdI)   WMBB 2008        21/01/2008   43/96
Accesso ai metadati: ’.’
     .freq                    frequenza delle osservazioni
     .start                   indice dell’oss. iniziale (anno,periodo)
     .start year              anno dell’oss. iniziale
     .start period            periodo dell’oss. iniziale
     .last                    indice dell’oss. finale (calcolato)
     .last year               anno dell’oss. finale (calcolato)
     .last period             periodo dell’oss. finale (calcolato)
     .range                   vettore degli indici iniziale e finale
     .dates                   vettore delle date in formato num. Matlab
     .matdata                 matrice dei valori della collezione
     .meta                    dizionario dei metadati di collezione
     .meta cols               dizionari dei metadati di colonna

Ad es.
datestr(TSC.dates)
ans =
01-Jan-1980
02-Jan-1980
03-Jan-1980 Somma (SIA-BdI)
          E.                           WMBB 2008        21/01/2008        44/96
Accesso alle osservazioni: ’()’
   Doppio vettore di interi (2 elementi)
           righe        colonne
       osservazioni       serie
 TSC(    [2:5],        [1:end])
tsStart: 1980     2
tsRelease: 19-Jan-2008
Frequency: 365 (daily)
Date
                                        T1              T2            T3
                                  19/01/08        19/01/08      19/01/08
1980-D-002   02-Jan-1980            7.0000         13.0000       11.0000
1980-D-003   02-Jan-1980           14.0000         17.0000       20.0000
1980-D-004   02-Jan-1980           11.0000         13.0000        9.0000
1980-D-005   02-Jan-1980           43.0000         51.0000       69.0000




             E. Somma (SIA-BdI)       WMBB 2008              21/01/2008    45/96
Esempio: Una osservazione di tutte le serie nella collezione
                righe            colonne
             osservazioni         serie
    TSC(          1,            [1:end])
tstab(TSC1)
tsStart: 1980     1
tsRelease: 19-Jan-2008
Frequency: 365 (daily)
Date
                                       T1              T2            T3
                                 19/01/08        19/01/08      19/01/08
1980-D-001 01-Jan-1980            11.0000         11.0000        9.0000




           E. Somma (SIA-BdI)        WMBB 2008              21/01/2008    46/96
Esempio: Tutte le osservazioni di una serie della collezione
                  righe           colonne
               osservazioni        serie
    TSC(        [1:end],            2)
tstab(TSC1)
tsStart: 1980     1
tsRelease: 19-Jan-2008
Frequency: 365 (daily)
Date
                                         T1
                                   19/01/08
1980-D-001   01-Jan-1980            11.0000
1980-D-002   01-Jan-1980             7.0000
1980-D-003   01-Jan-1980            14.0000
1980-D-004   01-Jan-1980            11.0000
[...]
1980-D-021   01-Jan-1980            35.0000
1980-D-022   01-Jan-1980            11.0000
1980-D-023   01-Jan-1980            13.0000
1980-D-024   01-Jan-1980            10.0000

             E. Somma (SIA-BdI)        WMBB 2008   21/01/2008   47/96
Accesso alle osservazioni: ’()’
   Quattro Interi e un indice (5 elementi)
        anno periodo anno periodo                      colonne
             iniziale             finale
 TSC( 1986,          1,     1996,       1,              ’:’)
 TSC( 1986,          1,     1996,       1,             [2 3])
tsStart: 1980     2
tsRelease: 19-Jan-2008
Frequency: 365 (daily)
Date
                                        T1              T2            T3
                                  19/01/08        19/01/08      19/01/08
1980-D-002   02-Jan-1980            7.0000         13.0000       11.0000
1980-D-003   02-Jan-1980           14.0000         17.0000       20.0000
1980-D-004   02-Jan-1980           11.0000         13.0000        9.0000
1980-D-005   02-Jan-1980           43.0000         51.0000       69.0000



             E. Somma (SIA-BdI)       WMBB 2008              21/01/2008    48/96
Operazione di Lead e Lag: ’{}’
TSC = tsmat(1980,1,365,count(:,1))
tstab(TSC1,TSC1{-1},TSC1{1})
   % == tstab(TSC,tslag(TSC,1),tslag(TSC,-1))
tsStart: 1979   365
tsRelease: 18-Jan-2008
Frequency: 365 (daily)
Date                              T1          T1             T1
                            18/01/08    18/01/08       18/01/08
1979-D-365 31-Dec-1979           NaN         NaN        11.0000
1980-D-001 31-Dec-1979       11.0000         NaN         7.0000
1980-D-002 31-Dec-1979        7.0000     11.0000        14.0000
[...]
1980-D-023 31-Dec-1979       13.0000     11.0000        10.0000
1980-D-024 31-Dec-1979       10.0000     13.0000            NaN
1980-D-025 31-Dec-1979           NaN     10.0000            NaN

         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008        49/96
Riorganizzazione


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   50/96
Concatenazione orizzontale
aa=tsmat(1980,1,4,reshape(-1:-1:-16,4,4))
Tsmat object
       Size: [4 4]
 Frequency: 4
      Start: 1980     1
        End: 1980     4
     Labels: T1 T2 T3 T4
tstab(aa)
tsStart: 1980      1
tsRelease: 19-Jan-2008
Frequency: 4 (quarterly)
Date
                         T1        T2          T3              T4
                  19/01/08   19/01/08    19/01/08        19/01/08
1980-Q-001         -1.0000    -5.0000     -9.0000        -13.0000
1980-Q-002         -2.0000    -6.0000    -10.0000        -14.0000
1980-Q-003         -3.0000    -7.0000    -11.0000        -15.0000
1980-Q-004         -4.0000    -8.0000    -12.0000        -16.0000



          E. Somma (SIA-BdI)    WMBB 2008           21/01/2008      51/96
Concatenazione orizzontale
bb=tsmat(1979,1,4,reshape(1:16,4,4))
Tsmat object
       Size: [4 4]
 Frequency: 4
      Start: 1979      1
        End: 1979      4
     Labels: T1 T2 T3 T4
tstab(bb)
tsStart: 1979      1
tsRelease: 19-Jan-2008
Frequency: 4 (quarterly)
Date
                         T1        T2             T3              T4
                  19/01/08   19/01/08       19/01/08        19/01/08
1979-Q-001           1.0000    5.0000         9.0000         13.0000
1979-Q-002           2.0000    6.0000        10.0000         14.0000
1979-Q-003           3.0000    7.0000        11.0000         15.0000
1979-Q-004           4.0000    8.0000        12.0000         16.0000



          E. Somma (SIA-BdI)    WMBB 2008              21/01/2008      52/96
Concatenazione orizzontale
cc=[aa,bb]
Tsmat object
       Size: [8 8]
 Frequency: 4
      Start: 1979     1
        End: 1980     4
     Labels: T1 T2 T3 T4 T1 T2 T3 T4
tstab(cc)
tsStart: 1979      1
tsRelease: 19-Jan-2008
Frequency: 4 (quarterly)
Date
                        T1           T2      [...]         T3           T4
                  19/01/08    19/01/08       [...]   19/01/08     19/01/08
1979-Q-001             NaN         NaN       [...]     9.0000      13.0000
1979-Q-002             NaN         NaN       [...]    10.0000      14.0000
1979-Q-003             NaN         NaN       [...]    11.0000      15.0000
1979-Q-004             NaN         NaN       [...]    12.0000      16.0000
1980-Q-001         -1.0000     -5.0000       [...]        NaN          NaN
1980-Q-002         -2.0000     -6.0000       [...]        NaN          NaN
1980-Q-003         -3.0000     -7.0000       [...]        NaN          NaN
1980-Q-004         -4.0000     -8.0000       [...]        NaN          NaN
           E. Somma (SIA-BdI)    WMBB 2008           21/01/2008              53/96
Concatenazione verticale
cc=[aa;bb]
Tsmat object
       Size: [8 4]
 Frequency: 4
      Start: 1979      1
        End: 1980      4
     Labels: T1 T2 T3 T4
tstab(cc)
tsStart: 1979      1
tsRelease: 19-Jan-2008
Frequency: 4 (quarterly)
Date
                         T1           T2             T3              T4
                  19/01/08      19/01/08       19/01/08        19/01/08
1979-Q-001           1.0000       5.0000         9.0000         13.0000
1979-Q-002           2.0000       6.0000        10.0000         14.0000
1979-Q-003           3.0000       7.0000        11.0000         15.0000
1979-Q-004           4.0000       8.0000        12.0000         16.0000
1980-Q-001         -1.0000       -5.0000        -9.0000        -13.0000
1980-Q-002         -2.0000       -6.0000       -10.0000        -14.0000
1980-Q-003         -3.0000       -7.0000       -11.0000        -15.0000
1980-Q-004         -4.0000       -8.0000       -12.0000        -16.0000
           E. Somma (SIA-BdI)      WMBB 2008              21/01/2008      54/96
Concatenazione verticale
cc=[aa{-2};bb]
Tsmat object
       Size: [8 4]
 Frequency: 4
      Start: 1979      1
        End: 1980      4
     Labels: T1 T2 T3 T4
tstab(cc)
tsStart: 1979      1
tsRelease: 19-Jan-2008
Frequency: 4 (quarterly)
Date
                         T1           T2             T3              T4
                  19/01/08      19/01/08       19/01/08        19/01/08
1979-Q-001           1.0000       5.0000         9.0000         13.0000
1979-Q-002           2.0000       6.0000        10.0000         14.0000
1979-Q-003           3.0000       7.0000        11.0000         15.0000
1979-Q-004           4.0000       8.0000        12.0000         16.0000
1980-Q-001              NaN          NaN            NaN             NaN
1980-Q-002              NaN          NaN            NaN             NaN
1980-Q-003         -1.0000       -5.0000        -9.0000        -13.0000
1980-Q-004         -2.0000       -6.0000       -10.0000        -14.0000
           E. Somma (SIA-BdI)      WMBB 2008              21/01/2008      55/96
Concatenazione verticale non adiacente
cc=[aa;bb{-1}]
??? Error using ==> tsmat.extend
"FillDateBeforeLastDate"

Error in ==> <a href="error:/Users/exedre/Work/Matlab/bi/toolboxes/bits2/@t
    self = extend(a, self, [ a.start_year a.start_period ], fill_date);

Error in ==> <a href="error:/Users/exedre/Work/Matlab/bi/toolboxes/bits2/@t
        res = extend(res,varargin{i},nan,true);




          E. Somma (SIA-BdI)       WMBB 2008     21/01/2008           56/96
extend Unione delle serie cn il controllo della sovrapposizione
>> ts1 = tsmat(1980,1,12,rand(7,1));
>> ts2 = tsmat(1980,6,12,rand(4,1));
>> ts=extend(ts1,ts2)
>> tstab(ts,ts1,ts2)
[...]                  T1          T1             T1
                 05/09/07    05/09/07       05/09/07
1980-M-001         0.4457      0.4457            NaN
1980-M-002         0.9388      0.9388            NaN
1980-M-003         0.6338      0.6338            NaN
1980-M-004         0.9297      0.9297            NaN
1980-M-005         0.0629      0.0629            NaN
1980-M-006         0.0104      0.3069         0.0104
1980-M-007         0.1678      0.9498         0.1678
1980-M-008         0.7553         NaN         0.7553
1980-M-009         0.8338         NaN         0.8338




          E. Somma (SIA-BdI)    WMBB 2008              21/01/2008   57/96
extend Unione delle serie cn il controllo della sovrapposizione
>> ts=extend(ts1,ts2,[1980 7])
>> tstab(ts,ts1,ts2)
[...]                  T1          T1             T1
                 05/09/07    05/09/07       05/09/07
1980-M-001         0.4457      0.4457            NaN
1980-M-002         0.9388      0.9388            NaN
1980-M-003         0.6338      0.6338            NaN
1980-M-004         0.9297      0.9297            NaN
1980-M-005         0.0629      0.0629            NaN
1980-M-006         0.3069      0.3069         0.0104
1980-M-007         0.1678      0.9498         0.1678
1980-M-008         0.7553         NaN         0.7553
1980-M-009         0.8338         NaN         0.8338




          E. Somma (SIA-BdI)    WMBB 2008              21/01/2008   58/96
extend Unione di serie non contigue
>> ts1=tsmat(1980,1,12,rand(5,1))
>> ts2=tsmat(1980,7,12,rand(5,1));
[...]                  T1          T1
1980-M-001         0.6059         NaN
1980-M-002         0.5179         NaN
1980-M-003         0.9429         NaN
1980-M-004         0.7412         NaN
1980-M-005         0.7011         NaN
1980-M-006            NaN         NaN
1980-M-007            NaN      0.7447
1980-M-008            NaN      0.8738
1980-M-009            NaN      0.9641
1980-M-010            NaN      0.9819
1980-M-011            NaN      0.9186




          E. Somma (SIA-BdI)    WMBB 2008   21/01/2008   59/96
extend Unione di serie non contigue
>> ts1=tsmat(1980,1,12,rand(5,1))
>> ts2=tsmat(1980,7,12,rand(5,1));
[...]                  T1          T1
1980-M-001         0.6059         NaN
1980-M-002         0.5179         NaN
1980-M-003         0.9429         NaN
1980-M-004         0.7412         NaN
1980-M-005         0.7011         NaN
1980-M-006            NaN         NaN
1980-M-007            NaN      0.7447
1980-M-008            NaN      0.8738
1980-M-009            NaN      0.9641
1980-M-010            NaN      0.9819
1980-M-011            NaN      0.9186
>> ts=extend(ts1,ts2)
??? Error using ==> tsmat.extend at 130
"TimeseriesCannotBeLinked"



          E. Somma (SIA-BdI)    WMBB 2008   21/01/2008   59/96
extend Unione serie non contigue
>> ts=extend(ts1,ts2,nan,true)
                       T1          T1             T1
                 05/09/07    05/09/07       05/09/07
1980-M-001         0.6059      0.6059            NaN
1980-M-002         0.5179      0.5179            NaN
1980-M-003         0.9429      0.9429            NaN
1980-M-004         0.7412      0.7412            NaN
1980-M-005         0.7011      0.7011            NaN
1980-M-006            NaN         NaN            NaN
1980-M-007         0.7447         NaN         0.7447
1980-M-008         0.8738         NaN         0.8738
1980-M-009         0.9641         NaN         0.9641
1980-M-010         0.9819         NaN         0.9819
1980-M-011         0.9186         NaN         0.9186




          E. Somma (SIA-BdI)    WMBB 2008              21/01/2008   60/96
Operazioni tra le tsmat


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   61/96
La differenza tra struttura e oggetto
    Struttura                 Oggetto
    s = struct()              o = class()        Creazione
    s.propriet´
              a               o.propriet´
                                        a        Accesso
    s.campo = valore          o.campo = valore   Riempimento
    funzione(s)               metodo(o)          Funzione/Metodo
    s.dati = m.dati +         n.dati             Operazioni tra strutture
                              s = m + n          Operazioni tra oggetti




         E. Somma (SIA-BdI)       WMBB 2008      21/01/2008            62/96
Operazioni sulle serie (senza esclusione dei nan)
   max(A)
   min(A)
   mean(A)
   median(A)
   std(A)
   sum(A)
   var(A)
   abs(A)
   ceil(A)
   TODO: iqr(A)




          E. Somma (SIA-BdI)   WMBB 2008        21/01/2008   63/96
Operazioni sulle serie con esclusione dei nan
   nanmax(A)
   nanmin(A)
   nanmean(A)
   nanmedian(A)
   nanstd(A)
   nansum(A)
   nanva(A)




          E. Somma (SIA-BdI)   WMBB 2008        21/01/2008   64/96
Operazioni tra le serie
 tstab(A,B,     A*10)
 tstab(A,B,     A+B)
 tstab(A,B,     A-B)
 tstab(A,B,     A*B)
 tstab(A,B,     A./B)




          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   65/96
Altre operazioni
corr(TSC)
corr(TSC.matdata)
corr(count(:,1),count(:,2))
ans =
    0.9331
corr(TSC(:,1),TSC(:,2))
??? Error using ==> tsmat.subsref
@tsmatsubsref::TS Index exceeds matrix dimensions




          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   66/96
Altre operazioni
cov(TSC)
cov(TSC.matdata)
ans =
  1.0e+003 *
    0.6437    0.9802           1.6567
    0.9802    1.7144           2.6908
    1.6567    2.6908           4.6278




          E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   67/96
Altre operazioni
tstab(TSC,cumsum(TSC))
tstab(cumprod(TSC))




          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   68/96
Operazioni logiche
tstab(TSC==TSC)
tsStart: 1980     1
tsRelease: 18-Jan-2008
Frequency: 365 (daily)
Date
                                      T1         T2           T3
                                18/01/08   18/01/08     18/01/08
1980-D-001 01-Jan-1980            1.0000     1.0000       1.0000
1980-D-002 01-Jan-1980            1.0000     1.0000       1.0000
1980-D-003 01-Jan-1980            1.0000     1.0000       1.0000
[...]




         E. Somma (SIA-BdI)   WMBB 2008    21/01/2008        69/96
Operazioni logiche
TSC1 = tsmat(1980,1,365,rand(24,3)*10*)
tstab(TSC>TSC1) (tstab(ge(TSC,TSC1))
tsStart: 1980     1
tsRelease: 18-Jan-2008
Frequency: 365 (daily)
Date
                                  T1          T2             T3
                            18/01/08    18/01/08       18/01/08
1980-D-001 01-Jan-1980        0.0000      0.0000         0.0000
1980-D-002 01-Jan-1980        0.0000      0.0000         0.0000
1980-D-003 01-Jan-1980        0.0000      0.0000         1.0000
1980-D-004 01-Jan-1980        0.0000      0.0000         0.0000
[...]



         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008        70/96
Operazioni e Funzioni
    Operazione        F unzione
    gt(A,B)           A>B
    ge(A,B)           A≥B
    lt(A,B)           A<B
    le(A,B)           A≤B
    ne(A,B)           A=B




         E. Somma (SIA-BdI)       WMBB 2008   21/01/2008   71/96
Determinazione dei valori
    Operazione         F unzione
    isnan              = NaN
    isfinite           =∞




          E. Somma (SIA-BdI)       WMBB 2008   21/01/2008   72/96
Introduciamo dei missing in testa e in coda
TSC([1:3],[1:3])=NaN; tstab(TSC)
TSC([24],[1:3])=NaN; tstab(TSC)

Stringiamo l’intervallo di definizione della serie ai valori non missing
TSCn=notnanrange(TSC)




          E. Somma (SIA-BdI)    WMBB 2008         21/01/2008              73/96
Lag e Lead
TSC = tsmat(1980,1,365,count(:,1))
tstab(TSC,tslag(TSC,1),tslag(TSC,-1))
tsStart: 1979   365
tsRelease: 18-Jan-2008
Frequency: 365 (daily)
Date
                                  T1            T1           T1
                            18/01/08      18/01/08     18/01/08
1979-D-365 31-Dec-1979           NaN           NaN      11.0000
1980-D-001 31-Dec-1979       11.0000           NaN       7.0000
1980-D-002 31-Dec-1979        7.0000       11.0000      14.0000
[...]
1980-D-023 31-Dec-1979       13.0000       11.0000      10.0000
1980-D-024 31-Dec-1979       10.0000       13.0000          NaN
1980-D-025 31-Dec-1979           NaN       10.0000          NaN


         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008        74/96
Gestione dei Metadati


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   75/96
Metadati della collezione
ts.meta.<campo>
getmeta(ts,’<campo>’)
getmeta(ts,’<campo>’,<default>)

rel = getmeta(ts,’release’,today)
rel =

       733426




          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   76/96
Metadati della collezione
A.meta.pippo=’pluto1’;
pluto=A.meta.pippo;
A.meta
ans =
    release: 733426
      pippo: ’pluto1’

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

A=addmeta(A,’pippo’,’pluto2’);
A.meta
ans =
    release: 733426
      pippo: ’pluto2’


          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008    77/96
Un metadato notevole: release
   Il metadato release indica la data in cui la serie `  e
   presa in considerazione (?!?)
   Non viene utilizzata in alcun modo nei calcoli ma `   e
   molto importante nelle operazioni di vintage dei dati
   La release della singola serie (ovvero
   ts.meta colsj.release), se presente, verr`        a
   utilizzata per indicare il vintage dei dati, altrimenti si
   utilizzera la release dell’intera collezione
   (ts.meta.release), nel caso in cui non sia presente
   neppure questo (errore) si utilizzer` la data corrente.
                                        a


        E. Somma (SIA-BdI)   WMBB 2008    21/01/2008        78/96
Esempio
A.meta.release
ans =
      733426
>> datestr(A.meta.release)
ans =
19-Jan-2008




          E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   79/96
Cancellare un metadato
rmfield(A.meta,’pippo’)                   % NON HA EFFETTO

A.meta = rmfield(A.meta,’pippo’) % CORRETTO

     oppure

A=delmeta(A,’pippo’)




         E. Somma (SIA-BdI)   WMBB 2008          21/01/2008   80/96
Metadati di colonna
TSC.meta_cols
ans =
    label: {’T1’           ’T2’   ’T3’}

Metadati di colonna
    I metadati di colonna sono ospitati in una struttura i cui campi sono
cell-array.
     `
    E uno strumento del linguaggio Matlab un po’ contorto a cui bisogna
fare attenzione e che provoca un bel po’ di problemi.




          E. Somma (SIA-BdI)        WMBB 2008     21/01/2008            81/96
Metadati di colonna
TSC.meta_cols.release(2) # NON FUNZIONA

M = TSC.meta_cols                     # BISOGNA FARE COSI’
label = M.labels(2)




         E. Somma (SIA-BdI)   WMBB 2008       21/01/2008     82/96
Metadati di colonna
getcolmeta(TSC,2,’label’)
ans =
    ’T2’
getcolmeta(TSC,2,’release’,today)
ans =
      733426




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   83/96
Metadati di colonna
getcolmeta(TSC,2,’label’)
ans =
    ’T2’
getcolmeta(TSC,2,’release’,today)
ans =
      733426
FCM = getfullcolmeta(TSC)
1x3 struct array with fields:
    label
FCM(1).label
ans =
    ’T1’




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   84/96
Metadati di colonna
getcolmeta(TSC,2,’label’)
ans =
    ’T2’
getcolmeta(TSC,2,’release’,today)
ans =
      733426
FCM = getfullcolmeta(TSC)
1x3 struct array with fields:
    label
FCM(1).label
ans =
    ’T1’




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   85/96
Metadati di colonna
getcolmeta(TSC,2,’label’)
ans =
    ’T2’
getcolmeta(TSC,2,’release’,today)
ans =
      733426
FCM = getfullcolmeta(TSC)
1x3 struct array with fields:
    label
FCM(1).label
ans =
    ’T1’




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   86/96
Metadati di colonna
TSC=addmeta_cols(TSC, 3, ’release’, {today })




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   87/96
Plot


1   Le serie storiche in MATLAB
      L’oggetto timeseries
      L’oggetto fints

2   BITS - Bank of Italy Time Series
      L’oggetto tsmat
      Creazione della tsmat
      Indicizzazione per l’accesso
      Riorganizzazione
      Operazioni tra le tsmat
      Gestione dei Metadati
      Plot



           E. Somma (SIA-BdI)     WMBB 2008   21/01/2008   88/96
Esempio di plot
aa=tsmat(1980,1,12,randn(120,1));
bb=filter(1,[1 -0.9],aa);
h=plot([aa,bb]);
legend(’aa tsmat’,’filtered tsmat bb’);
% Let’s add a moving average of the bb tsmat
cc=mave(bb,12);
plot([aa,bb,cc]);
legend(’aa tsmat’,’filtered tsmat bb’,’12 terms moving average




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008     89/96
Esempio di plot




         E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   90/96
Grazie dell’attenzione




E. Somma (SIA-BdI)   WMBB 2008   21/01/2008   91/96

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Workshop Matlab BITS Base

  • 1. BITS: Serie Storiche in Matlab Emmanuele Somma Supporto Informatico per l’Area Ricerche Banca d’Italia 21 Gennaio 2008 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 1/96
  • 2. Piano della presentazione 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 2/96
  • 3. Le serie storiche in MATLAB 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 3/96
  • 4. Serie storica Insieme di informazioni omogenee riferite a momenti diversi in successione temporale. t1 v1 t2 v2 . . . . . . tn vn E. Somma (SIA-BdI) WMBB 2008 21/01/2008 4/96
  • 5. Serie storica Insieme di osservazioni numeriche riferite a momenti diversi in successione temporale periodica. tp v1 t2p v2 . . . . . . tnp vn E. Somma (SIA-BdI) WMBB 2008 21/01/2008 5/96
  • 6. L’oggetto timeseries 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 6/96
  • 7. Un array dei dati Un array di dati x = [-0.2 -0.3 13; -0.1 -0.4 15; NaN 2.8 17; 0.5 0.3 NaN; -0.3 -0.1 15] Un array casuale di dati x = rand(4,4); E. Somma (SIA-BdI) WMBB 2008 21/01/2008 7/96
  • 8. Un paio di timeseries ts_pos = timeseries(x(:,1:2), 1:5, ’name’, ’Position’) getdatasamplesize(ts_pos) ts_vel = timeseries(x(:,3), 1:5, ’name’, ’Velocity’); getdatasamplesize(ts_vel) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 8/96
  • 9. Altre timeseries %% Import the sample data load count.dat count1 = timeseries(count(:,1), 1:24,’name’, ’intersection1’); count2 = timeseries(count(:,2), 1:24,’name’, ’intersection2’); count3 = timeseries(count(:,3), 1:24,’name’, ’intersection3’); get(count1) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 9/96
  • 10. Definizione delle unit` di misura a count1.DataInfo.Units = ’cars’; count1.TimeInfo.Units = ’hours’; count2.TimeInfo.Units = ’hours’; count3.TimeInfo.Units = ’hours’; E. Somma (SIA-BdI) WMBB 2008 21/01/2008 10/96
  • 11. Definizione del metodo d’interpolazione count1.DataInfo.Interpolation = tsdata.interpolation(’zoh’); % zero-order hold E. Somma (SIA-BdI) WMBB 2008 21/01/2008 11/96
  • 12. Aggiunta di eventi %% Construct and add the first event to all time series e1 = tsdata.event(’AMCommute’,8); % Construct the first event at 8 AM e1.Units = ’hours’; % Specify the time units of the time count1 = addevent(count1,e1); % Add the event to count1 count2 = addevent(count2,e1); % Add the event to count2 count3 = addevent(count3,e1); % Add the event to count3 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 12/96
  • 13. Aggiunta di eventi %% Construct and add the second event to all time series e2 = tsdata.event(’PMCommute’,18); % Construct the first event at 6 PM e2.Units = ’hours’; % Specify the time units of the time count1 = addevent(count1,e2); % Add the event to count1 count2 = addevent(count2,e2); % Add the event to count2 count3 = addevent(count3,e2); % Add the event to count3 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 13/96
  • 14. Collezioni di timeseries tsc = tscollection({count1 count2},’name’, ’count_coll’) tsc = addts(tsc, count3) tsc1 = removets(tsc1,’intersection3’) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 14/96
  • 15. Ricampionamento della collezione tsc1 = resample(tsc,1:2:24) tsc1 = resample(tsc,1:0.5:24) tsc1 = resample(tsc1,tsc1.Time) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 15/96
  • 16. Modifica dei contenuti degli elementi della collezione tsc1 = addsampletocollection(tsc1,’time’,3.25,... ’intersection1’,5) tsc1 = delsamplefromcollection(tsc1,’index’,... find(isnan(tsc1.intersection2.Data))); tsc1 = addsampletocollection(tsc1,’time’,3.25,... ’intersection1’,5); E. Somma (SIA-BdI) WMBB 2008 21/01/2008 16/96
  • 17. Modifica dei contenuti degli elementi della collezione plot(tsc1.intersection1); hold on; plot(tsc1.intersection2) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 17/96
  • 18. E. Somma (SIA-BdI) WMBB 2008 21/01/2008 18/96
  • 19. L’oggetto fints 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 19/96
  • 20. Creazione fints dates = (datenum(’05/11/99’):datenum(’05/11/99’)+100)’; data_series1 = exp(randn(1, 101))’; data_series2 = exp(randn(1, 101))’; data = [data_series1 data_series2]; myfts = fints(dates, data); myfts myfts = desc: (none) freq: Unknown (0) ’dates: (101)’ ’series1: (101)’ ’series2: (101)’ ’11-May-1999’ [ 0.6488] [ 0.1105] ’12-May-1999’ [ 0.1891] [ 2.6814] ’13-May-1999’ [ 1.1335] [ 0.5953] [...] E. Somma (SIA-BdI) WMBB 2008 21/01/2008 20/96
  • 21. Trasformazione srs2 = myfts.series2 srs2_vec = fts2mat(myfts.series2) format long g srs2_mtx = fts2mat(myfts.series2, 1) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 21/96
  • 22. Indicizzazione elementi format short myfts(’05/11/99’) myfts.series2(’05/11/99’) myfts.series2({’05/11/99’, ’05/21/99’, ’05/31/99’}) myfts (’05/11/99::05/15/99’) myfts.series2(1) myfts.series2([1, 3, 5]) myfts.series2(16:20) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 22/96
  • 23. Operazioni addup = myfts1 + newfts subout = myfts1 - newfts addscalar = myfts1 + 10000 submtx = myfts1 - randn(20, 4) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 23/96
  • 24. Operazioni newfts2 = fints(myfts1.dates, fts2mat(myfts1/10000),... {’Rat1’,’Rat2’, ’Rat3’,’Rat4’}, 1, ’New FTS’) addother = myfts1 + fts2mat(newfts2); E. Somma (SIA-BdI) WMBB 2008 21/01/2008 24/96
  • 25. BITS - Bank of Italy Time Series 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 25/96
  • 26. L’oggetto tsmat 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 26/96
  • 27. Costruzione tsmat TSMAT = tsmat(1980,1,12,count) tsmat( macro index (year), micro index (period), frequency, d Parametri macro index double (used as integer) micro index double (used as integer) frequency numero di elementi in una divisione macro 1 Year 2 Semester 4 Quarter 12 Month 52 Week 365 Day data matrix NOBS×NSERIES SERIES colonne OSSERV righe E. Somma (SIA-BdI) WMBB 2008 21/01/2008 27/96
  • 28. Esempio A = tsmat(1980,1,12,rand(20,1)) Tsmat object Size: [20 1] Frequency: 12 Start: 1980 1 End: 1981 8 Labels: T1 B = tsmat(1980,1,12,rand(20,1)) BG = tsmat(1980,1,365,rand(220,1)) Tsmat object Size: [220 1] Frequency: 365 Start: Tue Jan-01-1980 End: Thu Aug-07-1980 Labels: T1 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 28/96
  • 29. Caricamento dati load count.dat TSC = tsmat(1980,1,365,count) Tsmat object Size: [24 3] Frequency: 365 Start: Tue Jan-01-1980 End: Thu Jan-24-1980 Labels: T1 T2 T3 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 29/96
  • 30. Struttura struct(TSC) ans = matdata: [24x3 double] start_year: 1980 start_period: 1 freq: 365 last_year: 1980 last_period: 24 meta: [1x1 struct] meta_cols: [1x1 struct] E. Somma (SIA-BdI) WMBB 2008 21/01/2008 30/96
  • 31. I Valori TSC.matdata ans = 11 11 9 7 13 11 14 17 20 11 13 9 43 51 69 38 46 76 61 132 186 [...] E. Somma (SIA-BdI) WMBB 2008 21/01/2008 31/96
  • 32. I metadati di base .freq frequenza delle osservazioni .start indice dell’oss. iniziale (anno,periodo) .start year anno dell’oss. iniziale .start period periodo dell’oss. iniziale .last indice dell’oss. finale (calcolato) .last year anno dell’oss. finale (calcolato) .last period periodo dell’oss. finale (calcolato) .range vettore degli indici iniziale e finale .dates vettore delle date in formato num. Matlab .matdata matrice dei valori della collezione Ad es. datestr(TSC.dates) ans = 01-Jan-1980 02-Jan-1980 03-Jan-1980 [...] E. Somma (SIA-BdI) WMBB 2008 21/01/2008 32/96
  • 33. I metadati ’estesi’ .meta metadati della collezione .meta cols metadati delle colonne I metadati di colonna obbligatori ’label’ nome della serie Ad es. TSC.meta ans = release: 733425 TSC.meta_cols ans = label: {’T1’ ’T2’ ’T3’} E. Somma (SIA-BdI) WMBB 2008 21/01/2008 33/96
  • 34. Visualizzare una serie con tstab tstab(S1 [, S2 ...]) dove S1,...,S2 sono oggetti tsmat A=tsmat(1980,1,12,rand(5,1)) B=tsmat(1980,3,12,rand(5,1)) tstab(A,B) tsStart: 1980 1 tsRelease: 18-Jan-2008 Frequency: 12 (monthly) Date T1 T1 18/01/08 18/01/08 1980-M-001 0.0377 NaN 1980-M-002 0.8852 NaN 1980-M-003 0.9133 0.2619 1980-M-004 0.7962 0.3354 1980-M-005 0.0987 0.6797 1980-M-006 NaN 0.1366 1980-M-007 NaN 0.7212 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 34/96
  • 35. Creazione della tsmat 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 35/96
  • 36. tsmat: Come si usa >> E. Somma (SIA-BdI) WMBB 2008 21/01/2008 36/96
  • 37. tsmat: Come si usa >> ts = tsmat(1980,1,12,rand(3,4)) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 36/96
  • 38. tsmat: Come si usa >> ts = tsmat(1980,1,12,rand(3,4)) Tsmat object Size: [3 4] Start: 1980 1 End: 1980 3 Labels: T1 T2 T3 T4 >> E. Somma (SIA-BdI) WMBB 2008 21/01/2008 36/96
  • 39. tsmat: Come si usa >> ts = tsmat(1980,1,12,rand(3,4)) Tsmat object Size: [3 4] Start: 1980 1 End: 1980 3 Labels: T1 T2 T3 T4 >> get(ts) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 36/96
  • 40. tsmat: Come si usa >> ts = tsmat(1980,1,12,rand(3,4)) Tsmat object Size: [3 4] Start: 1980 1 End: 1980 3 Labels: T1 T2 T3 T4 >> get(ts) matdata: [3x4 double] start_year: 1980 start_period: 1 freq: 12 last_year: 1980 last_period: 3 meta: [1x1 struct] meta_cols: [1x1 struct] E. Somma (SIA-BdI) WMBB 2008 21/01/2008 36/96
  • 41. tsmat: Come si usa >> E. Somma (SIA-BdI) WMBB 2008 21/01/2008 37/96
  • 42. tsmat: Come si usa >> tstab(ts) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 37/96
  • 43. tsmat: Come si usa >> tstab(ts) tsStart: 1980 1 tsRelease: 17-Jul-2007 Frequency: 12 (monthly) Date T1 T2 T3 T4 17/07/07 17/07/07 17/07/07 17/07/07 1980-M-001 0.6822 0.1509 0.8600 0.4966 1980-M-002 0.3028 0.6979 0.8537 0.8998 1980-M-003 0.5417 0.3784 0.5936 0.8216 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 37/96
  • 44. tsmat: Come si usa >> tstab(ts) tsStart: 1980 1 tsRelease: 17-Jul-2007 Frequency: 12 (monthly) Date LABELS T1 T2 T3 T4 17/07/07 17/07/07 17/07/07 17/07/07 1980-M-001 0.6822 0.1509 0.8600 0.4966 1980-M-002 0.3028 0.6979 0.8537 0.8998 1980-M-003 0.5417 0.3784 0.5936 0.8216 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 37/96
  • 45. tsmat: Come si usa >> tstab(ts) tsStart: 1980 1 tsRelease: 17-Jul-2007 RELEASES Frequency: 12 (monthly) Date T1 T2 T3 T4 17/07/07 17/07/07 17/07/07 17/07/07 1980-M-001 0.6822 0.1509 0.8600 0.4966 1980-M-002 0.3028 0.6979 0.8537 0.8998 1980-M-003 0.5417 0.3784 0.5936 0.8216 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 37/96
  • 46. tsmat Etichette di colonna ts = tsmat(1980,1,12,rand(3,4), ... {’PRICE’, ’STOCK’, ’EXCHANGE’, ’UNIT’}); tstab(ts) tsStart: 1980 1 tsRelease: 18-Jul-2007 Frequency: 12 (monthly) Date PRICE STOCK EXCHANGE UNIT 18/07/07 18/07/07 18/07/07 18/07/07 1980-M-001 0.0495 0.5221 0.3751 0.5979 1980-M-002 0.5667 0.1171 0.8234 0.9492 1980-M-003 0.1219 0.7699 0.0466 0.2888 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 38/96
  • 47. tsmat Etichette di colonna automatiche ts = tsmat(1980,1,12,rand(3,4),’PRICE’); tstab(ts) tsStart: 1980 1 tsRelease: 18-Jul-2007 Frequency: 12 (monthly) Date PRICE1 PRICE2 PRICE3 PRICE4 18/07/07 18/07/07 18/07/07 18/07/07 1980-M-001 0.8702 0.1923 0.9339 0.8952 1980-M-002 0.0269 0.7157 0.1372 0.9424 1980-M-003 0.5195 0.2507 0.5216 0.3351 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 39/96
  • 48. tsmat Rilasci di colonna ts = tsmat(1980,1,12,rand(3,4),’PRICE’, ... { ’01-Jan-2007’ ’02-Jan-2007’ ’07-Jan-2007’ ’09-Jan-2007’ }); tstab(ts) tsStart: 1980 1 Frequency: 12 (monthly) Date PRICE1 PRICE2 PRICE3 PRICE4 01/01/07 02/01/07 07/01/07 09/01/07 1980-M-001 0.5962 0.5972 0.9561 0.8121 1980-M-002 0.3290 0.1614 0.5955 0.6101 1980-M-003 0.4782 0.8295 0.0287 0.7015 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 40/96
  • 49. tsmat Distribuzione dei rilasci su tutte le colonne ts = tsmat(1980,1,12,rand(3,4), ... {’PRICE’, ’STOCK’, ’EXCHANGE’, ’UNIT’}, ... ’01-Jan-2002’ ); tstab(ts) tsStart: 1980 1 tsRelease: 18-Jul-2007 Frequency: 12 (monthly) Date PRICE STOCK EXCHANGE UNIT 01/01/02 01/01/02 01/01/02 01/01/02 1980-M-001 0.4374 0.1359 0.3987 0.8686 1980-M-002 0.4712 0.5325 0.3584 0.6264 1980-M-003 0.1493 0.7258 0.2853 0.2412 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 41/96
  • 50. Indicizzazione per l’accesso 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 42/96
  • 51. Indicizzazione Metadati fondamentali tramite ’.’ (es. TSC.start) Osservazione tramite ’()’ (es. TSC([2:5, [1:end]) Lead/Lag tramite ’{}’ (es. TSC{-1}) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 43/96
  • 52. Accesso ai metadati: ’.’ .freq frequenza delle osservazioni .start indice dell’oss. iniziale (anno,periodo) .start year anno dell’oss. iniziale .start period periodo dell’oss. iniziale .last indice dell’oss. finale (calcolato) .last year anno dell’oss. finale (calcolato) .last period periodo dell’oss. finale (calcolato) .range vettore degli indici iniziale e finale .dates vettore delle date in formato num. Matlab .matdata matrice dei valori della collezione .meta dizionario dei metadati di collezione .meta cols dizionari dei metadati di colonna Ad es. datestr(TSC.dates) ans = 01-Jan-1980 02-Jan-1980 03-Jan-1980 Somma (SIA-BdI) E. WMBB 2008 21/01/2008 44/96
  • 53. Accesso alle osservazioni: ’()’ Doppio vettore di interi (2 elementi) righe colonne osservazioni serie TSC( [2:5], [1:end]) tsStart: 1980 2 tsRelease: 19-Jan-2008 Frequency: 365 (daily) Date T1 T2 T3 19/01/08 19/01/08 19/01/08 1980-D-002 02-Jan-1980 7.0000 13.0000 11.0000 1980-D-003 02-Jan-1980 14.0000 17.0000 20.0000 1980-D-004 02-Jan-1980 11.0000 13.0000 9.0000 1980-D-005 02-Jan-1980 43.0000 51.0000 69.0000 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 45/96
  • 54. Esempio: Una osservazione di tutte le serie nella collezione righe colonne osservazioni serie TSC( 1, [1:end]) tstab(TSC1) tsStart: 1980 1 tsRelease: 19-Jan-2008 Frequency: 365 (daily) Date T1 T2 T3 19/01/08 19/01/08 19/01/08 1980-D-001 01-Jan-1980 11.0000 11.0000 9.0000 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 46/96
  • 55. Esempio: Tutte le osservazioni di una serie della collezione righe colonne osservazioni serie TSC( [1:end], 2) tstab(TSC1) tsStart: 1980 1 tsRelease: 19-Jan-2008 Frequency: 365 (daily) Date T1 19/01/08 1980-D-001 01-Jan-1980 11.0000 1980-D-002 01-Jan-1980 7.0000 1980-D-003 01-Jan-1980 14.0000 1980-D-004 01-Jan-1980 11.0000 [...] 1980-D-021 01-Jan-1980 35.0000 1980-D-022 01-Jan-1980 11.0000 1980-D-023 01-Jan-1980 13.0000 1980-D-024 01-Jan-1980 10.0000 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 47/96
  • 56. Accesso alle osservazioni: ’()’ Quattro Interi e un indice (5 elementi) anno periodo anno periodo colonne iniziale finale TSC( 1986, 1, 1996, 1, ’:’) TSC( 1986, 1, 1996, 1, [2 3]) tsStart: 1980 2 tsRelease: 19-Jan-2008 Frequency: 365 (daily) Date T1 T2 T3 19/01/08 19/01/08 19/01/08 1980-D-002 02-Jan-1980 7.0000 13.0000 11.0000 1980-D-003 02-Jan-1980 14.0000 17.0000 20.0000 1980-D-004 02-Jan-1980 11.0000 13.0000 9.0000 1980-D-005 02-Jan-1980 43.0000 51.0000 69.0000 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 48/96
  • 57. Operazione di Lead e Lag: ’{}’ TSC = tsmat(1980,1,365,count(:,1)) tstab(TSC1,TSC1{-1},TSC1{1}) % == tstab(TSC,tslag(TSC,1),tslag(TSC,-1)) tsStart: 1979 365 tsRelease: 18-Jan-2008 Frequency: 365 (daily) Date T1 T1 T1 18/01/08 18/01/08 18/01/08 1979-D-365 31-Dec-1979 NaN NaN 11.0000 1980-D-001 31-Dec-1979 11.0000 NaN 7.0000 1980-D-002 31-Dec-1979 7.0000 11.0000 14.0000 [...] 1980-D-023 31-Dec-1979 13.0000 11.0000 10.0000 1980-D-024 31-Dec-1979 10.0000 13.0000 NaN 1980-D-025 31-Dec-1979 NaN 10.0000 NaN E. Somma (SIA-BdI) WMBB 2008 21/01/2008 49/96
  • 58. Riorganizzazione 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 50/96
  • 59. Concatenazione orizzontale aa=tsmat(1980,1,4,reshape(-1:-1:-16,4,4)) Tsmat object Size: [4 4] Frequency: 4 Start: 1980 1 End: 1980 4 Labels: T1 T2 T3 T4 tstab(aa) tsStart: 1980 1 tsRelease: 19-Jan-2008 Frequency: 4 (quarterly) Date T1 T2 T3 T4 19/01/08 19/01/08 19/01/08 19/01/08 1980-Q-001 -1.0000 -5.0000 -9.0000 -13.0000 1980-Q-002 -2.0000 -6.0000 -10.0000 -14.0000 1980-Q-003 -3.0000 -7.0000 -11.0000 -15.0000 1980-Q-004 -4.0000 -8.0000 -12.0000 -16.0000 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 51/96
  • 60. Concatenazione orizzontale bb=tsmat(1979,1,4,reshape(1:16,4,4)) Tsmat object Size: [4 4] Frequency: 4 Start: 1979 1 End: 1979 4 Labels: T1 T2 T3 T4 tstab(bb) tsStart: 1979 1 tsRelease: 19-Jan-2008 Frequency: 4 (quarterly) Date T1 T2 T3 T4 19/01/08 19/01/08 19/01/08 19/01/08 1979-Q-001 1.0000 5.0000 9.0000 13.0000 1979-Q-002 2.0000 6.0000 10.0000 14.0000 1979-Q-003 3.0000 7.0000 11.0000 15.0000 1979-Q-004 4.0000 8.0000 12.0000 16.0000 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 52/96
  • 61. Concatenazione orizzontale cc=[aa,bb] Tsmat object Size: [8 8] Frequency: 4 Start: 1979 1 End: 1980 4 Labels: T1 T2 T3 T4 T1 T2 T3 T4 tstab(cc) tsStart: 1979 1 tsRelease: 19-Jan-2008 Frequency: 4 (quarterly) Date T1 T2 [...] T3 T4 19/01/08 19/01/08 [...] 19/01/08 19/01/08 1979-Q-001 NaN NaN [...] 9.0000 13.0000 1979-Q-002 NaN NaN [...] 10.0000 14.0000 1979-Q-003 NaN NaN [...] 11.0000 15.0000 1979-Q-004 NaN NaN [...] 12.0000 16.0000 1980-Q-001 -1.0000 -5.0000 [...] NaN NaN 1980-Q-002 -2.0000 -6.0000 [...] NaN NaN 1980-Q-003 -3.0000 -7.0000 [...] NaN NaN 1980-Q-004 -4.0000 -8.0000 [...] NaN NaN E. Somma (SIA-BdI) WMBB 2008 21/01/2008 53/96
  • 62. Concatenazione verticale cc=[aa;bb] Tsmat object Size: [8 4] Frequency: 4 Start: 1979 1 End: 1980 4 Labels: T1 T2 T3 T4 tstab(cc) tsStart: 1979 1 tsRelease: 19-Jan-2008 Frequency: 4 (quarterly) Date T1 T2 T3 T4 19/01/08 19/01/08 19/01/08 19/01/08 1979-Q-001 1.0000 5.0000 9.0000 13.0000 1979-Q-002 2.0000 6.0000 10.0000 14.0000 1979-Q-003 3.0000 7.0000 11.0000 15.0000 1979-Q-004 4.0000 8.0000 12.0000 16.0000 1980-Q-001 -1.0000 -5.0000 -9.0000 -13.0000 1980-Q-002 -2.0000 -6.0000 -10.0000 -14.0000 1980-Q-003 -3.0000 -7.0000 -11.0000 -15.0000 1980-Q-004 -4.0000 -8.0000 -12.0000 -16.0000 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 54/96
  • 63. Concatenazione verticale cc=[aa{-2};bb] Tsmat object Size: [8 4] Frequency: 4 Start: 1979 1 End: 1980 4 Labels: T1 T2 T3 T4 tstab(cc) tsStart: 1979 1 tsRelease: 19-Jan-2008 Frequency: 4 (quarterly) Date T1 T2 T3 T4 19/01/08 19/01/08 19/01/08 19/01/08 1979-Q-001 1.0000 5.0000 9.0000 13.0000 1979-Q-002 2.0000 6.0000 10.0000 14.0000 1979-Q-003 3.0000 7.0000 11.0000 15.0000 1979-Q-004 4.0000 8.0000 12.0000 16.0000 1980-Q-001 NaN NaN NaN NaN 1980-Q-002 NaN NaN NaN NaN 1980-Q-003 -1.0000 -5.0000 -9.0000 -13.0000 1980-Q-004 -2.0000 -6.0000 -10.0000 -14.0000 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 55/96
  • 64. Concatenazione verticale non adiacente cc=[aa;bb{-1}] ??? Error using ==> tsmat.extend "FillDateBeforeLastDate" Error in ==> <a href="error:/Users/exedre/Work/Matlab/bi/toolboxes/bits2/@t self = extend(a, self, [ a.start_year a.start_period ], fill_date); Error in ==> <a href="error:/Users/exedre/Work/Matlab/bi/toolboxes/bits2/@t res = extend(res,varargin{i},nan,true); E. Somma (SIA-BdI) WMBB 2008 21/01/2008 56/96
  • 65. extend Unione delle serie cn il controllo della sovrapposizione >> ts1 = tsmat(1980,1,12,rand(7,1)); >> ts2 = tsmat(1980,6,12,rand(4,1)); >> ts=extend(ts1,ts2) >> tstab(ts,ts1,ts2) [...] T1 T1 T1 05/09/07 05/09/07 05/09/07 1980-M-001 0.4457 0.4457 NaN 1980-M-002 0.9388 0.9388 NaN 1980-M-003 0.6338 0.6338 NaN 1980-M-004 0.9297 0.9297 NaN 1980-M-005 0.0629 0.0629 NaN 1980-M-006 0.0104 0.3069 0.0104 1980-M-007 0.1678 0.9498 0.1678 1980-M-008 0.7553 NaN 0.7553 1980-M-009 0.8338 NaN 0.8338 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 57/96
  • 66. extend Unione delle serie cn il controllo della sovrapposizione >> ts=extend(ts1,ts2,[1980 7]) >> tstab(ts,ts1,ts2) [...] T1 T1 T1 05/09/07 05/09/07 05/09/07 1980-M-001 0.4457 0.4457 NaN 1980-M-002 0.9388 0.9388 NaN 1980-M-003 0.6338 0.6338 NaN 1980-M-004 0.9297 0.9297 NaN 1980-M-005 0.0629 0.0629 NaN 1980-M-006 0.3069 0.3069 0.0104 1980-M-007 0.1678 0.9498 0.1678 1980-M-008 0.7553 NaN 0.7553 1980-M-009 0.8338 NaN 0.8338 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 58/96
  • 67. extend Unione di serie non contigue >> ts1=tsmat(1980,1,12,rand(5,1)) >> ts2=tsmat(1980,7,12,rand(5,1)); [...] T1 T1 1980-M-001 0.6059 NaN 1980-M-002 0.5179 NaN 1980-M-003 0.9429 NaN 1980-M-004 0.7412 NaN 1980-M-005 0.7011 NaN 1980-M-006 NaN NaN 1980-M-007 NaN 0.7447 1980-M-008 NaN 0.8738 1980-M-009 NaN 0.9641 1980-M-010 NaN 0.9819 1980-M-011 NaN 0.9186 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 59/96
  • 68. extend Unione di serie non contigue >> ts1=tsmat(1980,1,12,rand(5,1)) >> ts2=tsmat(1980,7,12,rand(5,1)); [...] T1 T1 1980-M-001 0.6059 NaN 1980-M-002 0.5179 NaN 1980-M-003 0.9429 NaN 1980-M-004 0.7412 NaN 1980-M-005 0.7011 NaN 1980-M-006 NaN NaN 1980-M-007 NaN 0.7447 1980-M-008 NaN 0.8738 1980-M-009 NaN 0.9641 1980-M-010 NaN 0.9819 1980-M-011 NaN 0.9186 >> ts=extend(ts1,ts2) ??? Error using ==> tsmat.extend at 130 "TimeseriesCannotBeLinked" E. Somma (SIA-BdI) WMBB 2008 21/01/2008 59/96
  • 69. extend Unione serie non contigue >> ts=extend(ts1,ts2,nan,true) T1 T1 T1 05/09/07 05/09/07 05/09/07 1980-M-001 0.6059 0.6059 NaN 1980-M-002 0.5179 0.5179 NaN 1980-M-003 0.9429 0.9429 NaN 1980-M-004 0.7412 0.7412 NaN 1980-M-005 0.7011 0.7011 NaN 1980-M-006 NaN NaN NaN 1980-M-007 0.7447 NaN 0.7447 1980-M-008 0.8738 NaN 0.8738 1980-M-009 0.9641 NaN 0.9641 1980-M-010 0.9819 NaN 0.9819 1980-M-011 0.9186 NaN 0.9186 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 60/96
  • 70. Operazioni tra le tsmat 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 61/96
  • 71. La differenza tra struttura e oggetto Struttura Oggetto s = struct() o = class() Creazione s.propriet´ a o.propriet´ a Accesso s.campo = valore o.campo = valore Riempimento funzione(s) metodo(o) Funzione/Metodo s.dati = m.dati + n.dati Operazioni tra strutture s = m + n Operazioni tra oggetti E. Somma (SIA-BdI) WMBB 2008 21/01/2008 62/96
  • 72. Operazioni sulle serie (senza esclusione dei nan) max(A) min(A) mean(A) median(A) std(A) sum(A) var(A) abs(A) ceil(A) TODO: iqr(A) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 63/96
  • 73. Operazioni sulle serie con esclusione dei nan nanmax(A) nanmin(A) nanmean(A) nanmedian(A) nanstd(A) nansum(A) nanva(A) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 64/96
  • 74. Operazioni tra le serie tstab(A,B, A*10) tstab(A,B, A+B) tstab(A,B, A-B) tstab(A,B, A*B) tstab(A,B, A./B) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 65/96
  • 75. Altre operazioni corr(TSC) corr(TSC.matdata) corr(count(:,1),count(:,2)) ans = 0.9331 corr(TSC(:,1),TSC(:,2)) ??? Error using ==> tsmat.subsref @tsmatsubsref::TS Index exceeds matrix dimensions E. Somma (SIA-BdI) WMBB 2008 21/01/2008 66/96
  • 76. Altre operazioni cov(TSC) cov(TSC.matdata) ans = 1.0e+003 * 0.6437 0.9802 1.6567 0.9802 1.7144 2.6908 1.6567 2.6908 4.6278 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 67/96
  • 77. Altre operazioni tstab(TSC,cumsum(TSC)) tstab(cumprod(TSC)) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 68/96
  • 78. Operazioni logiche tstab(TSC==TSC) tsStart: 1980 1 tsRelease: 18-Jan-2008 Frequency: 365 (daily) Date T1 T2 T3 18/01/08 18/01/08 18/01/08 1980-D-001 01-Jan-1980 1.0000 1.0000 1.0000 1980-D-002 01-Jan-1980 1.0000 1.0000 1.0000 1980-D-003 01-Jan-1980 1.0000 1.0000 1.0000 [...] E. Somma (SIA-BdI) WMBB 2008 21/01/2008 69/96
  • 79. Operazioni logiche TSC1 = tsmat(1980,1,365,rand(24,3)*10*) tstab(TSC>TSC1) (tstab(ge(TSC,TSC1)) tsStart: 1980 1 tsRelease: 18-Jan-2008 Frequency: 365 (daily) Date T1 T2 T3 18/01/08 18/01/08 18/01/08 1980-D-001 01-Jan-1980 0.0000 0.0000 0.0000 1980-D-002 01-Jan-1980 0.0000 0.0000 0.0000 1980-D-003 01-Jan-1980 0.0000 0.0000 1.0000 1980-D-004 01-Jan-1980 0.0000 0.0000 0.0000 [...] E. Somma (SIA-BdI) WMBB 2008 21/01/2008 70/96
  • 80. Operazioni e Funzioni Operazione F unzione gt(A,B) A>B ge(A,B) A≥B lt(A,B) A<B le(A,B) A≤B ne(A,B) A=B E. Somma (SIA-BdI) WMBB 2008 21/01/2008 71/96
  • 81. Determinazione dei valori Operazione F unzione isnan = NaN isfinite =∞ E. Somma (SIA-BdI) WMBB 2008 21/01/2008 72/96
  • 82. Introduciamo dei missing in testa e in coda TSC([1:3],[1:3])=NaN; tstab(TSC) TSC([24],[1:3])=NaN; tstab(TSC) Stringiamo l’intervallo di definizione della serie ai valori non missing TSCn=notnanrange(TSC) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 73/96
  • 83. Lag e Lead TSC = tsmat(1980,1,365,count(:,1)) tstab(TSC,tslag(TSC,1),tslag(TSC,-1)) tsStart: 1979 365 tsRelease: 18-Jan-2008 Frequency: 365 (daily) Date T1 T1 T1 18/01/08 18/01/08 18/01/08 1979-D-365 31-Dec-1979 NaN NaN 11.0000 1980-D-001 31-Dec-1979 11.0000 NaN 7.0000 1980-D-002 31-Dec-1979 7.0000 11.0000 14.0000 [...] 1980-D-023 31-Dec-1979 13.0000 11.0000 10.0000 1980-D-024 31-Dec-1979 10.0000 13.0000 NaN 1980-D-025 31-Dec-1979 NaN 10.0000 NaN E. Somma (SIA-BdI) WMBB 2008 21/01/2008 74/96
  • 84. Gestione dei Metadati 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 75/96
  • 85. Metadati della collezione ts.meta.<campo> getmeta(ts,’<campo>’) getmeta(ts,’<campo>’,<default>) rel = getmeta(ts,’release’,today) rel = 733426 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 76/96
  • 86. Metadati della collezione A.meta.pippo=’pluto1’; pluto=A.meta.pippo; A.meta ans = release: 733426 pippo: ’pluto1’ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A=addmeta(A,’pippo’,’pluto2’); A.meta ans = release: 733426 pippo: ’pluto2’ E. Somma (SIA-BdI) WMBB 2008 21/01/2008 77/96
  • 87. Un metadato notevole: release Il metadato release indica la data in cui la serie ` e presa in considerazione (?!?) Non viene utilizzata in alcun modo nei calcoli ma ` e molto importante nelle operazioni di vintage dei dati La release della singola serie (ovvero ts.meta colsj.release), se presente, verr` a utilizzata per indicare il vintage dei dati, altrimenti si utilizzera la release dell’intera collezione (ts.meta.release), nel caso in cui non sia presente neppure questo (errore) si utilizzer` la data corrente. a E. Somma (SIA-BdI) WMBB 2008 21/01/2008 78/96
  • 88. Esempio A.meta.release ans = 733426 >> datestr(A.meta.release) ans = 19-Jan-2008 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 79/96
  • 89. Cancellare un metadato rmfield(A.meta,’pippo’) % NON HA EFFETTO A.meta = rmfield(A.meta,’pippo’) % CORRETTO oppure A=delmeta(A,’pippo’) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 80/96
  • 90. Metadati di colonna TSC.meta_cols ans = label: {’T1’ ’T2’ ’T3’} Metadati di colonna I metadati di colonna sono ospitati in una struttura i cui campi sono cell-array. ` E uno strumento del linguaggio Matlab un po’ contorto a cui bisogna fare attenzione e che provoca un bel po’ di problemi. E. Somma (SIA-BdI) WMBB 2008 21/01/2008 81/96
  • 91. Metadati di colonna TSC.meta_cols.release(2) # NON FUNZIONA M = TSC.meta_cols # BISOGNA FARE COSI’ label = M.labels(2) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 82/96
  • 92. Metadati di colonna getcolmeta(TSC,2,’label’) ans = ’T2’ getcolmeta(TSC,2,’release’,today) ans = 733426 E. Somma (SIA-BdI) WMBB 2008 21/01/2008 83/96
  • 93. Metadati di colonna getcolmeta(TSC,2,’label’) ans = ’T2’ getcolmeta(TSC,2,’release’,today) ans = 733426 FCM = getfullcolmeta(TSC) 1x3 struct array with fields: label FCM(1).label ans = ’T1’ E. Somma (SIA-BdI) WMBB 2008 21/01/2008 84/96
  • 94. Metadati di colonna getcolmeta(TSC,2,’label’) ans = ’T2’ getcolmeta(TSC,2,’release’,today) ans = 733426 FCM = getfullcolmeta(TSC) 1x3 struct array with fields: label FCM(1).label ans = ’T1’ E. Somma (SIA-BdI) WMBB 2008 21/01/2008 85/96
  • 95. Metadati di colonna getcolmeta(TSC,2,’label’) ans = ’T2’ getcolmeta(TSC,2,’release’,today) ans = 733426 FCM = getfullcolmeta(TSC) 1x3 struct array with fields: label FCM(1).label ans = ’T1’ E. Somma (SIA-BdI) WMBB 2008 21/01/2008 86/96
  • 96. Metadati di colonna TSC=addmeta_cols(TSC, 3, ’release’, {today }) E. Somma (SIA-BdI) WMBB 2008 21/01/2008 87/96
  • 97. Plot 1 Le serie storiche in MATLAB L’oggetto timeseries L’oggetto fints 2 BITS - Bank of Italy Time Series L’oggetto tsmat Creazione della tsmat Indicizzazione per l’accesso Riorganizzazione Operazioni tra le tsmat Gestione dei Metadati Plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 88/96
  • 98. Esempio di plot aa=tsmat(1980,1,12,randn(120,1)); bb=filter(1,[1 -0.9],aa); h=plot([aa,bb]); legend(’aa tsmat’,’filtered tsmat bb’); % Let’s add a moving average of the bb tsmat cc=mave(bb,12); plot([aa,bb,cc]); legend(’aa tsmat’,’filtered tsmat bb’,’12 terms moving average E. Somma (SIA-BdI) WMBB 2008 21/01/2008 89/96
  • 99. Esempio di plot E. Somma (SIA-BdI) WMBB 2008 21/01/2008 90/96
  • 100. Grazie dell’attenzione E. Somma (SIA-BdI) WMBB 2008 21/01/2008 91/96