• Non ci sono risultati.

UN ESEMPIO COSTRUZIONE DI MODELLO SARIMA

N/A
N/A
Protected

Academic year: 2021

Condividi "UN ESEMPIO COSTRUZIONE DI MODELLO SARIMA"

Copied!
7
0
0

Testo completo

(1)

UN ESEMPIO COSTRUZIONE DI MODELLO SARIMA

/* LETTURA E STAMPA DEI DATI */

libname laghi '\\Bernoulli\hs\SMID\CORSI\Statistica Applicata 1\SERIE STORICHE\lago_erie';

data laghi.erie;

infile '\\Bernoulli\hs\SMID\CORSI\Statistica Applicata 1\SERIE STORICHE\lago_erie

\Livelli_ERIE.txt';

input num prof;

date=intnx('month','1jan21'd,_n_-1);

format date monyy.;

drop num; run;

proc print data=laghi.erie (obs=14);title 'Dati analizzati';run;

Dati analizzati Obs PROF DATE 1 14.763 JAN21 2 14.649 FEB21 3 15.085 MAR21 4 16.376 APR21 5 16.926 MAY21 6 16.774 JUN21 7 16.490 JUL21 8 15.769 AUG21 9 15.180 SEP21 10 14.383 OCT21 11 14.478 NOV21 12 14.364 DEC21 13 13.928 JAN22 14 13.283 FEB22

goption hsize = 18 cm vsize = 13 cm ftext=swissb htext=1;

axis1 order=('01jan21'd to '01jan26'd by year) offset=(3) minor=(number=3);

proc gplot data=laghi.erie;

plot prof*date=1 / haxis=axis1;

symbol1 c=black i=join v='dot';

format date year4.;

label date='Year';

title 'Grafico dei primi 60 dati';

run;quit;

(2)

/* FASE DI IDENTIFICAZIONE */

option pagesize=400;

proc arima data=laghi.erie;

identify var=prof outcov=laghi.id1 nlag=48;

title 'Fase di identificazione';

run;quit;

/* OUTPUT – test per verificare se la serie e` non autocorrelata; se si riufiuta l’ipotesi si puo` procedere con la modellazione */

Autocorrelation Check for White Noise To Chi- Pr >

Lag Square DF ChiSq ---Autocorrelations--- 6 1763.73 6 <.0001 0.949 0.843 0.714 0.591 0.496 0.449 12 3197.98 12 <.0001 0.455 0.507 0.586 0.669 0.731 0.744 18 4034.74 18 <.0001 0.696 0.604 0.488 0.371 0.279 0.232 24 4679.61 24 <.0001 0.240 0.291 0.370 0.452 0.513 0.534 ...

proc print data=laghi.id1 (obs=12); title 'File outcov'; run;

file outcov Obs LAG VAR N COV CORR STDERR INVCORR PARTCORR 1 0 PROF 600 4.04180 1.00000 0.00000 1.00000 1.00000 2 1 PROF 599 3.83374 0.94852 0.04082 -0.54364 0.94852 3 2 PROF 598 3.40730 0.84302 0.06831 -0.02744 -0.56514 4 3 PROF 597 2.88653 0.71417 0.08387 0.08633 -0.01902 5 4 PROF 596 2.38807 0.59084 0.09346 -0.00550 0.13102 6 5 PROF 595 2.00464 0.49598 0.09949 0.03512 0.17074 7 6 PROF 594 1.81386 0.44878 0.10353 -0.09723 0.25509 8 7 PROF 593 1.83829 0.45482 0.10672 0.07188 0.21541

goption reset=(all) htitle=1.5 ftext=SWISSB ; symbol7 i=needle ;

axis20 order=-1 to 1 by 0.1 label=(angle=90);

proc gplot data=laghi.id1;

title 'autocorrelazioni totale e parziale per la serie originale';

plot corr*lag=7/ vaxis=axis20;

plot PARTcorr*lag=7/ vaxis=axis20;

run;quit; title ' ';

data uno;

set laghi.erie (firstobs=13);

prof2=prof;

format data2 monyy.;

data2=date;

drop date prof;run;

data due;

(3)

set uno;

set laghi.erie;

diff=prof-prof2;

proc print data= due(obs=6);title 'Dati differenziati'; ;run;

