Hinweis:

-Ein R Notebook ist ein R Markdown-Dokument mit R Skripten, die unabhängig und interaktiv ausgeführt werden können, wobei die Ausgabe unmittelbar unter der Eingabe sichtbar ist.

-Die Notebook-Ausgabe ist als HTML, PDF, Word oder Latex verfügbar.

-Dieses Notebook als HTML ist vorzugsweise mit Web Browser (zb. Chrome) zu öffnen.

-R-Skripten kann als Rmd-Datei unter dem Button “Code” ( oben rechts) im Notebook extrahiert werden.


#quelle: https://all-free-download.com/free-vector/housing-buildings-icon.html


1. Hintergrund und Ziel der Analyse

Der Sales ist das Lebenselixier eines Unternehmens. Die Vorteile der Salesprognose können Sie sich ein genaues Bild machen, was Sie in den kommenden Monaten erwartet. Eine Standard-Verkaufsprognose betrachtet die Bedingungen in Ihrem Unternehmen in den Vormonaten und wendet dann Annahmen über die Kundengewinnung, die Wirtschaft und Ihr Produkt-und Dienstleistungsangebot an.

Die Salesprognose ist ein Schlüsselelement bei der Durchführung Ihres Unternehmens. Der Realismus, den eine gute Prognose bietet, kann Ihnen helfen, Ihre strategischen Pläne zu entwickeln und zu verbessern

Die Prognose können Aspekte Ihres Unternehmens verwalten, unter anderem:

  • Anzahl der Entscheidungen, von der Einstellung und dem Ressourcenmanagement bis hin zur Zielsetzung und Budgetierung.

  • Marketing

  • Inventor kontrollen

  • usw

#quelle: https://yourbusiness.azcentral.com/advantages-sales-forecasting-10308.html
#quelle: https://blog.hubspot.com/sales/sales-forecasting

Die Salesprognose identifiziert Schwachstellen und Stärken, bevor Sie Ihre Budget- und Marketingpläne für das nächste Zeitraum festlegen, so dass Sie Ihre Einkaufs- und Expansionspläne optimieren können.

Die Daten sind unter folgender URL abrufbar: USA Home Sales


2. Einlesen der Daten

Importieren der Daten

#Zuerst bitte setwd() in unsre file directory eingerichtet (Ordnen, wo der Daten liegen)
sales<-read.csv(file="sales.csv", header=TRUE,sep = ",")
head(sales, 5) #nur 5 Zeilen hat so gezeigt
dim(sales) #dimension der daten
[1] 277   2
class(sales) #class der daten
[1] "data.frame"
#Umbennen der Spaltenname
name<-c("month","sales")
names(sales)<-name
head(sales,5)

Also die Daten hat 275 Zeilen (277-2) und 2 Spalten (datum und anzahl der Wohnungen ) as “data.frame”. Es geht um CSV Tabelle Formatierung.

Vorsicht! die Daten ist monatlichen Daten von Jan 1973 - Nov 1995.


Erstellen ts (time series) object

Die Daten sind nicht ts object sondern dataframe. Wir müssen die Daten nach ts object konvertieren. Es gibt vielen Methoden um die Daten nach ts object zu konvertieren. Wir haben mit packages fpp(Data for “Forecasting principles and practice”) gewählt.

** Erstellen times series object mit fpp packagen: **

#install.packages("fpp")
#library(fpp)
sales_ts<-ts(sales$sales,frequency=12,start=c(1973))
sales_ts
     Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1973  55  60  68  63  65  61  54  52  46  42  37  30
1974  37  44  55  53  58  50  48  45  41  34  30  24
1975  29  34  44  54  57  51  51  53  46  46  46  39
1976  41  53  55  62  55  56  57  59  58  55  49  47
1977  57  68  84  81  78  74  64  74  71  63  55  51
1978  57  63  75  85  80  77  68  72  68  70  53  50
1979  53  58  73  72  68  63  64  68  60  54  41  35
1980  43  44  44  36  44  50  55  61  50  46  39  33
1981  37  40  49  44  45  38  36  34  28  29  27  29
1982  28  29  36  32  36  34  31  36  39  40  39  33
1983  44  46  57  59  64  59  51  50  48  51  45  48
1984  52  58  63  61  59  58  52  48  53  55  42  38
1985  48  55  67  60  65  65  63  61  54  52  51  47
1986  55  59  89  84  75  66  57  52  60  54  48  49
1987  53  59  73  72  62  58  55  56  52  52  43  37
1988  43  55  68  68  64  65  57  59  54  57  43  42
1989  52  51  58  60  61  58  62  61  49  51  47  40
1990  45  50  58  52  50  50  46  46  38  37  34  29
1991  30  40  46  46  47  47  43  46  37  41  39  36
1992  48  55  56  53  52  53  52  56  51  48  42  42
1993  44  50  60  66  58  59  55  57  57  56  53  51
1994  45  58  74  65  65  55  52  59  54  57  45  40
1995  47  47  60  58  63  64  64  63  55  54  44  NA
1996  NA                                            

Es gibt NA werten, also bereinigen wir direkt vor dem Analyse. Denn NA werte zerstört die Aggregation.

Für nächstes Schritt brauchen wir aber daten ohne NA:

sales_ts_ohne_na<-na.remove(sales_ts) #vorsicht na.remove liegt in fpp package
class(sales_ts_ohne_na)
[1] "ts"

Plot der Daten:

plot.ts(sales_ts_ohne_na, type="p", col="blue", lty="dashed")

ts.plot(sales_ts_ohne_na,col="blue") #plot mit linien type

** Wichtigen empirischen Kennzahlen in Plot hinzufügen: **

plot(sales_ts_ohne_na,col="blue")
#Mittelwert berechnen
mw=mean(sales_ts_ohne_na)
mw
[1] 52.28727
#Mittelwert in Plot hinzufügen
x=c(1973:1995,4)
#length(x)
y=rep(mw,24)
#length(y)
lines(x,y,col=2)
#Varianz berechnen
var(sales_ts_ohne_na) 
[1] 142.534
#Standardabweichung berechnen
std=sd(sales_ts_ohne_na) 
std
[1] 11.93876
# std einzeichnen
z1=rep(std+mw,24)
z2=rep(-std+mw,24)
#length(y)
lines(x,z1,col=5)
lines(x,z2,col=5)

Interactiven Plot der Daten:

In R kann man interactiven visualisierung erstellen. Viele packagen oder methoden für diesem Zweck. Mehr informationen über https://www.htmlwidgets.org/

Wir haben dygraphs package gewählt.

#install dygraphs und ggplot2 package
dygraph(sales_ts, main = "Monatlicher Verkauf von neuen Einfamilienhäusern") %>% 
  dyRangeSelector(dateWindow = c("1973-01-01", "1995-01-11"))

3. Zeitreihenanalyse

Was sind die Komponenten einer Zeitreihe?

Ziel:

Wir wollen also möglichst mit stationären Prozessen arbeiten, noch besser mit linearen. Aber Prozesse mit

  • Trend
  • Saisonalen

Schwankungen sind nicht stationär. Daher versucht man, sie stationär zu machen

—> Trendbereinigung und Saisonbereinigung.

Additive or Multiplicative Zeitreihen?

Um eine erfolgreiche Trendbereinigung und Saisonbereinigung zu erreichen, ist es wichtig, zwischen dem additiven und dem multiplikativen Modell zu wählen, was eine Analyse der Zeitreihen erfordert.

plot.ts(sales_ts_ohne_na,col="blue") #ohne log

Um symmetrisch zu machen, fügen wir log funktion ein.

plot.ts(log(sales_ts_ohne_na),col="red") #mit log

Mit und ohne log funktion ist ähnlich (Also nehmen wir ohne log funktion).

Schrit per schritt Zeitreihenanalyse

Stationäre Prüfen

Es gibt einigen Methoden um Stationarität zu prüfen, unter anderem:

1. Mit White Noise

White Noise das einfachste Beispiel für einen stationären Prozess. Am Besten ist Gausches White Noise wegen folgenden Gründen.

  • Vorhersagbarkeit: Wenn Ihre Zeitreihe White Noise ist, dann ist es per Definition zufällig. Du kannst es nicht vernünftig modellieren und Vorhersagen treffen.

  • Modelldiagnose: Die Fehlerreihe eines Zeitreihen-Prognosemodells sollte idealerweise White Noise sein.

  • Gauss oder Normal distribution ist wichtige Verteilung wegen einigen Gründen

Um White Noise zu identifizeren nutzt man ACF (erste Identification) und Ljung-Box-Pierce-Test (Unkorreliert).

par(mfrow=c(1,1), mar=c(3,3,1,0)+.5, mgp=c(1.6,.6,0))
acf(sales_ts_ohne_na)

Box.test(sales_ts_ohne_na, lag=30, type="Ljung-Box")

    Box-Ljung test

data:  sales_ts_ohne_na
X-squared = 1025.2, df = 30, p-value < 2.2e-16
#quelle: Zeitreihenanalyse Skripten SS2018, Prof. Dr. Irina Penner, HTW Berlin

2. Anderen Test (Unkorreliert) z.B: Augmented Dickey Fuller test, Phillipps-Perron test, Zivot-Andrews test, ADF-GLS test.

  • Augmented Dickey-Fuller test:
#install.packages("tseries")
#library(tseries)
adf.test(sales_ts_ohne_na)

    Augmented Dickey-Fuller Test

data:  sales_ts_ohne_na
Dickey-Fuller = -3.9397, Lag order = 6, p-value = 0.01247
alternative hypothesis: stationary
  • Phillipps-Perron test:
pp.test(sales_ts_ohne_na)
p-value smaller than printed p-value

    Phillips-Perron Unit Root Test

data:  sales_ts_ohne_na
Dickey-Fuller Z(alpha) = -44.195, Truncation lag parameter = 5, p-value = 0.01
alternative hypothesis: stationary

3. Falls die Residuen (ut) unabhängig und normalverteilt sind?

QQ-Plots und Histogramm (nach dem Trendbereinigung und Saisonbereinigung: die Residuen)

Extraktion von Saisonalität und Trend

Es gibt einigen Methoden um Trend oder Saison zu zerlegen, unter anderem:

  • Trend zerlegen: -> Trendresiduen= Data-Season

    • Global Trend

      • Linear

      • Nicht linear

    • Lokal Trend

      • Einfache gleitende Durchschnitte

      • Differenzfilter

      • Faltung: Hintereinanderausführung von Filtern

  • Saison bereinigung: -> Saisonresiduen = Daten - Trend

    • Phasendurchschnittsverfahren

    • Regression mittels Saison-Dummies

    • Regression mit trigonometrischen Polynomen

    • Differenzenbildung

    • Viele etablierte Verfahren als Mischung aus diesen Methoden

Direkt: DECOMPOSE( ) and STL(): Time Series Decomposition in R

Um das Leben einfacher zu machen, bieten einige R-Pakete eine Zerlegung mit einer einzigen Zeile Code.

DECOMPOSE():

