<<timeseri\\datasmoo.m
<<timeseri\\timeseri.m
<<timeseri\\userfunc.m

POPIS ARMA, AR a MA MODELU

Popis modelu ARMA (2, 1) v tvare

(Subscript[X, t])-0.5 (Subscript[X, t-1])+0.2(Subscript[X, t-2])=(Subscript[Z, t])+0.7(Subscript[Z, t-1])

ARMAModel[{0.5,-0.2},{.7},.8]

Popis modelu ARMA (2, 1) v tvare
(Subscript[X, t])-0.7 (Subscript[X, t-1])+0.2(Subscript[X, t-2])=(Subscript[Z, t])+0.8(Subscript[Z, t-1])

popis modelu AR(2)

arma=ARMAModel[{0.5,-0.2},{0.7},0.8]
MACoefficients[arma]
ARCoefficients[arma]

Vytvorenie casoveho radu popisaneho arma modelom

Prikaz arma popisuje model, ale nevytvori hodnotycasoveho radu. Prikaz timeseries nahodne vygeneruje vychodiskove hodnoty. Sum ma normalne rozlozenie pravdepodobnosti so stredovou hodnotou 0 a rozptylom 0.8.

rad=TimeSeries[ARMAModel[{0.5,-0.2},{0.7},0.8],7]

rad=SeedRandom[1234];
TimeSeries[ARMAModel[{0.5,-0.2},{0.7},0.8],7]

TimeSeries[ARMAModel[{0.5,-0.2},{0.7},0.8],7,{-0.3,.5}]

rad1=TimeSeries[SeedRandom[1234];ARMAModel[{0.5,-0.2},{0.7},0.8],7,{-0.3,.5}]
ListPlot[rad1,Joined->True]

rad2=(SeedRandom[1234];TimeSeries[ARMAModel[{0.5,-0.2},{0.7},0.75],200]);
ListPlot[rad2,Joined->True]

rad3=(SeedRandom[1234];TimeSeries[ARMAModel[{0.5,-0.1},{1},1],50]);
ListPlot[rad3,Joined->True]

STACIONARITA

Stacionaritu zistime prikazom StationaryQ

StationaryQ[ARMAModel[{0.5,-1.2},{0.7},1]]

Dany model nie je stacionarny.

Stacionarita zavisi iba od AR koeficientov, mozem napisat :

StationaryQ[{0.5,-1.2}]

Inak sa da napisat :

Solve[1-0.5x+1.2x^2==0,x]

Absolutna hodnota oboch korenov je < 0 = > lezi vo vnutri jednotkoveho kruhu

Abs[x/.%] (* /. - znamena prirad a % posledny vystup*)

StationaryQ[ARModel[{0.3,-.8}]]

Solve[1-0.3x+0.8x^2==0,x]

Abs[x /. %]

Korene lezia mimo jednotkovej kruznice.

Priklad1:
Prepiste stacionarny arma(1,1) model (Subscript[X, t])-0.7 (Subscript[X, t-1])=(Subscript[Z, t])+0.3(Subscript[Z, t-1])do tvaru MA(5)

StationaryQ[ARMAModel[{0.7},{0.8},1]]

arma=ARMAModel[{0.7},{0.8},1]

ma4=ToMAModel[arma,4]

StationaryQ[ma4]

Nasledujucim prikazom sa vypocitaju 4 koeficienty AR (4) modelu ako expanzia stacionarneho ARMA (1, 1) modelu.

INVERTIBILITA

InvertibleQ[ARMAModel[{0.5,-1.2},{0.7},1]]

InvertibleQ[{0.7}]

Solve[1+0.7x==0,x]

Abs[x /. %]

Korene lezia mimo jednotkovej kruznice.

Priklad :
Prepiste ARMA(1,1) model (Subscript[X, t])-0.7(Subscript[X, t-1])=(Subscript[Z, t])-0.5(Subscript[Z, t-1]) do tvaru AR(6) modelu.

InvertibleQ[ARMAModel[{0.7},{-.5}]]

ToARModel[ARMAModel[{0.7},{-.5}],6]

Ak chceme k modelu pridat aj rozptyl pouzijeme append

Append[%,1]

KOVARIACNA A KORELACNA FUNKCIA

Priklad :
 Definujem e kovar a korel fciu pre AR (1) model pouzitim prikazov :

CovarianceFunction[ARModel[{f1},s],4]

Ziskali sme vzorce pre kovariancie s posunitim 0, 1, 2, 3, 4

Vyraz %/[[1]] predstavuje prvy prvok posledneho vystupu.

Aby sme dostali vzorce pre korrelacnu fciu musime vydelit uvedeny vsledok prvym vystupom

%/%[[1]]

corr=c

CovarianceFunction[MAModel[{θ1},σ2],5]

Priklad :

StationaryQ[ARModel[{.7},1]]

corr1=CovarianceFunction[ARModel[{.7},1],10]

plotcorr[corr_,opts_]:=ListPlot[corr, DataRange->{0,Length[corr]-1},opts]
plotcorr[corr1,AxesLabel->{"k","ρ(k)"}]

Ak chceme zobrazit iba korelacnu fciu, mozno prikaz zapisat nasledovne (AR(1) model pre φ=-0.7):

plotcorr[CorrelationFunction[ARModel[{.9,-.8},1],25],AxesLabel->{"k","ρ(k)"},Joined->True]

Priklad:
Najdite vzorce pre korelacnu fciu d oposunutia 4 modelu MA(2) daneho
(Subscript[X, t])=(Subscript[Z, t])+(Subscript[θ, 1])(Subscript[Z, t-1])+(Subscript[θ, 2])(Subscript[Z, t-2])

CorrelationFunction[MAModel[{t1,t2},var],4]

CorrelationFunction[ARMAModel[{f1,f2},{t1,t2},var],2]

plotcorr[CorrelationFunction[ARMAModel[{.9,-0.3},{.2,-1.2},1],10],AxesLabel->{"k","ρ(k)"},Joined->True]

PARCIALNA KORELACNA FUNKCIA

Priklad:
Najdite vzorce pre parc korel fciu modelu AR(2) s posunutim do 4.

PartialCorrelationFunction[ARModel[{f1,f2},s],4]

StationaryQ[ARModel[{0.1,.8},1]]

ListLinePlot[PartialCorrelationFunction[ARModel[{0.1,.8},1],20],AxesLabel->{"k","ρ(k)"}]

PartialCorrelationFunction[MAModel[{t1},1],4]

ListLinePlot[PartialCorrelationFunction[MAModel[{0.8},1],20],AxesLabel->{"k","ρ(k)"}]