Library yang dibutuhkan

library(timeSeries)
## Warning: package 'timeSeries' was built under R version 4.0.5
## Loading required package: timeDate
## Warning: package 'timeDate' was built under R version 4.0.5
library(tseries)
## Warning: package 'tseries' was built under R version 4.0.5
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo

Cara memasukkan data kita, kita memakai data .csv

data=arima.sim(n=50,model=list(order=c(0,0,1),ma=0.1,sd=0.1))
data=read.csv("D:/1. kuliah s2/materi Pak Agus Data Mining/Dini_Kristianti_200605220015_Review_Jurnal/Revisi_Dini_Kristianti_Review_Jurnal_/dini_data_hotel_bali2.csv")

Menampilkan data keseluruhan yang kita gunakan

View(data)

Menampilkan data Hotel Bintang

data=data$Bintang.3
data=as.ts(data)
str(data)
##  Time-Series [1:13] from 1 to 13: 53.42 46.82 28.7 2.06 1.06 ...
plot.ts(data)

adf.test(data)
## Warning in adf.test(data): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  data
## Dickey-Fuller = -10.119, Lag order = 2, p-value = 0.01
## alternative hypothesis: stationary

Cara menampilkan grafik ACF

acf(data)

Cara menampilkan grafik PACF

pacf(data)

Hasil ARIMA

fit=arima(data,c(0,0,1))
fit
## 
## Call:
## arima(x = data, order = c(0, 0, 1))
## 
## Coefficients:
##          ma1  intercept
##       1.0000    16.3343
## s.e.  0.2725     5.4392
## 
## sigma^2 estimated as 103.5:  log likelihood = -49.93,  aic = 105.85
myresid=fit$residuals
qqnorm(myresid)

library(FitAR)
## Warning: package 'FitAR' was built under R version 4.0.5
## Loading required package: lattice
## Loading required package: leaps
## Warning: package 'leaps' was built under R version 4.0.5
## Loading required package: ltsa
## Loading required package: bestglm
## Warning: package 'bestglm' was built under R version 4.0.5
boxresult<-LjungBoxTest(myresid)
## Warning in (ra^2)/(n - (1:lag.max)): longer object length is not a multiple of
## shorter object length
plot(boxresult[3],main="Ljung-Box_Test",xlab="lag",ylab="p-value")

Box.test(myresid,type = "Ljung-Box")
## 
##  Box-Ljung test
## 
## data:  myresid
## X-squared = 0.7383, df = 1, p-value = 0.3902
pred<-predict(fit,n.ahead=5)
ts.plot(data,pred$pred)

data
## Time Series:
## Start = 1 
## End = 13 
## Frequency = 1 
##  [1] 53.42 46.82 28.70  2.06  1.06  2.11  3.22  4.27  5.92 11.26 10.40 15.20
## [13] 11.62
pred$pred
## Time Series:
## Start = 14 
## End = 18 
## Frequency = 1 
## [1] 11.19571 16.33429 16.33429 16.33429 16.33429
pred
## $pred
## Time Series:
## Start = 14 
## End = 18 
## Frequency = 1 
## [1] 11.19571 16.33429 16.33429 16.33429 16.33429
## 
## $se
## Time Series:
## Start = 14 
## End = 18 
## Frequency = 1 
## [1] 10.53298 14.39080 14.39080 14.39080 14.39080
AirPassengers
##      Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
## 1949 112 118 132 129 121 135 148 148 136 119 104 118
## 1950 115 126 141 135 125 149 170 170 158 133 114 140
## 1951 145 150 178 163 172 178 199 199 184 162 146 166
## 1952 171 180 193 181 183 218 230 242 209 191 172 194
## 1953 196 196 236 235 229 243 264 272 237 211 180 201
## 1954 204 188 235 227 234 264 302 293 259 229 203 229
## 1955 242 233 267 269 270 315 364 347 312 274 237 278
## 1956 284 277 317 313 318 374 413 405 355 306 271 306
## 1957 315 301 356 348 355 422 465 467 404 347 305 336
## 1958 340 318 362 348 363 435 491 505 404 359 310 337
## 1959 360 342 406 396 420 472 548 559 463 407 362 405
## 1960 417 391 419 461 472 535 622 606 508 461 390 432
str(AirPassengers)
##  Time-Series [1:144] from 1949 to 1961: 112 118 132 129 121 135 148 148 136 119 ...
ts.plot(AirPassengers)

components.ts=decompose(AirPassengers)
plot(components.ts)

acf(AirPassengers)

pacf(AirPassengers)

x=log(AirPassengers)
plot(diff(x))

data=diff(diff(x,12))
plot(data)

acf(data)

pacf(data)