decompose(sales_ts_ohne_na, type = "additive") 
$`x`
Time Series:
Start = c(1973, 1) 
End = c(1995, 11) 
Frequency = 12 
  [1] 55 60 68 63 65 61 54 52 46 42 37 30 37 44 55 53 58 50 48 45 41 34 30 24 29 34 44 54 57 51 51
 [32] 53 46 46 46 39 41 53 55 62 55 56 57 59 58 55 49 47 57 68 84 81 78 74 64 74 71 63 55 51 57 63
 [63] 75 85 80 77 68 72 68 70 53 50 53 58 73 72 68 63 64 68 60 54 41 35 43 44 44 36 44 50 55 61 50
 [94] 46 39 33 37 40 49 44 45 38 36 34 28 29 27 29 28 29 36 32 36 34 31 36 39 40 39 33 44 46 57 59
[125] 64 59 51 50 48 51 45 48 52 58 63 61 59 58 52 48 53 55 42 38 48 55 67 60 65 65 63 61 54 52 51
[156] 47 55 59 89 84 75 66 57 52 60 54 48 49 53 59 73 72 62 58 55 56 52 52 43 37 43 55 68 68 64 65
[187] 57 59 54 57 43 42 52 51 58 60 61 58 62 61 49 51 47 40 45 50 58 52 50 50 46 46 38 37 34 29 30
[218] 40 46 46 47 47 43 46 37 41 39 36 48 55 56 53 52 53 52 56 51 48 42 42 44 50 60 66 58 59 55 57
[249] 57 56 53 51 45 58 74 65 65 55 52 59 54 57 45 40 47 47 60 58 63 64 64 63 55 54 44
attr(,"na.removed")
[1] 276 277

$seasonal
            Jan        Feb        Mar        Apr        May        Jun        Jul        Aug
1973  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1974  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1975  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1976  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1977  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1978  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1979  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1980  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1981  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1982  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1983  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1984  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1985  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1986  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1987  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1988  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1989  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1990  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1991  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1992  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1993  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1994  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
1995  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
            Sep        Oct        Nov        Dec
1973  -1.293561  -2.365530  -8.812500 -12.369318
1974  -1.293561  -2.365530  -8.812500 -12.369318
1975  -1.293561  -2.365530  -8.812500 -12.369318
1976  -1.293561  -2.365530  -8.812500 -12.369318
1977  -1.293561  -2.365530  -8.812500 -12.369318
1978  -1.293561  -2.365530  -8.812500 -12.369318
1979  -1.293561  -2.365530  -8.812500 -12.369318
1980  -1.293561  -2.365530  -8.812500 -12.369318
1981  -1.293561  -2.365530  -8.812500 -12.369318
1982  -1.293561  -2.365530  -8.812500 -12.369318
1983  -1.293561  -2.365530  -8.812500 -12.369318
1984  -1.293561  -2.365530  -8.812500 -12.369318
1985  -1.293561  -2.365530  -8.812500 -12.369318
1986  -1.293561  -2.365530  -8.812500 -12.369318
1987  -1.293561  -2.365530  -8.812500 -12.369318
1988  -1.293561  -2.365530  -8.812500 -12.369318
1989  -1.293561  -2.365530  -8.812500 -12.369318
1990  -1.293561  -2.365530  -8.812500 -12.369318
1991  -1.293561  -2.365530  -8.812500 -12.369318
1992  -1.293561  -2.365530  -8.812500 -12.369318
1993  -1.293561  -2.365530  -8.812500 -12.369318
1994  -1.293561  -2.365530  -8.812500 -12.369318
1995  -1.293561  -2.365530  -8.812500           

$trend
Time Series:
Start = c(1973, 1) 
End = c(1995, 11) 
Frequency = 12 
  [1]       NA       NA       NA       NA       NA 52.75000 51.25000 49.91667 48.83333 48.00000
 [11] 47.41667 46.50000 46.00000 45.41667 45.00000 44.33333 43.75000 43.25000 42.58333 41.75000
 [21] 40.83333 40.91667 40.83333 40.91667 41.16667 41.83333 42.25000 43.25000 44.58333 45.83333
 [31] 46.83333 48.41667 49.33333 50.00000 49.83333 50.25000 50.75000 51.25000 52.25000 53.00000
 [41] 53.25000 53.91667 55.25000 56.50000 58.91667 60.50000 62.41667 63.91667 64.50000 65.75000
 [51] 66.83333 67.50000 68.00000 68.33333 68.33333 67.91667 67.16667 67.50000 67.66667 67.91667
 [61] 68.25000 68.08333 67.83333 68.41667 68.25000 68.16667 67.83333 67.41667 67.25000 66.16667
 [71] 65.16667 64.00000 63.66667 63.33333 62.66667 61.33333 60.33333 59.08333 58.25000 57.08333
 [81] 54.66667 51.66667 49.66667 48.58333 47.83333 47.25000 46.41667 45.75000 45.58333 45.41667
 [91] 44.91667 44.58333 45.00000 45.66667 45.75000 44.75000 43.16667 40.91667 39.08333 37.66667
[101] 36.66667 36.33333 35.58333 34.66667 33.58333 32.58333 31.83333 31.50000 31.08333 31.25000
[111] 32.16667 33.08333 34.08333 34.41667 35.75000 37.16667 38.91667 41.16667 43.50000 45.58333
[121] 47.25000 48.41667 49.16667 50.08333 50.58333 51.83333 52.50000 53.50000 54.00000 54.16667
[131] 53.75000 53.66667 53.75000 53.58333 54.00000 54.33333 54.08333 53.25000 52.91667 52.66667
[141] 53.00000 52.91667 53.41667 54.00000 54.91667 56.00000 56.08333 55.83333 56.58333 57.33333
[151] 57.91667 58.25000 60.08333 62.08333 62.91667 63.00000 62.50000 61.75000 62.25000 62.41667
[161] 62.16667 62.33333 62.16667 62.16667 60.83333 59.83333 58.75000 58.08333 57.91667 58.25000
[171] 57.58333 57.41667 57.00000 56.00000 55.16667 54.83333 54.41667 54.08333 54.25000 54.83333
[181] 55.00000 55.25000 55.41667 55.83333 55.83333 56.25000 57.00000 56.66667 55.83333 55.16667
[191] 54.91667 54.33333 54.75000 54.91667 54.50000 54.00000 54.33333 54.16667 53.58333 53.50000
[201] 53.50000 52.83333 51.91667 51.25000 49.91667 48.66667 47.75000 46.58333 45.50000 44.58333
[211] 43.33333 42.50000 41.50000 41.00000 40.75000 40.50000 40.25000 40.25000 40.16667 40.50000
[221] 40.91667 41.50000 43.00000 44.25000 45.08333 45.66667 46.08333 46.58333 47.33333 48.16667
[231] 49.33333 49.91667 50.16667 50.66667 50.33333 49.91667 50.25000 51.33333 51.83333 52.33333
[241] 52.58333 52.66667 53.16667 53.83333 54.75000 55.50000 55.58333 56.25000 57.41667 57.33333
[251] 57.91667 57.58333 57.33333 57.50000 57.25000 57.33333 56.66667 55.75000 55.91667 55.00000
[261] 53.83333 53.25000 53.08333 53.83333 54.83333 55.16667 55.25000 55.00000 54.91667       NA
[271]       NA       NA       NA       NA       NA

$random
              Jan          Feb          Mar          Apr          May          Jun          Jul
1973           NA           NA           NA           NA           NA   3.60795455   1.44128788
1974  -1.95643939  -0.14962121   0.93750000   0.60416667   6.98674242   2.10795455   4.10795455
1975  -5.12310606  -6.56628788  -7.31250000   2.68750000   5.15340909   0.52462121   2.85795455
1976  -2.70643939   3.01704545  -6.31250000   0.93750000  -5.51325758  -2.55871212   0.44128788
1977  -0.45643939   3.51704545   8.10416667   5.43750000   2.73674242   1.02462121  -5.64204545
1978  -4.20643939  -3.81628788  -1.89583333   8.52083333   4.48674242   4.19128788  -1.14204545
1979  -3.62310606  -4.06628788   1.27083333   2.60416667   0.40340909  -0.72537879   4.44128788
1980   2.21022727  -1.98295455 -11.47916667 -17.81250000  -8.84659091  -0.05871212   8.77462121
1981   0.87689394   0.35037879   0.85416667  -1.72916667   1.07007576  -2.97537879  -0.89204545
1982   3.96022727  -0.98295455  -5.22916667  -9.14583333  -5.34659091  -5.05871212  -6.05871212
1983   3.79356061  -1.14962121  -1.22916667   0.85416667   6.15340909   2.52462121  -2.80871212
1984   5.29356061   5.68371212  -0.06250000  -1.39583333  -2.34659091   0.10795455  -2.22537879
1985   0.12689394   0.26704545   1.85416667  -3.89583333   1.15340909   3.02462121   3.77462121
1986  -0.45643939  -1.48295455  17.68750000  13.52083333   5.57007576  -0.97537879  -6.47537879
1987   2.12689394   2.01704545   6.35416667   6.52083333  -2.26325758  -2.64204545  -1.47537879
1988  -4.95643939   1.01704545   3.52083333   4.10416667   0.90340909   4.10795455  -1.30871212
1989   4.29356061  -2.64962121  -5.56250000  -2.06250000  -0.59659091  -0.80871212   7.10795455
1990   2.12689394   2.60037879   1.18750000  -2.64583333  -2.76325758   0.77462121   1.35795455
1991  -3.20643939   1.01704545  -3.22916667  -2.56250000  -1.17992424   0.85795455  -1.30871212
1992   7.71022727   8.10037879  -2.39583333  -4.97916667  -5.42992424  -2.30871212   0.35795455
1993  -1.53977273  -1.39962121  -2.22916667   4.10416667  -4.01325758  -1.14204545  -1.89204545
1994  -5.28977273   1.76704545   7.68750000  -0.39583333   1.07007576  -5.39204545  -5.22537879
1995  -0.78977273  -6.89962121  -4.31250000  -5.06250000   0.82007576           NA           NA
              Aug          Sep          Oct          Nov          Dec
1973  -0.72916667  -1.53977273  -3.63446970  -1.60416667  -4.13068182
1974   0.43750000   1.46022727  -4.55113636  -2.02083333  -4.54734848
1975   1.77083333  -2.03977273  -1.63446970   4.97916667   1.11931818
1976  -0.31250000   0.37689394  -3.13446970  -4.60416667  -4.54734848
1977   3.27083333   5.12689394  -2.13446970  -3.85416667  -4.54734848
1978   1.77083333   2.04356061   6.19886364  -3.35416667  -1.63068182
1979   8.10416667   6.62689394   4.69886364   0.14583333  -1.21401515
1980  13.60416667   6.29356061   2.69886364   2.06250000   0.61931818
1981  -3.47916667  -4.28977273  -1.21780303   3.97916667   9.86931818
1982  -3.97916667   1.37689394   1.19886364   4.31250000  -0.21401515
1983  -6.31250000  -4.70643939  -0.80113636   0.06250000   6.70265152
1984  -7.47916667   1.29356061   4.44886364  -2.60416667  -3.63068182
1985  -0.06250000  -4.78977273  -7.71780303  -3.10416667  -3.63068182
1986 -12.97916667   0.46022727  -3.46780303  -1.93750000   3.28598485
1987  -1.64583333  -1.12310606   0.28219697  -2.43750000  -5.46401515
1988  -0.47916667  -0.53977273   4.19886364  -3.10416667   0.03598485
1989   4.68750000  -3.20643939   0.53219697   3.89583333   1.11931818
1990   0.68750000  -2.20643939  -1.63446970   2.06250000   0.86931818
1991  -1.06250000  -6.78977273  -2.30113636   1.72916667   1.78598485
1992   3.27083333   2.04356061  -0.96780303  -1.02083333   2.03598485
1993  -2.06250000   0.87689394   1.03219697   3.89583333   5.78598485
1994   1.18750000   1.46022727   6.11553030   0.72916667  -1.46401515
1995           NA           NA           NA           NA             