Dati differenziati Obs prof2 data2 PROF DATE diff 1 13.928 JAN22 14.763 JAN21 0.835 2 13.283 FEB22 14.649 FEB21 1.366 3 13.700 MAR22 15.085 MAR21 1.385 4 15.465 APR22 16.376 APR21 0.911 5 16.243 MAY22 16.926 MAY21 0.683 6 16.490 JUN22 16.774 JUN21 0.284

goption hsize = 13 cm vsize = 13 htitle=1.5 ftext=SWISSB;

axis1 length=10 cm; symbol1 i=none v=dot;

proc gplot data=due;

plot prof*prof2/vaxis=axis1 haxis=axis1;run;quit;

goption hsize = 18 cm vsize = 13 cm; symbol1 i=j v=none;

proc gplot data=due;

plot diff*data2; run;quit;

/*Di feren f ze di ordine 1 e 12*/

proc arima data=laghi.erie;

identify var=prof(1,12) outcov=laghi.id1 nlag=48;

title 'Fase di identificazione';

run;quit;

proc gplot data=laghi.id1;

title 'autocorrelazioni totale e parziale per la serie differenziata';

plot corr*lag=7/ vaxis=axis20;

plot PARTcorr*lag=7/ vaxis=axis20;

run;quit; title ' ';

(4)

/* STIMA CON DIVERSI MODELLI E DIVERSI METODI */

proc arima data=laghi.erie;

identify var=prof (1,12) center noprint;

/* noprint evita la stampa - nella finestra di output -

dei grafici delle funzioni di autocorrelazioni parziali e totali*/

estimate p=1 q=(1,2,3)(12) noconstant;

title 'Fase di stima e verifica diagnostica';

run;quit;

/*Si osserva l'output e in particolare

- la tabella "Autocorrelation Check of Residuals"

che contiene i p-value per un test di nullita` delle autocorrelazioni di ordine k - le stime dei parametri del modello*/

Conditional Least Squares Estimation

Standard Approx

Parameter Estimate Error t Value Pr > |t| Lag MA1,1 0.54796 0.15219 3.60 0.0003 1 MA1,2 0.06039 0.05145 1.17 0.2409 2 MA1,3 0.14552 0.04211 3.46 0.0006 3 MA2,1 0.89477 0.01939 46.15 <.0001 12 AR1,1 0.72258 0.15070 4.79 <.0001 1 Variance Estimate 0.175891

Std Error Estimate 0.419394 AIC 650.6717 SBC 672.5468 Number of Residuals 587

* AIC and SBC do not include log determinant.

Correlations of Parameter Estimates

Parameter MA1,1 MA1,2 MA1,3 MA2,1 AR1,1 MA1,1 1.000 0.275 -0.249 -0.070 0.963 MA1,2 0.275 1.000 -0.534 -0.001 0.413 MA1,3 -0.249 -0.534 1.000 -0.038 -0.220 MA2,1 -0.070 -0.001 -0.038 1.000 -0.069 AR1,1 0.963 0.413 -0.220 -0.069 1.000 Autocorrelation Check of Residuals

Chi- Pr >

Square DF ChiSq ---Autocorrelations--- 1.22 1 0.2691 0.002 0.001 0.004 -0.020 -0.015 0.038 9.21 7 0.2376 -0.002 -0.009 -0.027 -0.009 0.108 -0.029 13.50 13 0.4099 -0.041 0.053 0.017 -0.013 -0.033 -0.033 22.92 19 0.2410 0.026 -0.058 -0.029 0.030 -0.093 0.030 32.00 25 0.1580 0.057 0.023 -0.078 -0.028 0.049 -0.042 38.16 31 0.1761 -0.011 0.012 0.080 -0.010 0.048 0.028 43.57 37 0.2120 -0.046 -0.051 -0.058 0.005 -0.020 -0.007 48.48 43 0.2615 0.027 0.030 -0.075 0.012 -0.005 -0.014 Model for variable PROF

Data have been centered by subtracting the value 0.001002 Period(s) of Differencing 1,12 No mean term in this model.

Autoregressive Factors Factor 1: 1 - 0.72258 B**(1) Moving Average Factors

Factor 1: 1 - 0.54796 B**(1) - 0.06039 B**(2) - 0.14552 B**(3) Factor 2: 1 - 0.89477 B**(12)