$figure
 [1]  -7.043561  -1.267045   9.062500   8.062500   7.263258   4.642045   1.308712   2.812500
 [9]  -1.293561  -2.365530  -8.812500 -12.369318

$type
[1] "additive"

attr(,"class")
[1] "decomposed.ts"
dec=decompose(sales_ts_ohne_na)
plot(dec)

plot(sales_ts_ohne_na, main="Sales ", ylab="")
lines((dec$trend), col=4)
lines((dec$seasonal+dec$trend), col=2)

STL():

par(mfrow=c(1,1))
dec.pass=stl(sales_ts_ohne_na,"periodic")
dec.pass
 Call:
 stl(x = sales_ts_ohne_na, s.window = "periodic")

Components
          seasonal    trend     remainder
Jan 1973 -7.052493 61.82257   0.229924553
Feb 1973 -1.230381 60.22258   1.007797644
Mar 1973 -1.230381 58.62260  10.607783268
Apr 1973 -1.230381 57.06243   7.167954891
May 1973 -1.230381 55.50225  10.728126513
Jun 1973 -1.230381 54.00072   8.229659946
Jul 1973 -1.230381 52.49919   2.731193379
Aug 1973 -1.230381 51.05776   2.172624177
Sep 1973 -1.230381 49.61633  -2.385945024
Oct 1973 -1.230382 48.47375  -5.243364787
Nov 1973 -1.230382 47.33117  -9.100784549
Dec 1973 -1.230382 46.71048 -15.480098727
Jan 1974 -1.230382 46.08979  -7.859412905
Feb 1974 -7.052493 45.68398   5.368513088
Mar 1974 -1.230381 45.27817  10.952215020
Apr 1974 -1.230381 44.83067   9.399713294
May 1974 -1.230381 44.38317  14.847211579
Jun 1974 -1.230381 43.73419   7.496194529
Jul 1974 -1.230381 43.08520   6.145177480
Aug 1974 -1.230381 42.27816   3.952222771
Sep 1974 -1.230381 41.47111   0.759268063
Oct 1974 -1.230381 40.95995  -5.729568248
Nov 1974 -1.230382 40.44879  -9.218404558
Dec 1974 -1.230382 40.52756 -15.297176051
Jan 1975 -1.230382 40.60633 -10.375947545
Feb 1975 -7.052493 41.25403  -0.201534597
Mar 1975 -1.230381 41.90173   3.328654211
Apr 1975 -1.230381 42.99659  12.233795016
May 1975 -1.230381 44.09145  14.138935831
Jun 1975 -1.230381 45.38910   6.841279047
Jul 1975 -1.230381 46.68676   5.543622263
Aug 1975 -1.230381 47.76362   6.466758666
Sep 1975 -1.230381 48.84049  -1.610104931
Oct 1975 -1.230381 49.39289  -2.162510337
Nov 1975 -1.230382 49.94530  -2.714915742
Dec 1975 -1.230382 50.26758 -10.037202259
Jan 1976 -1.230382 50.58987  -8.359488776
Feb 1976 -7.052493 51.09301   8.959484139
Mar 1976 -1.230381 51.59615   4.634232914
Apr 1976 -1.230381 52.24755  10.982828918
May 1976 -1.230381 52.89896   3.331424933
Jun 1976 -1.230381 53.78671   3.443671725
Jul 1976 -1.230381 54.67446   3.555918518
Aug 1976 -1.230381 56.14859   4.081794138
Sep 1976 -1.230381 57.62271   1.607669758
Oct 1976 -1.230381 59.43175  -3.201368589
Nov 1976 -1.230382 61.24079 -11.010406936
Dec 1976 -1.230382 62.77446 -14.544075741
Jan 1977 -1.230382 64.30813  -6.077744546
Feb 1977 -7.052493 65.44889   9.603601456
Mar 1977 -1.230381 66.58966  18.640723319
Apr 1977 -1.230381 67.32774  14.902643624
May 1977 -1.230381 68.06582  11.164563940
Jun 1977 -1.230381 68.18920   7.041185814
Jul 1977 -1.230381 68.31257  -3.082192312
Aug 1977 -1.230381 67.95156   7.278823026
Sep 1977 -1.230381 67.59054   4.639838364
Oct 1977 -1.230381 67.45458  -3.224202775
Nov 1977 -1.230382 67.31863 -11.088243914
Dec 1977 -1.230382 67.50216 -15.271783182
Jan 1978 -1.230382 67.68570  -9.455322450
Feb 1978 -7.052493 67.90944   2.143055308
Mar 1978 -1.230381 68.13317   8.097208926
Apr 1978 -1.230381 68.31711  17.913267540
May 1978 -1.230381 68.50105  12.729326164
Jun 1978 -1.230381 68.43810   9.792276740
Jul 1978 -1.230381 68.37515   0.855227315
Aug 1978 -1.230381 67.82881   5.401566694
Sep 1978 -1.230381 67.28248   1.947906074
Oct 1978 -1.230381 66.41100   4.819378561
Nov 1978 -1.230382 65.53953 -11.309148952
Dec 1978 -1.230382 64.69248 -13.462100587
Jan 1979 -1.230382 63.84543  -9.615052222
Feb 1979 -7.052493 63.18734   1.865149046
Mar 1979 -1.230381 62.52925  11.701126174
Apr 1979 -1.230381 61.77447  11.455910354
May 1979 -1.230381 61.01969   8.210694543
Jun 1979 -1.230381 60.03600   4.194376714
Jul 1979 -1.230381 59.05232   6.178058884
Aug 1979 -1.230381 57.45553  11.774849495
Sep 1979 -1.230381 55.85874   5.371640107
Oct 1979 -1.230381 53.66388   1.566498979
Nov 1979 -1.230382 51.46902  -9.238642149
Dec 1979 -1.230382 49.63182 -13.401438080
Jan 1980 -1.230382 47.79462  -3.564234011
Feb 1980 -7.052493 46.81209   4.240401131
Mar 1980 -1.230381 45.82957  -0.599187867
Apr 1980 -1.230381 45.52741  -8.297031534
May 1980 -1.230381 45.22526   0.005124809
Jun 1980 -1.230381 45.30657   5.923814421
Jul 1980 -1.230381 45.38788  10.842504033
Aug 1980 -1.230381 45.63098  16.599400091
Sep 1980 -1.230381 45.87409   5.356296149
Oct 1980 -1.230381 45.81279   1.417588045
Nov 1980 -1.230382 45.75150  -5.521120058
Dec 1980 -1.230382 44.67895 -10.448565543
Jan 1981 -1.230382 43.60639  -5.376011028
Feb 1981 -7.052493 41.86292   5.189571391
Mar 1981 -1.230381 40.11945  10.110929670
Apr 1981 -1.230381 38.66696   6.563416013
May 1981 -1.230381 37.21448   9.015902365
Jun 1981 -1.230381 36.32708   2.903300191
Jul 1981 -1.230381 35.43968   1.790698017
Aug 1981 -1.230381 34.73098   0.499402137
Sep 1981 -1.230381 34.02228  -4.791893744
Oct 1981 -1.230381 33.31112  -3.080734148
Nov 1981 -1.230382 32.59996  -4.369574553
Dec 1981 -1.230382 32.11584  -1.885457667
Jan 1982 -1.230382 31.63172  -2.401340780
Feb 1982 -7.052493 31.63684   4.415655286
Mar 1982 -1.230381 31.64195   5.588427213
Apr 1982 -1.230381 32.17310   1.057285681
May 1982 -1.230381 32.70424   4.526144158
Jun 1982 -1.230381 33.77989   1.450490687
Jul 1982 -1.230381 34.85554  -2.625162784
Aug 1982 -1.230381 36.57721   0.653170491
Sep 1982 -1.230381 38.29888   1.931503767
Oct 1982 -1.230381 40.44169   0.788686530
Nov 1982 -1.230382 42.58451  -2.354130707
Dec 1982 -1.230382 44.52271 -10.292325593
Jan 1983 -1.230382 46.46090  -1.230520478
Feb 1983 -7.052493 47.72738   5.325109751
Mar 1983 -1.230381 48.99387   9.236515840
Apr 1983 -1.230381 49.74380  10.486585888
May 1983 -1.230381 50.49373  14.736655946
Jun 1983 -1.230381 51.24299   8.987395230
Jul 1983 -1.230381 51.99225   0.238134514
Aug 1983 -1.230381 52.67312  -1.442741965
Sep 1983 -1.230381 53.35400  -4.123618444
Oct 1983 -1.230381 53.68724  -1.456858872
Nov 1983 -1.230382 54.02048  -7.790099301
Dec 1983 -1.230382 54.08807  -4.857688326
Jan 1984 -1.230382 54.15566  -0.925277350
Feb 1984 -7.052493 54.15654  10.895951036
Mar 1984 -1.230381 54.15743  10.072955283
Apr 1984 -1.230381 53.94335   8.287035050
May 1984 -1.230381 53.72927   6.501114827
Jun 1984 -1.230381 53.35159   5.878794218
Jul 1984 -1.230381 52.97391   0.256473610
Aug 1984 -1.230381 52.84330  -3.612921373
Sep 1984 -1.230381 52.71270   1.517683643
Oct 1984 -1.230381 52.99779   3.232590408
Nov 1984 -1.230382 53.28288 -10.052502828
Dec 1984 -1.230382 53.89935 -14.668963881
Jan 1985 -1.230382 54.51581  -5.285424934
Feb 1985 -7.052493 55.13482   6.917674886
Mar 1985 -1.230381 55.75383  12.476550566
Apr 1985 -1.230381 56.18577   5.044613866
May 1985 -1.230381 56.61770   9.612677176
Jun 1985 -1.230381 57.10283   9.127555709
Jul 1985 -1.230381 57.58795   6.642434241
Aug 1985 -1.230381 58.43915   3.791230130
Sep 1985 -1.230381 59.29036  -4.059973981
Oct 1985 -1.230381 60.42009  -7.189710878
Nov 1985 -1.230382 61.54983  -9.319447775
Dec 1985 -1.230382 62.19821 -13.967825337
Jan 1986 -1.230382 62.84658  -6.616202899
Feb 1986 -7.052493 62.92917   3.123318730
Mar 1986 -1.230381 63.01176  27.218616220
Apr 1986 -1.230381 62.88496  22.345416497
May 1986 -1.230381 62.75816  13.472216785
Jun 1986 -1.230381 62.35540   4.874985273
Jul 1986 -1.230381 61.95263  -3.722246238
Aug 1986 -1.230381 61.26809  -8.037710633
Sep 1986 -1.230381 60.58356   0.646824972
Oct 1986 -1.230381 59.90096  -4.670573835
Nov 1986 -1.230382 59.21835  -9.987972643
Dec 1986 -1.230382 58.90597  -8.675586153
Jan 1987 -1.230382 58.59358  -4.363199664
Feb 1987 -7.052493 58.36275   7.689747268
Mar 1987 -1.230381 58.13191  16.098470061
Apr 1987 -1.230381 57.62558  15.604805273
May 1987 -1.230381 57.11924   6.111140495
Jun 1987 -1.230381 56.35507   2.875312791
Jul 1987 -1.230381 55.59090   0.639485088
Aug 1987 -1.230381 54.96140   2.268982687
Sep 1987 -1.230381 54.33190  -1.101519715
Oct 1987 -1.230381 54.20957  -0.979187443
Nov 1987 -1.230382 54.08724  -9.856855171
Dec 1987 -1.230382 54.40582 -16.175437963
Jan 1988 -1.230382 54.72440 -10.494020756
Feb 1988 -7.052493 55.09893   6.953567185
Mar 1988 -1.230381 55.47345  13.756930985
Apr 1988 -1.230381 55.80992  13.420463651
May 1988 -1.230381 56.14638   9.083996327
Jun 1988 -1.230381 56.36676   9.863617967
Jul 1988 -1.230381 56.58714   1.643239607
Aug 1988 -1.230381 56.37484   3.855540536
Sep 1988 -1.230381 56.16254  -0.932158535
Oct 1988 -1.230381 55.65706   2.573317646
Nov 1988 -1.230382 55.15159 -10.921206172
Dec 1988 -1.230382 54.85661 -11.626228323
Jan 1989 -1.230382 54.56163  -1.331250474
Feb 1989 -7.052493 54.46603   3.586465130
Mar 1989 -1.230381 54.37042   4.859956593
Apr 1989 -1.230381 54.27968   6.950704976
May 1989 -1.230381 54.18893   8.041453369
Jun 1989 -1.230381 54.09677   5.133609188
Jul 1989 -1.230381 54.00462   9.225765008
Aug 1989 -1.230381 53.81896   8.411425078
Sep 1989 -1.230381 53.63330  -3.402914852
Oct 1989 -1.230381 53.07898  -0.848593955
Nov 1989 -1.230382 52.52465  -4.294273058
Dec 1989 -1.230382 51.54381 -10.313432596
Jan 1990 -1.230382 50.56297  -4.332592133
Feb 1990 -7.052493 49.39765   7.654843676
Mar 1990 -1.230381 48.23233  10.998055345
Apr 1990 -1.230381 47.09863   6.131747611
May 1990 -1.230381 45.96494   5.265439886
Jun 1990 -1.230381 44.88695   6.343430929
Jul 1990 -1.230381 43.80896   3.421421972
Aug 1990 -1.230381 42.94279   4.287592812
Sep 1990 -1.230381 42.07662  -2.846236349
Oct 1990 -1.230381 41.48288  -3.252497167
Nov 1990 -1.230382 40.88914  -5.658757986
Dec 1990 -1.230382 40.59162 -10.361238445
Jan 1991 -1.230382 40.29410  -9.063718904
Feb 1991 -7.052493 40.22752   6.824971443
Mar 1991 -1.230381 40.16094   7.069437649
Apr 1991 -1.230381 40.41417   6.816206282
May 1991 -1.230381 40.66741   7.562974925
Jun 1991 -1.230381 41.41709   6.813288519
Jul 1991 -1.230381 42.16678   2.063602113
Aug 1991 -1.230381 43.25418   3.976205452
Sep 1991 -1.230381 44.34157  -6.111191210
Oct 1991 -1.230381 45.20791  -2.977525204
Nov 1991 -1.230382 46.07424  -5.843859197
Dec 1991 -1.230382 46.74221  -9.511824651
Jan 1992 -1.230382 47.41017   1.820209895
Feb 1992 -7.052493 48.10287  13.949627493
Mar 1992 -1.230381 48.79556   8.434820951
Apr 1992 -1.230381 49.29445   4.935927326
May 1992 -1.230381 49.79335   3.437033712
Jun 1992 -1.230381 49.96677   4.263610473
Jul 1992 -1.230381 50.14019   3.090187233
Aug 1992 -1.230381 50.35278   6.877603252
Sep 1992 -1.230381 50.56536   1.665019271
Oct 1992 -1.230381 51.04985  -1.819471747
Nov 1992 -1.230382 51.53434  -8.303962765
Dec 1992 -1.230382 51.94083  -8.710451994
Jan 1993 -1.230382 52.34732  -7.116941223
Feb 1993 -7.052493 52.67858   4.373910275
Mar 1993 -1.230381 53.00984   8.220537634
Apr 1993 -1.230381 53.57410  13.656285846
May 1993 -1.230381 54.13835   5.092034068
Jun 1993 -1.230381 54.80254   5.427844973
Jul 1993 -1.230381 55.46673   0.763655877
Aug 1993 -1.230381 56.11835   2.112035819
Sep 1993 -1.230381 56.76997   1.460415761
Oct 1993 -1.230381 57.24291  -0.012530697
Nov 1993 -1.230382 57.71586  -3.485477155
Dec 1993 -1.230382 57.80625  -5.575867440
Jan 1994 -1.230382 57.89664 -11.666257724
Feb 1994 -7.052493 57.66865   7.383846260
Mar 1994 -1.230381 57.44065  17.789726104
Apr 1994 -1.230381 57.06520   9.165177704
May 1994 -1.230381 56.68975   9.540629314
Jun 1994 -1.230381 56.19324   0.037137467
Jul 1994 -1.230381 55.69674  -2.466354380
Aug 1994 -1.230381 55.08499   5.145386717
Sep 1994 -1.230381 54.47325   0.757127815
Oct 1994 -1.230381 54.05382   4.176559377
Nov 1994 -1.230382 53.63439  -7.404009061
Dec 1994 -1.230382 53.80952 -12.579137363
Jan 1995 -1.230382 53.98465  -5.754265665
Feb 1995 -7.052493 54.40554  -0.353043748
Mar 1995 -1.230381 54.82643   6.403954028
Apr 1995 -1.230381 55.09259   4.137791239
May 1995 -1.230381 55.35875   8.871628459
Jun 1995 -1.230381 55.64907   9.581308573
Jul 1995 -1.230381 55.93939   9.290988686
Aug 1995 -1.230381 56.30171   7.928676013
Sep 1995 -1.230381 56.66402  -0.433636660
Oct 1995 -1.230381 57.05055  -1.820166184
Nov 1995 -1.230382 57.43708 -12.206695709
plot(dec.pass) 
#plot daten und modell
par(mfrow=c(3,1), mar=c(3,2,1,0)+.5, mgp=c(1.6,.6,0))

plot(sales_ts_ohne_na, main="Sales: saisonale Zerlegung mit stl", ylab="")
lines((dec.pass$time.series[,2]), col=4)
lines((dec.pass$time.series[,2]+dec.pass$time.series[,1]), col=2)
#Residuen
residuen=dec.pass$time.series[,3]
plot(residuen)                  
qqnorm(residuen)
qqline(residuen, col=2)

acf(residuen)

#Rquadrat(exp(dec.pass$time.series[,2]+dec.pass$time.series[,1]), passb) #Bestimmheitmaß

4. Modellen

AR Modelle:

1. ACF und PACF als erste identifikation:

  • ACF: exponential abklingelnd
  • PACF: ordnung (Grad) der Modellen: der PACF bricht ab (außer KI: 95%)
par(mfrow=c(2,1))
acf(sales_ts_ohne_na)
pacf(sales_ts_ohne_na)

#oder
acf2(sales_ts_ohne_na)
        ACF  PACF
 [1,]  0.86  0.86
 [2,]  0.67 -0.24
 [3,]  0.47 -0.13
 [4,]  0.34  0.13
 [5,]  0.28  0.15
 [6,]  0.24 -0.13
 [7,]  0.22  0.09
 [8,]  0.22  0.09
 [9,]  0.30  0.33
[10,]  0.43  0.27
[11,]  0.55  0.02
[12,]  0.61 -0.01
[13,]  0.52 -0.32
[14,]  0.37 -0.09
[15,]  0.20 -0.13
[16,]  0.08 -0.02
[17,]  0.01 -0.06
[18,] -0.07 -0.13
[19,] -0.10  0.02
[20,] -0.12 -0.08
[21,] -0.05  0.12
[22,]  0.08 -0.02
[23,]  0.18 -0.02
[24,]  0.24  0.05
[25,]  0.17 -0.13
[26,]  0.03 -0.15
[27,] -0.12 -0.06
[28,] -0.23  0.02
[29,] -0.29 -0.01
[30,] -0.35 -0.01
[31,] -0.37  0.05
[32,] -0.37 -0.04
[33,] -0.30  0.02
[34,] -0.18 -0.04
[35,] -0.09 -0.14
[36,] -0.05 -0.02
[37,] -0.13 -0.17
[38,] -0.24 -0.07
[39,] -0.37 -0.01
[40,] -0.44  0.08
[41,] -0.47  0.02
[42,] -0.52 -0.07
[43,] -0.51  0.06
[44,] -0.50 -0.06
[45,] -0.42 -0.10
[46,] -0.30  0.05
[47,] -0.18  0.06
[48,] -0.12 -0.05

Kandidaten: 1, 2, 3,4,5….usw

2. Schätzen von AR-Parametern:

  • Conditional bzw. Unconditional Least Sum of Squares (CLS bzw. ULS)
  • Conditional bzw. Unconditional Maximum Likelihood (CML bzw. UML)
  • Burg
  • Yule Walker (YW)
#Ordnung suchen
mm1_mle=ar.mle(sales_ts_ohne_na)
mm1_mle$order # Ordnung suchen 
[1] 10
mm2_yw=ar.yw(sales_ts_ohne_na)
mm2_yw$order # Ordnung suchen  
[1] 15
mm3_ols=ar.ols(sales_ts_ohne_na)
mm3_ols$order # Ordnung suchen
[1] 21
mm4_burg=ar.burg(sales_ts_ohne_na)
mm4_burg$order # Ordnung suchen 
[1] 21

Graphische Vergleich jeweils methoden:

#Graphic Ordnung suchen
aic=mm1_mle$aic  # For plotting below.
plot(c(0:(length(aic)-1)),aic,type='h',xlab='order',ylab='aic')
lines(0:(length(mm2_yw$aic)-1), mm2_yw$aic, lty=4, col=2)
lines(0:(length(mm3_ols$aic)-1), mm3_ols$aic, lty=4, col=3)
lines(0:(length(mm4_burg$aic)-1), mm4_burg$aic, lty=4, col=4)
lines(0:(length(aic)-1),aic,lty=2)
colors <- c("green","blue","red", "black")
legend("topright", c(paste("OLS"),
                     paste("Burg"),
                     paste("YW"),
                     paste("MLE")),
       lwd = 1, cex=1, col=colors, pt.lwd = 1, lty=4) 

Graphische Vergleich der Modellen:

#Grafischer Vergleich
plot(sales_ts_ohne_na, main="Vergleich Modelle")
lines(fitted(mm2_yw),col="blue")
lines(fitted(mm1_mle),col="red")
lines(fitted(mm3_ols),col=6)
lines(fitted(mm4_burg),col=3)
colors <- c("blue","red",6, 3)
legend("top", c(paste("YW"),
                paste("MLE"),
                paste("OLS"),
                paste("BURG")),
       lwd = 1, cex=1, col=colors, pt.lwd = 1, lty=2) 

3. Gute der Modellen direkt mit sarima():

Fazit: Ordnung Kandidaten sind 10, 15, 21

sarima(sales_ts_ohne_na,10,0,0)$ttable
initial  value 2.485953 
iter   2 value 2.178505
iter   3 value 1.991777
iter   4 value 1.956337
iter   5 value 1.948356
iter   6 value 1.829770
iter   7 value 1.678623
iter   8 value 1.665761
iter   9 value 1.653535
iter  10 value 1.650139
iter  11 value 1.647349
iter  12 value 1.646675
iter  13 value 1.646441
iter  14 value 1.646403
iter  15 value 1.646374
iter  16 value 1.646371
iter  17 value 1.646369
iter  18 value 1.646369
iter  19 value 1.646369
iter  19 value 1.646369
iter  19 value 1.646369
final  value 1.646369 
converged
initial  value 1.645266 
iter   2 value 1.645189
iter   3 value 1.645112
iter   4 value 1.645071
iter   5 value 1.645054
iter   6 value 1.645051
iter   7 value 1.645042
iter   8 value 1.645038
iter   9 value 1.645036
iter  10 value 1.645036
iter  11 value 1.645035
iter  12 value 1.645033
iter  13 value 1.645030
iter  14 value 1.645027
iter  15 value 1.645025
iter  16 value 1.645025
iter  17 value 1.645025
iter  18 value 1.645025
iter  18 value 1.645025
iter  18 value 1.645025
final  value 1.645025 
converged
      Estimate     SE t.value p.value
ar1     0.9300 0.0577 16.1276  0.0000
ar2     0.0127 0.0806  0.1580  0.8746
ar3    -0.2370 0.0796 -2.9754  0.0032
ar4    -0.0890 0.0809 -1.0995  0.2725
ar5     0.2380 0.0805  2.9568  0.0034
ar6    -0.0943 0.0806 -1.1699  0.2431
ar7     0.0795 0.0806  0.9862  0.3250
ar8    -0.2344 0.0794 -2.9529  0.0034
ar9     0.0415 0.0810  0.5129  0.6084
ar10    0.2796 0.0580  4.8221  0.0000
xmean  52.5640 3.8136 13.7832  0.0000

sarima(sales_ts_ohne_na, 15,0,0)$ttable
initial  value 2.481688 
iter   2 value 2.198492
iter   3 value 2.189123
iter   4 value 2.106546
iter   5 value 1.794528
iter   6 value 1.702350
iter   7 value 1.632242
iter   8 value 1.599626
iter   9 value 1.581282
iter  10 value 1.573771
iter  11 value 1.565390
iter  12 value 1.564197
iter  13 value 1.563744
iter  14 value 1.563715
iter  15 value 1.563640
iter  16 value 1.563626
iter  17 value 1.563623
iter  18 value 1.563622
iter  19 value 1.563618
iter  20 value 1.563615
iter  21 value 1.563607
iter  22 value 1.563604
iter  23 value 1.563603
iter  24 value 1.563602
iter  25 value 1.563602
iter  25 value 1.563602
iter  25 value 1.563602
final  value 1.563602 
converged
initial  value 1.567435 
iter   2 value 1.567307
iter   3 value 1.567264
iter   4 value 1.567221
iter   5 value 1.567196
iter   6 value 1.567148
iter   7 value 1.567126
iter   8 value 1.567113
iter   9 value 1.567107
iter  10 value 1.567107
iter  11 value 1.567107
iter  12 value 1.567106
iter  13 value 1.567106
iter  14 value 1.567106
iter  15 value 1.567106
iter  16 value 1.567106
iter  17 value 1.567106
iter  18 value 1.567106
iter  18 value 1.567106
iter  18 value 1.567106
final  value 1.567106 
converged
      Estimate     SE t.value p.value
ar1     0.8717 0.0594 14.6762  0.0000
ar2     0.0092 0.0794  0.1154  0.9083
ar3    -0.0889 0.0783 -1.1351  0.2574
ar4    -0.0519 0.0765 -0.6784  0.4981
ar5     0.1918 0.0763  2.5144  0.0125
ar6    -0.0848 0.0758 -1.1194  0.2640
ar7     0.0308 0.0759  0.4053  0.6856
ar8    -0.1482 0.0754 -1.9652  0.0505
ar9     0.0226 0.0762  0.2962  0.7673
ar10    0.2065 0.0761  2.7127  0.0071
ar11   -0.0167 0.0767 -0.2178  0.8277
ar12    0.3021 0.0770  3.9247  0.0001
ar13   -0.2284 0.0791 -2.8890  0.0042
ar14    0.0319 0.0806  0.3955  0.6928
ar15   -0.1605 0.0603 -2.6632  0.0082
xmean  52.5919 2.4805 21.2018  0.0000

sarima(sales_ts_ohne_na, 21,0,0)$ttable
initial  value 2.490162 
iter   2 value 2.179536
iter   3 value 2.062500
iter   4 value 1.920823
iter   5 value 1.772078
iter   6 value 1.655608
iter   7 value 1.625625
iter   8 value 1.602186
iter   9 value 1.565626
iter  10 value 1.555343
iter  11 value 1.545142
iter  12 value 1.538298
iter  13 value 1.537900
iter  14 value 1.537299
iter  15 value 1.537296
iter  16 value 1.536651
iter  17 value 1.536628
iter  18 value 1.536616
iter  19 value 1.536609
iter  20 value 1.536605
iter  21 value 1.536592
iter  22 value 1.536585
iter  23 value 1.536581
iter  24 value 1.536580
iter  25 value 1.536579
iter  26 value 1.536579
iter  26 value 1.536579
iter  26 value 1.536579
final  value 1.536579 
converged
initial  value 1.536690 
iter   2 value 1.536583
iter   3 value 1.536506
iter   4 value 1.536403
iter   5 value 1.536382
iter   6 value 1.536373
iter   7 value 1.536224
iter   8 value 1.536202
iter   9 value 1.536179
iter  10 value 1.536175
iter  11 value 1.536173
iter  12 value 1.536172
iter  13 value 1.536172
iter  14 value 1.536171
iter  15 value 1.536171
iter  16 value 1.536171
iter  17 value 1.536171
iter  18 value 1.536171
iter  19 value 1.536171
iter  20 value 1.536171
iter  21 value 1.536171
iter  21 value 1.536171
iter  21 value 1.536171
final  value 1.536171 
converged
      Estimate     SE t.value p.value
ar1     0.8732 0.0595 14.6777  0.0000
ar2    -0.0292 0.0782 -0.3729  0.7095
ar3    -0.0822 0.0779 -1.0557  0.2921
ar4    -0.0605 0.0775 -0.7815  0.4352
ar5     0.1595 0.0772  2.0660  0.0398
ar6    -0.0091 0.0777 -0.1176  0.9065
ar7     0.0212 0.0773  0.2741  0.7843
ar8    -0.0602 0.0773 -0.7783  0.4371
ar9    -0.0313 0.0771 -0.4056  0.6854
ar10    0.2014 0.0754  2.6705  0.0081
ar11   -0.0372 0.0763 -0.4875  0.6263
ar12    0.2892 0.0755  3.8330  0.0002
ar13   -0.1859 0.0775 -2.3975  0.0172
ar14    0.0155 0.0784  0.1975  0.8436
ar15   -0.1311 0.0784 -1.6728  0.0956
ar16    0.0029 0.0790  0.0372  0.9704
ar17    0.0658 0.0790  0.8327  0.4058
ar18   -0.1585 0.0790 -2.0055  0.0460
ar19    0.1082 0.0796  1.3590  0.1754
ar20   -0.2335 0.0798 -2.9270  0.0037
ar21    0.1507 0.0611  2.4676  0.0143
xmean  52.6856 2.1056 25.0221  0.0000

Welche Modell ist am Besten?: Mit AIC oder BIC.

AIC:

#Mit AIC
sarima(sales_ts_ohne_na,10,0,0)$AIC
initial  value 2.485953 
iter   2 value 2.178505
iter   3 value 1.991777
iter   4 value 1.956337
iter   5 value 1.948356
iter   6 value 1.829770
iter   7 value 1.678623
iter   8 value 1.665761
iter   9 value 1.653535
iter  10 value 1.650139
iter  11 value 1.647349
iter  12 value 1.646675
iter  13 value 1.646441
iter  14 value 1.646403
iter  15 value 1.646374
iter  16 value 1.646371
iter  17 value 1.646369
iter  18 value 1.646369
iter  19 value 1.646369
iter  19 value 1.646369
iter  19 value 1.646369
final  value 1.646369 
converged
initial  value 1.645266 
iter   2 value 1.645189
iter   3 value 1.645112
iter   4 value 1.645071
iter   5 value 1.645054
iter   6 value 1.645051
iter   7 value 1.645042
iter   8 value 1.645038
iter   9 value 1.645036
iter  10 value 1.645036
iter  11 value 1.645035
iter  12 value 1.645033
iter  13 value 1.645030
iter  14 value 1.645027
iter  15 value 1.645025
iter  16 value 1.645025
iter  17 value 1.645025
iter  18 value 1.645025
iter  18 value 1.645025
iter  18 value 1.645025
final  value 1.645025 
converged
[1] 4.356501