/*In qesto caso:

- i residui possono essere considerati non autocorrelati

- il parametro MA di ordine 2 puo` essere considerato nullo*/

(5)

proc arima data=laghi.erie;

identify var=prof (1,12) center noprint;

estimate p=(1) q=(1,3)(12) noconstant;

title 'Fase di stima e verifica diagnostica';

run;quit;

Fase di stima e verifica diagnostica The ARIMA Procedure

Conditional Least Squares Estimation

Standard Approx

Parameter Estimate Error t Value Pr > |t| Lag MA1,1 0.47413 0.18169 2.61 0.0093 1 MA1,2 0.16450 0.03830 4.30 <.0001 3 MA2,1 0.89487 0.01929 46.40 <.0001 12 AR1,1 0.62705 0.17265 3.63 0.0003 1 Variance Estimate 0.175969

Std Error Estimate 0.419486 AIC 649.9381 SBC 667.4382 Number of Residuals 587 * AIC and SBC do not include log determinant.

Correlations of Parameter Estimates

Parameter MA1,1 MA1,2 MA2,1 AR1,1 MA1,1 1.000 0.239 -0.035 0.980 MA1,2 0.239 1.000 -0.041 0.304 MA2,1 -0.035 -0.041 1.000 -0.036 AR1,1 0.980 0.304 -0.036 1.000 Autocorrelation Check of Residuals To Chi- Pr >

Lag Square DF ChiSq ---Autocorrelations--- 6 2.24 2 0.3270 0.023 -0.032 0.014 -0.022 -0.028 0.028 12 10.64 8 0.2227 -0.008 -0.017 -0.038 -0.012 0.105 -0.032 18 15.45 14 0.3482 -0.047 0.053 0.019 -0.016 -0.037 -0.031 24 24.86 20 0.2068 0.025 -0.062 -0.028 0.030 -0.093 0.025 30 34.91 26 0.1135 0.064 0.023 -0.082 -0.026 0.052 -0.040 36 41.52 32 0.1208 -0.015 0.019 0.081 -0.008 0.048 0.032 42 46.95 38 0.1513 -0.045 -0.054 -0.056 0.006 -0.020 -0.009 48 51.88 44 0.1937 0.033 0.031 -0.073 0.011 -0.001 -0.014 Model for variable PROF

Data have been centered by subtracting the value 0.001002 Period(s) of Differencing 1,12 No mean term in this model.

Autoregressive Factors Factor 1: 1 - 0.62705 B**(1) Moving Average Factors

Factor 1: 1 - 0.47413 B**(1) - 0.1645 B**(3) Factor 2: 1 - 0.89487 B**(12)

/*Il modello e` soddisfacente*/

/*Si provano comunque altri modelli*/

proc arima data=laghi.erie;

identify var=prof (1,12) center noprint;

estimate p=(1) q=(3)(12) noconstant;

title 'Fase di stima e verifica diagnostica';

proc arima data=laghi.erie;

identify var=prof (1,12) center noprint;

estimate q=(1,3)(12) noconstant;

title 'Fase di stima e verifica diagnostica';

run;quit;

(6)

/* PREVISIONE E GRAFICO AUTOCORRELAZIONI RESIDUI */

/* NOTA: i residui vengono conservati solo con l'istruzione forecast*/

proc arima data=laghi.erie;

identify var=prof(1,12) center noprint;

estimate p=(1) q=(1,3)(12) noconstant noprint;

forecast lead=12 out=laghi.forcls id=date interval=month;

run;

proc print data=laghi.forcls (obs=22); title 'File out – prime osservazioni'; run;

Obs DATE PROF FORECAST STD L95 U95 RESIDUAL 1 JAN21 14.763 . . . . . 2 FEB21 14.649 . . . . . 3 MAR21 15.085 . . . . . 4 APR21 16.376 . . . . . 5 MAY21 16.926 . . . . . 6 JUN21 16.774 . . . . . 7 JUL21 16.490 . . . . . 8 AUG21 15.769 . . . . . 9 SEP21 15.180 . . . . . 10 OCT21 14.383 . . . . . 11 NOV21 14.478 . . . . . 12 DEC21 14.364 . . . . . 13 JAN22 13.928 . . . . . 14 FEB22 13.283 13.8150 0.41949 12.9928 14.6372 -0.53200 15 MAR22 13.700 13.6386 0.41949 12.8165 14.4608 0.06135 16 APR22 15.465 14.9504 0.41949 14.1282 15.7725 0.51463 17 MAY22 16.243 16.1561 0.41949 15.3339 16.9783 0.08689 18 JUN22 16.490 16.1831 0.41949 15.3609 17.0052 0.30695 19 JUL22 16.243 16.2264 0.41949 15.4042 17.0486 0.01662 20 AUG22 15.787 15.5234 0.41949 14.7012 16.3456 0.26360 21 SEP22 15.446 15.1891 0.41949 14.3669 16.0112 0.25693 22 OCT22 14.649 14.6803 0.41949 13.8582 15.5025 -0.03133