sarima(sales_ts,15,0,1)$AIC 
initial  value 2.477969 
iter   2 value 2.072883
iter   3 value 1.821983
iter   4 value 1.681173
iter   5 value 1.639634
iter   6 value 1.613854
iter   7 value 1.595848
iter   8 value 1.589525
iter   9 value 1.579773
iter  10 value 1.577979
iter  11 value 1.576519
iter  12 value 1.576082
iter  13 value 1.575352
iter  14 value 1.573996
iter  15 value 1.573032
iter  16 value 1.572449
iter  17 value 1.571974
iter  18 value 1.571453
iter  19 value 1.570694
iter  20 value 1.570000
iter  21 value 1.569741
iter  22 value 1.569332
iter  23 value 1.569077
iter  24 value 1.568539
iter  25 value 1.568131
iter  26 value 1.567837
iter  27 value 1.567613
iter  28 value 1.567547
iter  29 value 1.567314
iter  30 value 1.566957
iter  31 value 1.566464
iter  32 value 1.566286
iter  33 value 1.566007
iter  34 value 1.565913
iter  35 value 1.565642
iter  36 value 1.565329
iter  37 value 1.565165
iter  38 value 1.565043
iter  39 value 1.564868
iter  40 value 1.564748
iter  41 value 1.564563
iter  42 value 1.564460
iter  43 value 1.564341
iter  44 value 1.564246
iter  45 value 1.564093
iter  46 value 1.563823
iter  47 value 1.563560
iter  48 value 1.563101
iter  49 value 1.562926
iter  50 value 1.562624
iter  51 value 1.562447
iter  52 value 1.562319
iter  53 value 1.562205
iter  54 value 1.562022
iter  55 value 1.561951
iter  56 value 1.561723
iter  57 value 1.561721
iter  58 value 1.561610
iter  59 value 1.561586
iter  60 value 1.561526
iter  61 value 1.561456
iter  62 value 1.561427
iter  63 value 1.561362
iter  64 value 1.561224
iter  65 value 1.561061
iter  66 value 1.560970
iter  67 value 1.560902
iter  68 value 1.560786
iter  69 value 1.560540
iter  70 value 1.560241
iter  71 value 1.559551
iter  72 value 1.557250
iter  73 value 1.556947
iter  74 value 1.556737
iter  75 value 1.555458
iter  76 value 1.554503
iter  77 value 1.554201
iter  78 value 1.553312
iter  79 value 1.552252
iter  80 value 1.551811
iter  81 value 1.551653
iter  82 value 1.551361
iter  83 value 1.551201
iter  84 value 1.551148
iter  85 value 1.551120
iter  86 value 1.551110
iter  87 value 1.551105
iter  88 value 1.551102
iter  89 value 1.551102
iter  90 value 1.551101
iter  91 value 1.551101
iter  91 value 1.551101
iter  91 value 1.551101
final  value 1.551101 
converged
[1] 4.192116

sarima(sales_ts_ohne_na,21,0,1)$AIC
initial  value 2.490162 
iter   2 value 2.065409
iter   3 value 1.861024
iter   4 value 1.727229
iter   5 value 1.615131
iter   6 value 1.564840
iter   7 value 1.553164
iter   8 value 1.547655
iter   9 value 1.542343
iter  10 value 1.540627
iter  11 value 1.540452
iter  12 value 1.539995
iter  13 value 1.539881
iter  14 value 1.539646
iter  15 value 1.539150
iter  16 value 1.538334
iter  17 value 1.537251
iter  18 value 1.536838
iter  19 value 1.536819
iter  20 value 1.536651
iter  21 value 1.536637
iter  22 value 1.536619
iter  23 value 1.536591
iter  24 value 1.536567
iter  25 value 1.536548
iter  26 value 1.536537
iter  27 value 1.536530
iter  28 value 1.536528
iter  29 value 1.536527
iter  30 value 1.536527
iter  31 value 1.536527
iter  31 value 1.536527
iter  31 value 1.536527
final  value 1.536527 
converged
initial  value 1.536697 
iter   2 value 1.536583
iter   3 value 1.536506
iter   4 value 1.536406
iter   5 value 1.536354
iter   6 value 1.536300
iter   7 value 1.536229
iter   8 value 1.536208
iter   9 value 1.536196
iter  10 value 1.536191
iter  11 value 1.536189
iter  12 value 1.536188
iter  13 value 1.536187
iter  14 value 1.536186
iter  15 value 1.536184
iter  16 value 1.536183
iter  17 value 1.536181
iter  18 value 1.536178
iter  19 value 1.536176
iter  20 value 1.536174
iter  21 value 1.536172
iter  22 value 1.536171
iter  23 value 1.536170
iter  24 value 1.536168
iter  25 value 1.536168
iter  26 value 1.536167
iter  27 value 1.536166
iter  28 value 1.536166
iter  29 value 1.536165
iter  30 value 1.536165
iter  30 value 1.536165
iter  30 value 1.536165
final  value 1.536165 
converged
[1] 4.212936

BIC:

#Mit BIC
sarima(sales_ts_ohne_na,10,0,0)$BIC
initial  value 2.485953 
iter   2 value 2.178505
iter   3 value 1.991777
iter   4 value 1.956337
iter   5 value 1.948356
iter   6 value 1.829770
iter   7 value 1.678623
iter   8 value 1.665761
iter   9 value 1.653535
iter  10 value 1.650139
iter  11 value 1.647349
iter  12 value 1.646675
iter  13 value 1.646441
iter  14 value 1.646403
iter  15 value 1.646374
iter  16 value 1.646371
iter  17 value 1.646369
iter  18 value 1.646369
iter  19 value 1.646369
iter  19 value 1.646369
iter  19 value 1.646369
final  value 1.646369 
converged
initial  value 1.645266 
iter   2 value 1.645189
iter   3 value 1.645112
iter   4 value 1.645071
iter   5 value 1.645054
iter   6 value 1.645051
iter   7 value 1.645042
iter   8 value 1.645038
iter   9 value 1.645036
iter  10 value 1.645036
iter  11 value 1.645035
iter  12 value 1.645033
iter  13 value 1.645030
iter  14 value 1.645027
iter  15 value 1.645025
iter  16 value 1.645025
iter  17 value 1.645025
iter  18 value 1.645025
iter  18 value 1.645025
iter  18 value 1.645025
final  value 1.645025 
converged
[1] 3.501172

sarima(sales_ts,15,0,1)$BIC 
initial  value 2.477969 
iter   2 value 2.072883
iter   3 value 1.821983
iter   4 value 1.681173
iter   5 value 1.639634
iter   6 value 1.613854
iter   7 value 1.595848
iter   8 value 1.589525
iter   9 value 1.579773
iter  10 value 1.577979
iter  11 value 1.576519
iter  12 value 1.576082
iter  13 value 1.575352
iter  14 value 1.573996
iter  15 value 1.573032
iter  16 value 1.572449
iter  17 value 1.571974
iter  18 value 1.571453
iter  19 value 1.570694
iter  20 value 1.570000
iter  21 value 1.569741
iter  22 value 1.569332
iter  23 value 1.569077
iter  24 value 1.568539
iter  25 value 1.568131
iter  26 value 1.567837
iter  27 value 1.567613
iter  28 value 1.567547
iter  29 value 1.567314
iter  30 value 1.566957
iter  31 value 1.566464
iter  32 value 1.566286
iter  33 value 1.566007
iter  34 value 1.565913
iter  35 value 1.565642
iter  36 value 1.565329
iter  37 value 1.565165
iter  38 value 1.565043
iter  39 value 1.564868
iter  40 value 1.564748
iter  41 value 1.564563
iter  42 value 1.564460
iter  43 value 1.564341
iter  44 value 1.564246
iter  45 value 1.564093
iter  46 value 1.563823
iter  47 value 1.563560
iter  48 value 1.563101
iter  49 value 1.562926
iter  50 value 1.562624
iter  51 value 1.562447
iter  52 value 1.562319
iter  53 value 1.562205
iter  54 value 1.562022
iter  55 value 1.561951
iter  56 value 1.561723
iter  57 value 1.561721
iter  58 value 1.561610
iter  59 value 1.561586
iter  60 value 1.561526
iter  61 value 1.561456
iter  62 value 1.561427
iter  63 value 1.561362
iter  64 value 1.561224
iter  65 value 1.561061
iter  66 value 1.560970
iter  67 value 1.560902
iter  68 value 1.560786
iter  69 value 1.560540
iter  70 value 1.560241
iter  71 value 1.559551
iter  72 value 1.557250
iter  73 value 1.556947
iter  74 value 1.556737
iter  75 value 1.555458
iter  76 value 1.554503
iter  77 value 1.554201
iter  78 value 1.553312
iter  79 value 1.552252
iter  80 value 1.551811
iter  81 value 1.551653
iter  82 value 1.551361
iter  83 value 1.551201
iter  84 value 1.551148
iter  85 value 1.551120
iter  86 value 1.551110
iter  87 value 1.551105
iter  88 value 1.551102
iter  89 value 1.551102
iter  90 value 1.551101
iter  91 value 1.551101
iter  91 value 1.551101
iter  91 value 1.551101
final  value 1.551101 
converged
[1] 3.414529

sarima(sales_ts_ohne_na,21,0,1)$BIC
initial  value 2.490162 
iter   2 value 2.065409
iter   3 value 1.861024
iter   4 value 1.727229
iter   5 value 1.615131
iter   6 value 1.564840
iter   7 value 1.553164
iter   8 value 1.547655
iter   9 value 1.542343
iter  10 value 1.540627
iter  11 value 1.540452
iter  12 value 1.539995
iter  13 value 1.539881
iter  14 value 1.539646
iter  15 value 1.539150
iter  16 value 1.538334
iter  17 value 1.537251
iter  18 value 1.536838
iter  19 value 1.536819
iter  20 value 1.536651
iter  21 value 1.536637
iter  22 value 1.536619
iter  23 value 1.536591
iter  24 value 1.536567
iter  25 value 1.536548
iter  26 value 1.536537
iter  27 value 1.536530
iter  28 value 1.536528
iter  29 value 1.536527
iter  30 value 1.536527
iter  31 value 1.536527
iter  31 value 1.536527
iter  31 value 1.536527
final  value 1.536527 
converged
initial  value 1.536697 
iter   2 value 1.536583
iter   3 value 1.536506
iter   4 value 1.536406
iter   5 value 1.536354
iter   6 value 1.536300
iter   7 value 1.536229
iter   8 value 1.536208
iter   9 value 1.536196
iter  10 value 1.536191
iter  11 value 1.536189
iter  12 value 1.536188
iter  13 value 1.536187
iter  14 value 1.536186
iter  15 value 1.536184
iter  16 value 1.536183
iter  17 value 1.536181
iter  18 value 1.536178
iter  19 value 1.536176
iter  20 value 1.536174
iter  21 value 1.536172
iter  22 value 1.536171
iter  23 value 1.536170
iter  24 value 1.536168
iter  25 value 1.536168
iter  26 value 1.536167
iter  27 value 1.536166
iter  28 value 1.536166
iter  29 value 1.536165
iter  30 value 1.536165
iter  30 value 1.536165
iter  30 value 1.536165
final  value 1.536165 
converged
[1] 3.51543

WIN: Ordnung 21.

4. Residuen Test für am Besten Modell (Ordnung 21.)

#Residuen manuel entweder mit mm4_burg oder mm3_ols
layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))
plot(mm4_burg$resid)
res=na.omit(mm4_burg$resid)
acf(res)
Box.test(res, lag=20, type="Ljung-Box", fitdf=2)

    Box-Ljung test

data:  res
X-squared = 7.7008, df = 18, p-value = 0.9828
qqnorm(res, main="Normal QQ-Plot")  # qq-plots
qqline(res, col=2)
par(mfrow=c(1,1))

hist(res, prob=TRUE,16)   # histogram 
lines(density(res))
dn=dnorm(x=seq(min(res),max(res),length.out=500), mean(res), sd(res))
lines(x=seq(min(res),max(res),length.out=500), dn, col=2)

shapiro.test(res)          # passt nicht, vielleicht log besser

    Shapiro-Wilk normality test

data:  res
W = 0.97839, p-value = 0.0006571

ARIMA Modelle (auto.arima()):

  1. auto.arima() from forecast package erkennt die Modellen automatisch.
fit_auto_arima<-auto.arima(sales_ts_ohne_na)
(fit_auto_arima)
Series: sales_ts_ohne_na 
ARIMA(1,0,0)(1,1,0)[12] with drift 

Coefficients:
         ar1     sar1    drift
      0.8867  -0.4320  -0.0228
s.e.  0.0294   0.0569   0.1642

sigma^2 estimated as 27.92:  log likelihood=-811.38
AIC=1630.76   AICc=1630.92   BIC=1645.05

fit<-Arima(sales_ts_ohne_na,order = c(1,0,0),seasonal = c(1,0,0),include.drift = TRUE)

5. Prognosen

Mit STL() funktion von forecast package:

########## mit stl benoetigt das Paket forecast ####################
##### mit stl, besser als decompose #############
real=ts(c(1973, 275), frequency = 12,
        start = c(1995,1))
par(mfrow=c(1,1))
dec.pass=stl(sales_ts_ohne_na, "per")
dec.pass
 Call:
 stl(x = sales_ts_ohne_na, s.window = "per")

Components
          seasonal    trend     remainder
Jan 1973 -7.052493 61.82257   0.229924553
Feb 1973 -1.230381 60.22258   1.007797644
Mar 1973 -1.230381 58.62260  10.607783268
Apr 1973 -1.230381 57.06243   7.167954891
May 1973 -1.230381 55.50225  10.728126513
Jun 1973 -1.230381 54.00072   8.229659946
Jul 1973 -1.230381 52.49919   2.731193379
Aug 1973 -1.230381 51.05776   2.172624177
Sep 1973 -1.230381 49.61633  -2.385945024
Oct 1973 -1.230382 48.47375  -5.243364787
Nov 1973 -1.230382 47.33117  -9.100784549
Dec 1973 -1.230382 46.71048 -15.480098727
Jan 1974 -1.230382 46.08979  -7.859412905
Feb 1974 -7.052493 45.68398   5.368513088
Mar 1974 -1.230381 45.27817  10.952215020
Apr 1974 -1.230381 44.83067   9.399713294
May 1974 -1.230381 44.38317  14.847211579
Jun 1974 -1.230381 43.73419   7.496194529
Jul 1974 -1.230381 43.08520   6.145177480
Aug 1974 -1.230381 42.27816   3.952222771
Sep 1974 -1.230381 41.47111   0.759268063
Oct 1974 -1.230381 40.95995  -5.729568248
Nov 1974 -1.230382 40.44879  -9.218404558
Dec 1974 -1.230382 40.52756 -15.297176051
Jan 1975 -1.230382 40.60633 -10.375947545
Feb 1975 -7.052493 41.25403  -0.201534597
Mar 1975 -1.230381 41.90173   3.328654211
Apr 1975 -1.230381 42.99659  12.233795016
May 1975 -1.230381 44.09145  14.138935831
Jun 1975 -1.230381 45.38910   6.841279047
Jul 1975 -1.230381 46.68676   5.543622263
Aug 1975 -1.230381 47.76362   6.466758666
Sep 1975 -1.230381 48.84049  -1.610104931
Oct 1975 -1.230381 49.39289  -2.162510337
Nov 1975 -1.230382 49.94530  -2.714915742
Dec 1975 -1.230382 50.26758 -10.037202259
Jan 1976 -1.230382 50.58987  -8.359488776
Feb 1976 -7.052493 51.09301   8.959484139
Mar 1976 -1.230381 51.59615   4.634232914
Apr 1976 -1.230381 52.24755  10.982828918
May 1976 -1.230381 52.89896   3.331424933
Jun 1976 -1.230381 53.78671   3.443671725
Jul 1976 -1.230381 54.67446   3.555918518
Aug 1976 -1.230381 56.14859   4.081794138
Sep 1976 -1.230381 57.62271   1.607669758
Oct 1976 -1.230381 59.43175  -3.201368589
Nov 1976 -1.230382 61.24079 -11.010406936
Dec 1976 -1.230382 62.77446 -14.544075741
Jan 1977 -1.230382 64.30813  -6.077744546
Feb 1977 -7.052493 65.44889   9.603601456
Mar 1977 -1.230381 66.58966  18.640723319
Apr 1977 -1.230381 67.32774  14.902643624
May 1977 -1.230381 68.06582  11.164563940
Jun 1977 -1.230381 68.18920   7.041185814
Jul 1977 -1.230381 68.31257  -3.082192312
Aug 1977 -1.230381 67.95156   7.278823026
Sep 1977 -1.230381 67.59054   4.639838364
Oct 1977 -1.230381 67.45458  -3.224202775
Nov 1977 -1.230382 67.31863 -11.088243914
Dec 1977 -1.230382 67.50216 -15.271783182
Jan 1978 -1.230382 67.68570  -9.455322450
Feb 1978 -7.052493 67.90944   2.143055308
Mar 1978 -1.230381 68.13317   8.097208926
Apr 1978 -1.230381 68.31711  17.913267540
May 1978 -1.230381 68.50105  12.729326164
Jun 1978 -1.230381 68.43810   9.792276740
Jul 1978 -1.230381 68.37515   0.855227315
Aug 1978 -1.230381 67.82881   5.401566694
Sep 1978 -1.230381 67.28248   1.947906074
Oct 1978 -1.230381 66.41100   4.819378561
Nov 1978 -1.230382 65.53953 -11.309148952
Dec 1978 -1.230382 64.69248 -13.462100587
Jan 1979 -1.230382 63.84543  -9.615052222
Feb 1979 -7.052493 63.18734   1.865149046
Mar 1979 -1.230381 62.52925  11.701126174
Apr 1979 -1.230381 61.77447  11.455910354
May 1979 -1.230381 61.01969   8.210694543
Jun 1979 -1.230381 60.03600   4.194376714
Jul 1979 -1.230381 59.05232   6.178058884
Aug 1979 -1.230381 57.45553  11.774849495
Sep 1979 -1.230381 55.85874   5.371640107
Oct 1979 -1.230381 53.66388   1.566498979
Nov 1979 -1.230382 51.46902  -9.238642149
Dec 1979 -1.230382 49.63182 -13.401438080
Jan 1980 -1.230382 47.79462  -3.564234011
Feb 1980 -7.052493 46.81209   4.240401131
Mar 1980 -1.230381 45.82957  -0.599187867
Apr 1980 -1.230381 45.52741  -8.297031534
May 1980 -1.230381 45.22526   0.005124809
Jun 1980 -1.230381 45.30657   5.923814421
Jul 1980 -1.230381 45.38788  10.842504033
Aug 1980 -1.230381 45.63098  16.599400091
Sep 1980 -1.230381 45.87409   5.356296149
Oct 1980 -1.230381 45.81279   1.417588045
Nov 1980 -1.230382 45.75150  -5.521120058
Dec 1980 -1.230382 44.67895 -10.448565543
Jan 1981 -1.230382 43.60639  -5.376011028
Feb 1981 -7.052493 41.86292   5.189571391
Mar 1981 -1.230381 40.11945  10.110929670
Apr 1981 -1.230381 38.66696   6.563416013
May 1981 -1.230381 37.21448   9.015902365
Jun 1981 -1.230381 36.32708   2.903300191
Jul 1981 -1.230381 35.43968   1.790698017
Aug 1981 -1.230381 34.73098   0.499402137
Sep 1981 -1.230381 34.02228  -4.791893744
Oct 1981 -1.230381 33.31112  -3.080734148
Nov 1981 -1.230382 32.59996  -4.369574553
Dec 1981 -1.230382 32.11584  -1.885457667
Jan 1982 -1.230382 31.63172  -2.401340780
Feb 1982 -7.052493 31.63684   4.415655286
Mar 1982 -1.230381 31.64195   5.588427213
Apr 1982 -1.230381 32.17310   1.057285681
May 1982 -1.230381 32.70424   4.526144158
Jun 1982 -1.230381 33.77989   1.450490687
Jul 1982 -1.230381 34.85554  -2.625162784
Aug 1982 -1.230381 36.57721   0.653170491
Sep 1982 -1.230381 38.29888   1.931503767
Oct 1982 -1.230381 40.44169   0.788686530
Nov 1982 -1.230382 42.58451  -2.354130707
Dec 1982 -1.230382 44.52271 -10.292325593
Jan 1983 -1.230382 46.46090  -1.230520478
Feb 1983 -7.052493 47.72738   5.325109751
Mar 1983 -1.230381 48.99387   9.236515840
Apr 1983 -1.230381 49.74380  10.486585888
May 1983 -1.230381 50.49373  14.736655946
Jun 1983 -1.230381 51.24299   8.987395230
Jul 1983 -1.230381 51.99225   0.238134514
Aug 1983 -1.230381 52.67312  -1.442741965
Sep 1983 -1.230381 53.35400  -4.123618444
Oct 1983 -1.230381 53.68724  -1.456858872
Nov 1983 -1.230382 54.02048  -7.790099301
Dec 1983 -1.230382 54.08807  -4.857688326
Jan 1984 -1.230382 54.15566  -0.925277350
Feb 1984 -7.052493 54.15654  10.895951036
Mar 1984 -1.230381 54.15743  10.072955283
Apr 1984 -1.230381 53.94335   8.287035050
May 1984 -1.230381 53.72927   6.501114827
Jun 1984 -1.230381 53.35159   5.878794218
Jul 1984 -1.230381 52.97391   0.256473610
Aug 1984 -1.230381 52.84330  -3.612921373
Sep 1984 -1.230381 52.71270   1.517683643
Oct 1984 -1.230381 52.99779   3.232590408
Nov 1984 -1.230382 53.28288 -10.052502828
Dec 1984 -1.230382 53.89935 -14.668963881
Jan 1985 -1.230382 54.51581  -5.285424934
Feb 1985 -7.052493 55.13482   6.917674886
Mar 1985 -1.230381 55.75383  12.476550566
Apr 1985 -1.230381 56.18577   5.044613866
May 1985 -1.230381 56.61770   9.612677176
Jun 1985 -1.230381 57.10283   9.127555709
Jul 1985 -1.230381 57.58795   6.642434241
Aug 1985 -1.230381 58.43915   3.791230130
Sep 1985 -1.230381 59.29036  -4.059973981
Oct 1985 -1.230381 60.42009  -7.189710878
Nov 1985 -1.230382 61.54983  -9.319447775
Dec 1985 -1.230382 62.19821 -13.967825337
Jan 1986 -1.230382 62.84658  -6.616202899
Feb 1986 -7.052493 62.92917   3.123318730
Mar 1986 -1.230381 63.01176  27.218616220
Apr 1986 -1.230381 62.88496  22.345416497
May 1986 -1.230381 62.75816  13.472216785
Jun 1986 -1.230381 62.35540   4.874985273
Jul 1986 -1.230381 61.95263  -3.722246238
Aug 1986 -1.230381 61.26809  -8.037710633
Sep 1986 -1.230381 60.58356   0.646824972
Oct 1986 -1.230381 59.90096  -4.670573835
Nov 1986 -1.230382 59.21835  -9.987972643
Dec 1986 -1.230382 58.90597  -8.675586153
Jan 1987 -1.230382 58.59358  -4.363199664
Feb 1987 -7.052493 58.36275   7.689747268
Mar 1987 -1.230381 58.13191  16.098470061
Apr 1987 -1.230381 57.62558  15.604805273
May 1987 -1.230381 57.11924   6.111140495
Jun 1987 -1.230381 56.35507   2.875312791
Jul 1987 -1.230381 55.59090   0.639485088
Aug 1987 -1.230381 54.96140   2.268982687
Sep 1987 -1.230381 54.33190  -1.101519715
Oct 1987 -1.230381 54.20957  -0.979187443
Nov 1987 -1.230382 54.08724  -9.856855171
Dec 1987 -1.230382 54.40582 -16.175437963
Jan 1988 -1.230382 54.72440 -10.494020756
Feb 1988 -7.052493 55.09893   6.953567185
Mar 1988 -1.230381 55.47345  13.756930985
Apr 1988 -1.230381 55.80992  13.420463651
May 1988 -1.230381 56.14638   9.083996327
Jun 1988 -1.230381 56.36676   9.863617967
Jul 1988 -1.230381 56.58714   1.643239607
Aug 1988 -1.230381 56.37484   3.855540536
Sep 1988 -1.230381 56.16254  -0.932158535
Oct 1988 -1.230381 55.65706   2.573317646
Nov 1988 -1.230382 55.15159 -10.921206172
Dec 1988 -1.230382 54.85661 -11.626228323
Jan 1989 -1.230382 54.56163  -1.331250474
Feb 1989 -7.052493 54.46603   3.586465130
Mar 1989 -1.230381 54.37042   4.859956593
Apr 1989 -1.230381 54.27968   6.950704976
May 1989 -1.230381 54.18893   8.041453369
Jun 1989 -1.230381 54.09677   5.133609188
Jul 1989 -1.230381 54.00462   9.225765008
Aug 1989 -1.230381 53.81896   8.411425078
Sep 1989 -1.230381 53.63330  -3.402914852
Oct 1989 -1.230381 53.07898  -0.848593955
Nov 1989 -1.230382 52.52465  -4.294273058
Dec 1989 -1.230382 51.54381 -10.313432596
Jan 1990 -1.230382 50.56297  -4.332592133
Feb 1990 -7.052493 49.39765   7.654843676
Mar 1990 -1.230381 48.23233  10.998055345
Apr 1990 -1.230381 47.09863   6.131747611
May 1990 -1.230381 45.96494   5.265439886
Jun 1990 -1.230381 44.88695   6.343430929
Jul 1990 -1.230381 43.80896   3.421421972
Aug 1990 -1.230381 42.94279   4.287592812
Sep 1990 -1.230381 42.07662  -2.846236349
Oct 1990 -1.230381 41.48288  -3.252497167
Nov 1990 -1.230382 40.88914  -5.658757986
Dec 1990 -1.230382 40.59162 -10.361238445
Jan 1991 -1.230382 40.29410  -9.063718904
Feb 1991 -7.052493 40.22752   6.824971443
Mar 1991 -1.230381 40.16094   7.069437649
Apr 1991 -1.230381 40.41417   6.816206282
May 1991 -1.230381 40.66741   7.562974925
Jun 1991 -1.230381 41.41709   6.813288519
Jul 1991 -1.230381 42.16678   2.063602113
Aug 1991 -1.230381 43.25418   3.976205452
Sep 1991 -1.230381 44.34157  -6.111191210
Oct 1991 -1.230381 45.20791  -2.977525204
Nov 1991 -1.230382 46.07424  -5.843859197
Dec 1991 -1.230382 46.74221  -9.511824651
Jan 1992 -1.230382 47.41017   1.820209895
Feb 1992 -7.052493 48.10287  13.949627493
Mar 1992 -1.230381 48.79556   8.434820951
Apr 1992 -1.230381 49.29445   4.935927326
May 1992 -1.230381 49.79335   3.437033712
Jun 1992 -1.230381 49.96677   4.263610473
Jul 1992 -1.230381 50.14019   3.090187233
Aug 1992 -1.230381 50.35278   6.877603252
Sep 1992 -1.230381 50.56536   1.665019271
Oct 1992 -1.230381 51.04985  -1.819471747
Nov 1992 -1.230382 51.53434  -8.303962765
Dec 1992 -1.230382 51.94083  -8.710451994
Jan 1993 -1.230382 52.34732  -7.116941223
Feb 1993 -7.052493 52.67858   4.373910275
Mar 1993 -1.230381 53.00984   8.220537634
Apr 1993 -1.230381 53.57410  13.656285846
May 1993 -1.230381 54.13835   5.092034068
Jun 1993 -1.230381 54.80254   5.427844973
Jul 1993 -1.230381 55.46673   0.763655877
Aug 1993 -1.230381 56.11835   2.112035819
Sep 1993 -1.230381 56.76997   1.460415761
Oct 1993 -1.230381 57.24291  -0.012530697
Nov 1993 -1.230382 57.71586  -3.485477155
Dec 1993 -1.230382 57.80625  -5.575867440
Jan 1994 -1.230382 57.89664 -11.666257724
Feb 1994 -7.052493 57.66865   7.383846260
Mar 1994 -1.230381 57.44065  17.789726104
Apr 1994 -1.230381 57.06520   9.165177704
May 1994 -1.230381 56.68975   9.540629314
Jun 1994 -1.230381 56.19324   0.037137467
Jul 1994 -1.230381 55.69674  -2.466354380
Aug 1994 -1.230381 55.08499   5.145386717
Sep 1994 -1.230381 54.47325   0.757127815
Oct 1994 -1.230381 54.05382   4.176559377
Nov 1994 -1.230382 53.63439  -7.404009061
Dec 1994 -1.230382 53.80952 -12.579137363
Jan 1995 -1.230382 53.98465  -5.754265665
Feb 1995 -7.052493 54.40554  -0.353043748
Mar 1995 -1.230381 54.82643   6.403954028
Apr 1995 -1.230381 55.09259   4.137791239
May 1995 -1.230381 55.35875   8.871628459
Jun 1995 -1.230381 55.64907   9.581308573
Jul 1995 -1.230381 55.93939   9.290988686
Aug 1995 -1.230381 56.30171   7.928676013
Sep 1995 -1.230381 56.66402  -0.433636660
Oct 1995 -1.230381 57.05055  -1.820166184
Nov 1995 -1.230382 57.43708 -12.206695709
plot(dec.pass)