proc print data=laghi.forcls (firstobs=598); title 'File out – ultime osservazioni'; run;

File out - ultime osservazioni

Obs DATE PROF FORECAST STD L95 U95 RESIDUAL 598 OCT70 16.660 16.3687 0.41949 15.5466 17.1909 0.29127 599 NOV70 16.433 16.2737 0.41949 15.4515 17.0958 0.15933 600 DEC70 16.584 16.5147 0.41949 15.6925 17.3369 0.06929 601 JAN71 . 16.5220 0.41949 15.6998 17.3442 . 602 FEB71 . 16.6708 0.64021 15.4160 17.9256 . 603 MAR71 . 17.0827 0.82723 15.4614 18.7040 . 604 APR71 . 18.0313 0.95644 16.1567 19.9059 . 605 MAY71 . 18.6386 1.05813 16.5647 20.7125 . 606 JUN71 . 18.8187 1.14422 16.5761 21.0613 . 607 JUL71 . 18.7818 1.22046 16.3897 21.1738 . 608 AUG71 . 18.4608 1.29001 15.9324 20.9891 . 609 SEP71 . 17.8708 1.35469 15.2157 20.5260 . 610 OCT71 . 17.1727 1.41565 14.3981 19.9473 . 611 NOV71 . 16.7490 1.47362 13.8607 19.6372 . 612 DEC71 . 16.7957 1.52912 13.7987 19.7927 .

/*Identificazione e grafico autocorrelazioni dei residui */

proc arima data=laghi.forcls;

identify var=residual outcov=laghi.res nlag=48;run;quit;

proc gplot data=laghi.res;

title 'autocorrelazioni totale e parziale per la serie originale';

plot corr*lag=7/ vaxis=axis20; plot PARTcorr*lag=7/ vaxis=axis20;

run;quit; title ' ';

(7)

goption reset=(all);

axis1 order=('01jan67'd to '01jan72'd by year) offset=(3) minor=(number=3);

proc gplot data=laghi.forcls;

plot prof*date=1 forecast*date=2 l95*date=3 u95*date=4 / overlay haxis=axis1;

symbol1 c=black i=join v=dot; symbol2 c=black i=join v='F';

symbol3 c=black i=join v='L'; symbol4 c=black i=join v='U';

format date year4.; label date='Year';

title 'Previsioni del livello del lago';run;quit;

Riferimenti

Documenti correlati

Nel descritto quadro normativo, e proprio al fine di ovviare ai rischi ad esso connessi, il Fondo Banche Assicurazioni (FBA), ente paritetico istituito «al fine

 Tra questi due stati c’è stata una transizione demografica durante la quale la crescita della popolazione è stata elevata perché i tassi di natalità non sono diminuiti quando

[r]

Al termine della scuola dell’infanzia Al termine della classe 3^ primaria Al termine della classe 5^ primaria.. • Ascolta e comprende messaggi linguistici

(2) Per x negativo 1/x assume valori negativi: valori negativi quanto si voglia piccoli in valore assoluto per x negativo abbastanza grande in valore assoluto (1/x ha limite 0 − per

• La costruzione del modello matematico `e anche un procedimento che permette di comprendere a pieno il fenomeno fisico che si vuol descrivere.. • Compromesso fra la semplicit`a

Tale curva costituisce un modello statico del sistema in quanto non fornisce alcuna informazione sulla dinamica con cui l’estremit`a libera passa da una posizione di

Si ipotizza che il tasso di mortalità della preda causato dal predatore sia proporzionale al numero di volte che le prede ed i predatori si incontrano, quindi sia legato al