#plot daten und modell
plot(sales_ts_ohne_na, main="Passagierzahlen: saisonale Zerlegung mit stl", ylab="Passagierzahlen in 1000")
lines((dec.pass$time.series[,2]), col=4)
lines((dec.pass$time.series[,2]+dec.pass$time.series[,1]), col=2)

plot(forecast(dec.pass), main="Forecast stl")

plot(sales_ts_ohne_na, main="Monatlichen Sales: Vorhersage")
lines((forecast(dec.pass)$mean), col="green", lwd=2)
lines((forecast(dec.pass)$lower[,2]), col="blue", lwd=2)
lines((forecast(dec.pass)$upper[,2]), col="blue", lwd=2)

#lines(real, col=6, lwd=2)

Mit sarima.for() from astsa package:

fit<-Arima(sales_ts_ohne_na,order = c(1,0,0),seasonal = c(1,0,0),include.drift = TRUE)

sarima.for(sales_ts_ohne_na,5,1,0,0)
$`pred`
          Jan      Feb      Mar      Apr May Jun Jul Aug Sep Oct Nov      Dec
1995                                                                 45.19548
1996 46.21607 47.08735 47.83116 48.46616                                     

$se
           Jan       Feb       Mar       Apr May Jun Jul Aug Sep Oct Nov       Dec
1995                                                                      6.163496
1996  8.104027  9.265719 10.027947 10.548826                                      

4. Vergleichen AR und Auto Arima Modelle

AR:

summary(arima(sales_ts_ohne_na,order=c(21,0,0)))

Call:
arima(x = sales_ts_ohne_na, order = c(21, 0, 0))

Coefficients:
         ar1      ar2      ar3      ar4     ar5      ar6     ar7      ar8      ar9    ar10
      0.8732  -0.0292  -0.0822  -0.0605  0.1595  -0.0091  0.0212  -0.0602  -0.0313  0.2014
s.e.  0.0595   0.0782   0.0779   0.0775  0.0772   0.0777  0.0773   0.0773   0.0771  0.0754
         ar11    ar12     ar13    ar14     ar15    ar16    ar17     ar18    ar19     ar20    ar21
      -0.0372  0.2892  -0.1859  0.0155  -0.1311  0.0029  0.0658  -0.1585  0.1082  -0.2335  0.1507
s.e.   0.0763  0.0755   0.0775  0.0784   0.0784  0.0790  0.0790   0.0790  0.0796   0.0798  0.0611
      intercept
        52.6856
s.e.     2.1056

sigma^2 estimated as 21.02:  log likelihood = -812.66,  aic = 1671.31

Training set error measures:
                      ME     RMSE      MAE       MPE     MAPE      MASE        ACF1
Training set -0.03343723 4.585222 3.501625 -0.924734 6.979855 0.6907452 0.002623198

Auto ARIMA:

summary(fit_auto_arima)
Series: sales_ts_ohne_na 
ARIMA(1,0,0)(1,1,0)[12] with drift 

Coefficients:
         ar1     sar1    drift
      0.8867  -0.4320  -0.0228
s.e.  0.0294   0.0569   0.1642

sigma^2 estimated as 27.92:  log likelihood=-811.38
AIC=1630.76   AICc=1630.92   BIC=1645.05

Training set error measures:
                     ME     RMSE      MAE        MPE     MAPE      MASE        ACF1
Training set 0.06977783 5.137588 3.982385 -0.4155256 7.894716 0.4835491 -0.03677202

Fazit: Gute der Modellen

  • ME: Mean Error

  • RMSE: root mean squared error (AR modelle)

  • MAE: mean absolute error (AR modelle)

  • MPE: mean percentage error

  • MAPE: mean absolute percentage error (AR modelle)

  • ACF1: first-order autocorrelation coefficient (ACF1)

WINNER: AR Modelle mit Ordnung 21.

Cheers Cevi & Jabr

LS0tDQp0aXRsZTogIlVTQSBIb21lIFNhbGVzIg0KYXV0aG9yOiAiQ2V2aSBIZXJkaWFuICYgSmFiZXIgWmFoZXIgQWxkZWVuIg0KZGF0ZTogIjA3LjAxLjIwMTkiDQpvdXRwdXQ6DQogIG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