library(readxl)
## Warning: package 'readxl' was built under R version 4.4.2
veri <- read_excel("~/veri.xlsx")
View(veri)
head(veri)
## # A tibble: 6 × 9
## tarih TP YP mpt mbyat mbode ipt iyat iode
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2015Q1 517271. 302968. 23667. 12929. 1069. 190773. 60141. 13003.
## 2 2015Q2 494022. 296201. 26321. 15650. 1090. 193837. 58244. 12411.
## 3 2015Q3 475094. 324223. 29773. 16947. 1225. 190433. 51039. 12436.
## 4 2015Q4 470660. 298681. 35794. 16809. 1422. 206470. 53427. 12875.
## 5 2016Q1 473664. 302281. 38033. 18271. 1885. 194120. 53134. 12946.
## 6 2016Q2 496848. 315387. 49274. 21587. 2011. 233575. 54026. 13517.
str(veri)
## tibble [40 × 9] (S3: tbl_df/tbl/data.frame)
## $ tarih: chr [1:40] "2015Q1" "2015Q2" "2015Q3" "2015Q4" ...
## $ TP : num [1:40] 517271 494022 475094 470660 473664 ...
## $ YP : num [1:40] 302968 296201 324223 298681 302281 ...
## $ mpt : num [1:40] 23667 26321 29773 35794 38033 ...
## $ mbyat: num [1:40] 12929 15650 16947 16809 18271 ...
## $ mbode: num [1:40] 1069 1090 1225 1422 1885 ...
## $ ipt : num [1:40] 190773 193837 190433 206470 194120 ...
## $ iyat : num [1:40] 60141 58244 51039 53427 53134 ...
## $ iode : num [1:40] 13003 12411 12436 12875 12946 ...
library(tseries)
## Warning: package 'tseries' was built under R version 4.4.3
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
ts_veri <- ts(veri, start = c(2015, 1), frequency = 4)
library(urca)
## Warning: package 'urca' was built under R version 4.4.3
adf_results <- list()
ADF SONUÇLARI SABİT
columns_to_test <- colnames(ts_veri)
adf_results <- list()
columns_to_test <- colnames(ts_veri)[-1]
for (col in columns_to_test) {
# ts_veri'den ilgili sütunu al ve vektör olarak dönüştür
ts_data <- as.vector(ts_veri[, col])
adf_results[[col]] <- ur.df(ts_data, type = "drift", lags = 1)
}
for (col in names(adf_results)) {
cat("### ADF Testi Sonucu:", col, "###\n")
print(summary(adf_results[[col]]))
cat("\n--------------------------\n")
}
## ### ADF Testi Sonucu: TP ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -65878 -20089 2541 21829 49642
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.096e+05 4.769e+04 2.298 0.0276 *
## z.lag.1 -2.485e-01 1.078e-01 -2.305 0.0272 *
## z.diff.lag 2.113e-01 1.653e-01 1.278 0.2096
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 32010 on 35 degrees of freedom
## Multiple R-squared: 0.1384, Adjusted R-squared: 0.08912
## F-statistic: 2.81 on 2 and 35 DF, p-value: 0.07383
##
##
## Value of test-statistic is: -2.3053 2.659
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: YP ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -49422 -17812 -4189 8967 81792
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.501e+05 5.722e+04 2.624 0.0128 *
## z.lag.1 -4.714e-01 1.788e-01 -2.637 0.0124 *
## z.diff.lag -1.499e-01 1.712e-01 -0.876 0.3873
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 27190 on 35 degrees of freedom
## Multiple R-squared: 0.2832, Adjusted R-squared: 0.2422
## F-statistic: 6.913 on 2 and 35 DF, p-value: 0.002949
##
##
## Value of test-statistic is: -2.6369 3.4792
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: mpt ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -90233 -9090 -832 15340 48897
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2089.44489 7341.43956 0.285 0.77762
## z.lag.1 0.09861 0.03086 3.196 0.00295 **
## z.diff.lag -0.32867 0.17520 -1.876 0.06901 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 28290 on 35 degrees of freedom
## Multiple R-squared: 0.2287, Adjusted R-squared: 0.1847
## F-statistic: 5.19 on 2 and 35 DF, p-value: 0.01062
##
##
## Value of test-statistic is: 3.1958 11.5346
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: mbyat ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -58435 -8203 -1751 9155 74257
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.000e+03 7.793e+03 1.155 0.2560
## z.lag.1 -7.784e-03 6.726e-02 -0.116 0.9085
## z.diff.lag -4.300e-01 1.585e-01 -2.713 0.0103 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 26600 on 35 degrees of freedom
## Multiple R-squared: 0.1894, Adjusted R-squared: 0.1431
## F-statistic: 4.088 on 2 and 35 DF, p-value: 0.02537
##
##
## Value of test-statistic is: -0.1157 1.7693
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: mbode ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2439.90 -633.63 99.98 559.96 3075.90
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.90494 313.28992 0.051 0.95980
## z.lag.1 0.10163 0.03056 3.326 0.00208 **
## z.diff.lag -0.26533 0.17891 -1.483 0.14700
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1167 on 35 degrees of freedom
## Multiple R-squared: 0.2432, Adjusted R-squared: 0.2
## F-statistic: 5.624 on 2 and 35 DF, p-value: 0.007623
##
##
## Value of test-statistic is: 3.3257 11.4921
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: ipt ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -42592 -11985 1801 12236 34887
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.518e+02 2.219e+04 -0.007 0.995
## z.lag.1 1.850e-02 1.086e-01 0.170 0.866
## z.diff.lag -9.142e-02 1.938e-01 -0.472 0.640
##
## Residual standard error: 19780 on 35 degrees of freedom
## Multiple R-squared: 0.00638, Adjusted R-squared: -0.0504
## F-statistic: 0.1124 on 2 and 35 DF, p-value: 0.894
##
##
## Value of test-statistic is: 0.1704 0.627
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: iyat ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19399.8 -4303.2 -174.9 6341.6 17241.7
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.606e+04 1.112e+04 3.242 0.00261 **
## z.lag.1 -6.536e-01 2.017e-01 -3.241 0.00261 **
## z.diff.lag 1.914e-02 1.743e-01 0.110 0.91319
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8824 on 35 degrees of freedom
## Multiple R-squared: 0.3054, Adjusted R-squared: 0.2657
## F-statistic: 7.693 on 2 and 35 DF, p-value: 0.001701
##
##
## Value of test-statistic is: -3.2411 5.2761
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: iode ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3017.2 -854.3 258.9 800.5 1709.0
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 549.85550 1222.03635 0.450 0.656
## z.lag.1 -0.02993 0.09787 -0.306 0.762
## z.diff.lag 0.01133 0.18617 0.061 0.952
##
## Residual standard error: 1273 on 35 degrees of freedom
## Multiple R-squared: 0.002795, Adjusted R-squared: -0.05419
## F-statistic: 0.04906 on 2 and 35 DF, p-value: 0.9522
##
##
## Value of test-statistic is: -0.3058 0.4294
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
ADF SONUÇLARI TREND
columns_to_test <- colnames(ts_veri)
adf_results <- list()
columns_to_test <- colnames(ts_veri)[-1]
for (col in columns_to_test) {
# ts_veri'den ilgili sütunu al ve vektör olarak dönüştür
ts_data <- as.vector(ts_veri[, col])
adf_results[[col]] <- ur.df(ts_data, type = "trend", lags = 1)
}
for (col in names(adf_results)) {
cat("### ADF Testi Sonucu:", col, "###\n")
print(summary(adf_results[[col]]))
cat("\n--------------------------\n")
}
## ### ADF Testi Sonucu: TP ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -64872 -20421 3030 23457 51471
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.003e+05 5.307e+04 1.890 0.0673 .
## z.lag.1 -2.373e-01 1.123e-01 -2.113 0.0420 *
## tt 2.121e+02 5.050e+02 0.420 0.6771
## z.diff.lag 1.906e-01 1.744e-01 1.093 0.2820
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 32390 on 34 degrees of freedom
## Multiple R-squared: 0.1428, Adjusted R-squared: 0.06717
## F-statistic: 1.888 on 3 and 34 DF, p-value: 0.1502
##
##
## Value of test-statistic is: -2.113 1.7898 2.6829
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: YP ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -43179 -16232 -3523 5588 77929
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.684e+05 5.934e+04 2.838 0.00761 **
## z.lag.1 -4.997e-01 1.800e-01 -2.777 0.00887 **
## tt -4.506e+02 4.050e+02 -1.112 0.27373
## z.diff.lag -1.399e-01 1.708e-01 -0.819 0.41857
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 27100 on 34 degrees of freedom
## Multiple R-squared: 0.3084, Adjusted R-squared: 0.2473
## F-statistic: 5.053 on 3 and 34 DF, p-value: 0.005304
##
##
## Value of test-statistic is: -2.7767 2.7478 4.1191
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: mpt ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -92637 -11199 2432 13894 46294
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.111e+03 1.168e+04 -0.352 0.727
## z.lag.1 4.817e-02 7.981e-02 0.603 0.550
## tt 8.014e+02 1.168e+03 0.686 0.497
## z.diff.lag -3.036e-01 1.803e-01 -1.684 0.101
##
## Residual standard error: 28510 on 34 degrees of freedom
## Multiple R-squared: 0.2393, Adjusted R-squared: 0.1722
## F-statistic: 3.565 on 3 and 34 DF, p-value: 0.02408
##
##
## Value of test-statistic is: 0.6035 7.7306 5.2648
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: mbyat ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -53153 -13680 3555 11939 51558
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -8974.6932 8982.7624 -0.999 0.32480
## z.lag.1 -0.6238 0.2040 -3.058 0.00432 **
## tt 3780.1781 1196.2946 3.160 0.00331 **
## z.diff.lag -0.1317 0.1700 -0.774 0.44405
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 23720 on 34 degrees of freedom
## Multiple R-squared: 0.3734, Adjusted R-squared: 0.3181
## F-statistic: 6.753 on 3 and 34 DF, p-value: 0.001074
##
##
## Value of test-statistic is: -3.0583 4.8107 5.0009
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: mbode ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2438.7 -634.6 100.0 559.9 3074.3
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 13.04970 503.68481 0.026 0.979
## z.lag.1 0.10099 0.09324 1.083 0.286
## tt 0.42532 58.20257 0.007 0.994
## z.diff.lag -0.26481 0.19525 -1.356 0.184
##
## Residual standard error: 1184 on 34 degrees of freedom
## Multiple R-squared: 0.2432, Adjusted R-squared: 0.1764
## F-statistic: 3.642 on 3 and 34 DF, p-value: 0.0222
##
##
## Value of test-statistic is: 1.0831 7.4425 5.372
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: ipt ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -40590 -9105 1110 12903 41465
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.883e+03 2.208e+04 -0.312 0.757
## z.lag.1 4.399e-03 1.065e-01 0.041 0.967
## tt 4.744e+02 2.923e+02 1.623 0.114
## z.diff.lag -1.334e-01 1.911e-01 -0.698 0.490
##
## Residual standard error: 19330 on 34 degrees of freedom
## Multiple R-squared: 0.07783, Adjusted R-squared: -0.003543
## F-statistic: 0.9565 on 3 and 34 DF, p-value: 0.4244
##
##
## Value of test-statistic is: 0.0413 1.3156 1.3323
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: iyat ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19859.9 -3857.5 957.9 6372.0 16050.4
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.422e+04 1.161e+04 2.948 0.00575 **
## z.lag.1 -6.506e-01 2.035e-01 -3.196 0.00300 **
## tt 8.139e+01 1.320e+02 0.616 0.54170
## z.diff.lag 1.185e-02 1.763e-01 0.067 0.94682
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8903 on 34 degrees of freedom
## Multiple R-squared: 0.313, Adjusted R-squared: 0.2524
## F-statistic: 5.164 on 3 and 34 DF, p-value: 0.004756
##
##
## Value of test-statistic is: -3.1963 3.5817 5.3494
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: iode ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3089.8 -785.4 305.5 963.2 1533.2
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 265.70523 1205.05060 0.220 0.827
## z.lag.1 -0.05912 0.09714 -0.609 0.547
## tt 31.79381 19.20963 1.655 0.107
## z.diff.lag -0.03289 0.18367 -0.179 0.859
##
## Residual standard error: 1242 on 34 degrees of freedom
## Multiple R-squared: 0.07715, Adjusted R-squared: -0.004279
## F-statistic: 0.9474 on 3 and 34 DF, p-value: 0.4286
##
##
## Value of test-statistic is: -0.6086 1.2136 1.4187
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
BİRİNCİ FARKLARI
for (col in columns_to_test) {
# ts_veri'den ilgili sütunu al, birinci farkını hesapla ve vektör olarak dönüştür
diff_data <- diff(as.vector(ts_veri[, col]))
adf_results[[col]] <- ur.df(diff_data, type = "drift", lags = 1)
}
# Sonuçları yazdır
for (col in names(adf_results)) {
cat("### ADF Testi Sonucu:", col, "###\n")
print(summary(adf_results[[col]]))
cat("\n--------------------------\n")
}
## ### ADF Testi Sonucu: TP ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -62312 -25802 2552 19335 67297
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.862e+02 5.710e+03 0.138 0.891293
## z.lag.1 -9.238e-01 2.305e-01 -4.008 0.000316 ***
## z.diff.lag 2.468e-04 1.712e-01 0.001 0.998858
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 34720 on 34 degrees of freedom
## Multiple R-squared: 0.463, Adjusted R-squared: 0.4315
## F-statistic: 14.66 on 2 and 34 DF, p-value: 2.564e-05
##
##
## Value of test-statistic is: -4.0083 8.0414
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: YP ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -54589 -20726 -3770 13328 84029
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.001e+03 4.900e+03 -0.204 0.839
## z.lag.1 -1.472e+00 2.855e-01 -5.157 1.08e-05 ***
## z.diff.lag 6.894e-02 1.731e-01 0.398 0.693
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 29800 on 34 degrees of freedom
## Multiple R-squared: 0.6847, Adjusted R-squared: 0.6662
## F-statistic: 36.92 on 2 and 34 DF, p-value: 3.005e-09
##
##
## Value of test-statistic is: -5.1566 13.3368
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: mpt ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -92715 -14885 -9970 19178 65151
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 16332.3859 6850.5357 2.384 0.02285 *
## z.lag.1 -0.8713 0.2901 -3.004 0.00498 **
## z.diff.lag -0.1675 0.1953 -0.858 0.39707
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 32170 on 34 degrees of freedom
## Multiple R-squared: 0.5258, Adjusted R-squared: 0.4979
## F-statistic: 18.85 on 2 and 34 DF, p-value: 3.101e-06
##
##
## Value of test-statistic is: -3.0039 4.7034
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: mbyat ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -52352 -12100 -1299 11615 55782
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10757.4326 4489.7159 2.396 0.0222 *
## z.lag.1 -1.8727 0.2784 -6.727 9.94e-08 ***
## z.diff.lag 0.3039 0.1643 1.850 0.0730 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 25710 on 34 degrees of freedom
## Multiple R-squared: 0.7434, Adjusted R-squared: 0.7283
## F-statistic: 49.26 on 2 and 34 DF, p-value: 9.051e-11
##
##
## Value of test-statistic is: -6.7275 22.6384
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: mbode ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2452.1 -694.0 -47.3 590.4 3168.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 661.6217 286.0963 2.313 0.02693 *
## z.lag.1 -0.7611 0.2586 -2.943 0.00582 **
## z.diff.lag -0.1790 0.1903 -0.940 0.35371
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1337 on 34 degrees of freedom
## Multiple R-squared: 0.4785, Adjusted R-squared: 0.4478
## F-statistic: 15.6 on 2 and 34 DF, p-value: 1.56e-05
##
##
## Value of test-statistic is: -2.9432 4.4899
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: ipt ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -40656 -9327 3771 11639 32723
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3404.7946 3311.8922 1.028 0.31118
## z.lag.1 -0.8849 0.2719 -3.254 0.00257 **
## z.diff.lag -0.1673 0.1830 -0.914 0.36708
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19800 on 34 degrees of freedom
## Multiple R-squared: 0.5366, Adjusted R-squared: 0.5094
## F-statistic: 19.69 on 2 and 34 DF, p-value: 2.092e-06
##
##
## Value of test-statistic is: -3.2544 5.394
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: iyat ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -22397.7 -3807.0 779.7 5979.4 16395.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 492.1421 1615.6681 0.305 0.763
## z.lag.1 -1.6345 0.2746 -5.952 9.95e-07 ***
## z.diff.lag 0.2398 0.1696 1.414 0.167
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9825 on 34 degrees of freedom
## Multiple R-squared: 0.6791, Adjusted R-squared: 0.6603
## F-statistic: 35.98 on 2 and 34 DF, p-value: 4.051e-09
##
##
## Value of test-statistic is: -5.9515 17.7673
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
## ### ADF Testi Sonucu: iode ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2983.2 -931.6 266.0 857.2 1768.0
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 185.07818 214.94749 0.861 0.395248
## z.lag.1 -1.00221 0.24916 -4.022 0.000304 ***
## z.diff.lag -0.01125 0.17381 -0.065 0.948754
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1293 on 34 degrees of freedom
## Multiple R-squared: 0.4998, Adjusted R-squared: 0.4704
## F-statistic: 16.99 on 2 and 34 DF, p-value: 7.676e-06
##
##
## Value of test-statistic is: -4.0223 8.1253
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.58 -2.93 -2.60
## phi1 7.06 4.86 3.94
##
##
## --------------------------
TRENDLİ
for (col in columns_to_test) {
# ts_veri'den ilgili sütunu al, birinci farkını hesapla ve vektör olarak dönüştür
diff_data <- diff(as.vector(ts_veri[, col]))
adf_results[[col]] <- ur.df(diff_data, type = "trend", lags = 1)
}
# Sonuçları yazdır
for (col in names(adf_results)) {
cat("### ADF Testi Sonucu:", col, "###\n")
print(summary(adf_results[[col]]))
cat("\n--------------------------\n")
}
## ### ADF Testi Sonucu: TP ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -62643 -21781 5841 19818 67782
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -8.000e+03 1.253e+04 -0.639 0.527468
## z.lag.1 -9.731e-01 2.400e-01 -4.054 0.000289 ***
## tt 4.394e+02 5.568e+02 0.789 0.435625
## z.diff.lag 2.507e-02 1.750e-01 0.143 0.886963
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 34910 on 33 degrees of freedom
## Multiple R-squared: 0.473, Adjusted R-squared: 0.4251
## F-statistic: 9.873 on 3 and 33 DF, p-value: 8.54e-05
##
##
## Value of test-statistic is: -4.054 5.5091 8.2555
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: YP ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -55989 -19165 -5888 14100 82193
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.271e+03 1.056e+04 0.310 0.759
## z.lag.1 -1.483e+00 2.898e-01 -5.117 1.31e-05 ***
## tt -2.135e+02 4.657e+02 -0.458 0.650
## z.diff.lag 7.472e-02 1.756e-01 0.426 0.673
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 30150 on 33 degrees of freedom
## Multiple R-squared: 0.6867, Adjusted R-squared: 0.6582
## F-statistic: 24.11 on 3 and 33 DF, p-value: 1.896e-08
##
##
## Value of test-statistic is: -5.1167 8.7547 13.0913
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: mpt ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -92865 -14085 4158 12429 47923
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.747e+03 1.017e+04 -0.762 0.451496
## z.lag.1 -1.356e+00 3.077e-01 -4.405 0.000105 ***
## tt 1.569e+03 5.266e+02 2.980 0.005372 **
## z.diff.lag 6.777e-02 1.929e-01 0.351 0.727572
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 28990 on 33 degrees of freedom
## Multiple R-squared: 0.6264, Adjusted R-squared: 0.5924
## F-statistic: 18.44 on 3 and 33 DF, p-value: 3.327e-07
##
##
## Value of test-statistic is: -4.4049 6.8232 9.9986
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: mbyat ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -53478 -12895 751 11479 52333
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3850.9592 9023.4307 0.427 0.6723
## z.lag.1 -1.9016 0.2812 -6.763 1.04e-07 ***
## tt 353.2175 399.8766 0.883 0.3835
## z.diff.lag 0.3177 0.1655 1.919 0.0637 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 25790 on 33 degrees of freedom
## Multiple R-squared: 0.7493, Adjusted R-squared: 0.7266
## F-statistic: 32.89 on 3 and 33 DF, p-value: 4.977e-10
##
##
## Value of test-statistic is: -6.7629 15.2548 22.8732
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: mbode ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2318.4 -846.2 242.5 597.1 2870.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -287.06782 428.88897 -0.669 0.507942
## z.lag.1 -1.19144 0.28207 -4.224 0.000177 ***
## tt 62.79367 22.51440 2.789 0.008710 **
## z.diff.lag 0.02965 0.18919 0.157 0.876426
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1221 on 33 degrees of freedom
## Multiple R-squared: 0.578, Adjusted R-squared: 0.5396
## F-statistic: 15.07 on 3 and 33 DF, p-value: 2.391e-06
##
##
## Value of test-statistic is: -4.2239 6.183 9.084
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: ipt ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -39430 -8107 1208 14601 39683
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -5406.3581 6863.4927 -0.788 0.43650
## z.lag.1 -0.9830 0.2758 -3.564 0.00114 **
## tt 451.8280 309.7656 1.459 0.15412
## z.diff.lag -0.1262 0.1822 -0.692 0.49364
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19480 on 33 degrees of freedom
## Multiple R-squared: 0.5647, Adjusted R-squared: 0.5251
## F-statistic: 14.27 on 3 and 33 DF, p-value: 3.944e-06
##
##
## Value of test-statistic is: -3.5637 4.4245 6.5348
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: iyat ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23339 -3535 1021 6100 15893
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -925.0689 3476.6118 -0.266 0.792
## z.lag.1 -1.6428 0.2784 -5.900 1.3e-06 ***
## tt 70.8690 153.4346 0.462 0.647
## z.diff.lag 0.2428 0.1717 1.414 0.167
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9941 on 33 degrees of freedom
## Multiple R-squared: 0.6812, Adjusted R-squared: 0.6522
## F-statistic: 23.5 on 3 and 33 DF, p-value: 2.52e-08
##
##
## Value of test-statistic is: -5.8998 11.6419 17.4072
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
## ### ADF Testi Sonucu: iode ###
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2936.4 -900.3 192.7 919.1 1544.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -449.86749 451.27467 -0.997 0.326076
## z.lag.1 -1.12787 0.25623 -4.402 0.000106 ***
## tt 32.55032 20.46961 1.590 0.121331
## z.diff.lag 0.05198 0.17461 0.298 0.767820
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1265 on 33 degrees of freedom
## Multiple R-squared: 0.5354, Adjusted R-squared: 0.4932
## F-statistic: 12.68 on 3 and 33 DF, p-value: 1.128e-05
##
##
## Value of test-statistic is: -4.4018 6.5033 9.7176
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -4.15 -3.50 -3.18
## phi2 7.02 5.13 4.31
## phi3 9.31 6.73 5.61
##
##
## --------------------------
PHİLLİPS PERON TESTİ
cat("Phillips-Perron Testi (Drift - Seviye):\n")
## Phillips-Perron Testi (Drift - Seviye):
for (col in columns_to_test) {
result <- ur.pp(as.vector(ts_veri[, col]), type = "Z-tau", model = "constant")
p_value <- pnorm(abs(result@teststat), lower.tail = FALSE) * 2 # Yaklasik p-degeri
cat(col, ": PP Istatistigi =", round(result@teststat, 4),
", P-Degeri =", round(p_value, 4),
", Sonuc =", ifelse(p_value < 0.05, "Duragan", "Duragan Degil"), "\n")
}
## TP : PP Istatistigi = -2.3241 , P-Degeri = 0.0201 , Sonuc = Duragan
## YP : PP Istatistigi = -3.6933 , P-Degeri = 2e-04 , Sonuc = Duragan
## mpt : PP Istatistigi = 3.9139 , P-Degeri = 1e-04 , Sonuc = Duragan
## mbyat : PP Istatistigi = -0.1458 , P-Degeri = 0.8841 , Sonuc = Duragan Degil
## mbode : PP Istatistigi = 4.6814 , P-Degeri = 0 , Sonuc = Duragan
## ipt : PP Istatistigi = 0.0482 , P-Degeri = 0.9615 , Sonuc = Duragan Degil
## iyat : PP Istatistigi = -4.0536 , P-Degeri = 1e-04 , Sonuc = Duragan
## iode : PP Istatistigi = -0.2968 , P-Degeri = 0.7667 , Sonuc = Duragan Degil
cat("\nPhillips-Perron Testi (Drift - Birinci Fark):\n")
##
## Phillips-Perron Testi (Drift - Birinci Fark):
for (col in columns_to_test) {
diff_data <- diff(as.vector(ts_veri[, col]))
result_diff <- ur.pp(diff_data, type = "Z-tau", model = "constant")
p_value <- pnorm(abs(result_diff@teststat), lower.tail = FALSE) * 2
cat(col, ": PP Istatistigi =", round(result_diff@teststat, 4),
", P-Degeri =", round(p_value, 4),
", Sonuc =", ifelse(p_value < 0.05, "Duragan", "Duragan Degil"), "\n")
}
## TP : PP Istatistigi = -5.5055 , P-Degeri = 0 , Sonuc = Duragan
## YP : PP Istatistigi = -9.0327 , P-Degeri = 0 , Sonuc = Duragan
## mpt : PP Istatistigi = -6.169 , P-Degeri = 0 , Sonuc = Duragan
## mbyat : PP Istatistigi = -11.1433 , P-Degeri = 0 , Sonuc = Duragan
## mbode : PP Istatistigi = -5.5882 , P-Degeri = 0 , Sonuc = Duragan
## ipt : PP Istatistigi = -6.2997 , P-Degeri = 0 , Sonuc = Duragan
## iyat : PP Istatistigi = -8.8195 , P-Degeri = 0 , Sonuc = Duragan
## iode : PP Istatistigi = -6.01 , P-Degeri = 0 , Sonuc = Duragan
Trend modeli için PP testi (Seviye ve Birinci Fark)
cat("\nPhillips-Perron Testi (Trend - Seviye):\n")
##
## Phillips-Perron Testi (Trend - Seviye):
for (col in columns_to_test) {
result_trend <- ur.pp(as.vector(ts_veri[, col]), type = "Z-tau", model = "trend")
p_value <- pnorm(abs(result_trend@teststat), lower.tail = FALSE) * 2
cat(col, ": PP Istatistigi =", round(result_trend@teststat, 4),
", P-Degeri =", round(p_value, 4),
", Sonuc =", ifelse(p_value < 0.05, "Duragan", "Duragan Degil"), "\n")
}
## TP : PP Istatistigi = -2.0703 , P-Degeri = 0.0384 , Sonuc = Duragan
## YP : PP Istatistigi = -3.7378 , P-Degeri = 2e-04 , Sonuc = Duragan
## mpt : PP Istatistigi = 0.683 , P-Degeri = 0.4946 , Sonuc = Duragan Degil
## mbyat : PP Istatistigi = -4.4082 , P-Degeri = 0 , Sonuc = Duragan
## mbode : PP Istatistigi = 1.3186 , P-Degeri = 0.1873 , Sonuc = Duragan Degil
## ipt : PP Istatistigi = -0.0911 , P-Degeri = 0.9274 , Sonuc = Duragan Degil
## iyat : PP Istatistigi = -4.0066 , P-Degeri = 1e-04 , Sonuc = Duragan
## iode : PP Istatistigi = -0.5888 , P-Degeri = 0.556 , Sonuc = Duragan Degil
cat("\nPhillips-Perron Testi (Trend - Birinci Fark):\n")
##
## Phillips-Perron Testi (Trend - Birinci Fark):
for (col in columns_to_test) {
diff_data <- diff(as.vector(ts_veri[, col]))
result_trend_diff <- ur.pp(diff_data, type = "Z-tau", model = "trend")
p_value <- pnorm(abs(result_trend_diff@teststat), lower.tail = FALSE) * 2
cat(col, ": PP Istatistigi =", round(result_trend_diff@teststat, 4),
", P-Degeri =", round(p_value, 4),
", Sonuc =", ifelse(p_value < 0.05, "Duragan", "Duragan Degil"), "\n")
}
## TP : PP Istatistigi = -5.5547 , P-Degeri = 0 , Sonuc = Duragan
## YP : PP Istatistigi = -9.0182 , P-Degeri = 0 , Sonuc = Duragan
## mpt : PP Istatistigi = -7.7604 , P-Degeri = 0 , Sonuc = Duragan
## mbyat : PP Istatistigi = -11.367 , P-Degeri = 0 , Sonuc = Duragan
## mbode : PP Istatistigi = -6.9746 , P-Degeri = 0 , Sonuc = Duragan
## ipt : PP Istatistigi = -6.6586 , P-Degeri = 0 , Sonuc = Duragan
## iyat : PP Istatistigi = -8.7658 , P-Degeri = 0 , Sonuc = Duragan
## iode : PP Istatistigi = -6.3873 , P-Degeri = 0 , Sonuc = Duragan
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.2
library(reshape2)
library(tidyr)
##
## Attaching package: 'tidyr'
## The following object is masked from 'package:reshape2':
##
## smiths
# Gerekli kütüphaneleri yükleme
library(ggplot2)
library(tidyr)
# Veri setini oluÅŸturma
data <- data.frame(
Zaman = c("2015Q1", "2015Q2", "2015Q3", "2015Q4", "2016Q1", "2016Q2", "2016Q3", "2016Q4",
"2017Q1", "2017Q2", "2017Q3", "2017Q4", "2018Q1", "2018Q2", "2018Q3", "2018Q4",
"2019Q1", "2019Q2", "2019Q3", "2019Q4", "2020Q1", "2020Q2", "2020Q3", "2020Q4",
"2021Q1", "2021Q2", "2021Q3", "2021Q4", "2022Q1", "2022Q2", "2022Q3", "2022Q4",
"2023Q1", "2023Q2", "2023Q3", "2023Q4", "2024Q1", "2024Q2", "2024Q3", "2024Q4"),
TP = c(517270.7864, 494022.3545, 475093.5708, 470659.8765, 473663.6273, 496847.5114, 496420.754, 471366.5254,
444389.4509, 487480.2678, 507361.1497, 497824.3205, 440785.9335, 402763.8895, 338346.0486, 333842.1971,
401596.5664, 375475.0211, 404596.6907, 417125.7733, 426607.0742, 436370.1877, 443709.215, 420058.1094,
461311.5519, 418558.7537, 435401.2489, 378130.1938, 342648.1827, 359756.6648, 362236.5942, 413578.9707,
478732.1422, 501581.8121, 446200.1633, 469510.7296, 469658.3913, 496989.8771, 518716.414, 506077.2505),
YP = c(302967.8508, 296201.1354, 324223.2254, 298681.0496, 302280.8733, 315387.2749, 318228.4563, 320391.653,
294288.5632, 302564.0191, 318627.024, 317615.0892, 399944.156, 394775.5981, 377107.8318, 329000.6039,
326911.0773, 304150.3706, 302578.2184, 309179.9232, 318952.9752, 290892.1274, 328960.4675, 300344.3833,
353458.8756, 324809.9226, 328043.5995, 382495.9393, 327689.2889, 319284.5205, 304726.6289, 291596.8217,
288810.7034, 344394.42, 274403.0155, 285527.2396, 297056.4854, 301204.9346, 318787.2312, 278199.3753),
mpt = c(23667.00313, 26321.48841, 29773.42733, 35794.38195, 38032.92085, 49273.64874, 52321.3435, 60163.07932,
79912.80358, 74640.09955, 85355.4178, 98077.53785, 99256.80049, 103004.8718, 93983.81545, 100240.6569,
101686.2134, 104125.5269, 127383.0007, 152125.9665, 154666.237, 154298.8828, 206591.0226, 198723.9163,
213301.1158, 217779.8437, 255558.4023, 292746.4923, 221249.1875, 287930.7625, 295300.7217, 372023.2288,
434479.5505, 501706.5972, 474063.0842, 503830.2905, 544622.3701, 538060.0219, 626632.7517, 696946.1672),
mbyat = c(12929.11751, 15649.75271, 16947.36805, 16809.4529, 18270.81739, 21586.94284, 22737.76681, 28232.28949,
39625.18205, 36315.53792, 42577.72369, 52565.74522, 54440.1785, 73224.14163, 76303.1795, 49077.26476,
54641.28053, 56648.1737, 64315.59277, 79020.1369, 110889.259, 106710.8163, 121775.3658, 149714.5142,
153651.5277, 101328.0903, 98046.24451, 181951.4408, 101116.425, 107877.0516, 118807.0261, 165885.7811,
177481.0068, 163440.5238, 234442.0164, 196981.4734, 233623.8582, 206630.5439, 224550.7398, 237292.262),
mbode = c(1069.442849, 1089.68628, 1225.2544, 1422.107273, 1884.611319, 2010.55455, 2383.297814, 2520.927259,
3170.133611, 3201.317747, 3933.66983, 4169.793208, 5121.590242, 4580.876754, 4161.64429, 4741.891896,
5889.486582, 5262.799425, 6840.878731, 7820.829713, 8887.172229, 7336.011863, 9866.684081, 10411.17937,
12545.09663, 11583.53263, 12866.34127, 12302.48833, 11933.20423, 12605.45638, 13831.70169, 15836.30652,
20005.72268, 19254.40251, 18986.65187, 21272.29112, 24210.01136, 25335.82218, 29514.00331, 31752.81502),
ipt = c(190772.6376, 193837.2711, 190432.674, 206470.4767, 194119.9119, 233575.2411, 221074.1353, 236016.3773,
199879.0805, 219309.3448, 225890.8439, 252256.6514, 250737.5545, 221765.8867, 185773.8205, 190912.0689,
179644.4294, 159289.7578, 167397.686, 184230.8226, 167718.2824, 146378.9391, 167176.1742, 167955.7414,
182165.9295, 176470.0335, 188230.2448, 185724.6378, 162003.462, 179275.456, 180896.423, 216952.2687,
222516.7009, 232620.2292, 227100.9883, 243825.3612, 253553.3566, 257353.7283, 292196.3003, 322412.4889),
iyat = c(60140.50252, 58244.25288, 51038.52594, 53427.00004, 53133.78934, 54025.51392, 50429.02537, 56675.57309,
60163.59259, 59519.6649, 57361.02303, 65529.67323, 63796.16523, 67937.84962, 55528.51565, 45989.08497,
49420.66955, 39878.48167, 41190.18112, 49432.31302, 59732.35311, 56764.0963, 52721.05847, 60420.05785,
60048.25548, 41579.25973, 37289.55732, 60299.16491, 37983.43161, 40294.58378, 59876.42915, 66351.22605,
68053.83495, 55981.40607, 72457.78427, 46943.85452, 54335.19726, 52388.78668, 63745.60659, 68935.27009),
iode = c(13002.85707, 12411.01885, 12435.91154, 12875.48071, 12945.87291, 13517.09344, 12763.65631, 13087.42645,
11415.63797, 12880.8379, 13884.55457, 15050.00191, 14546.80813, 12903.03232, 10445.54336, 10911.17708,
10108.7818, 8715.738889, 9673.005536, 10678.12633, 10666.49163, 7879.848843, 9850.513557, 11193.61072,
11928.32163, 10514.29556, 11139.96209, 10662.11088, 9118.89568, 11087.34617, 11439.57873, 13334.76828,
13950.24052, 15399.72935, 15499.98993, 16163.3032, 15325.31205, 17060.41457, 17820.06638, 19256.63414)
)
# Veriyi uzun formata çevirme (pivot_longer ile)
data_long <- pivot_longer(data,
cols = c("TP", "YP", "mpt", "mbyat", "mbode", "ipt", "iyat", "iode"),
names_to = "Degisken",
values_to = "Deger")
# Gerekli kütüphane (zoo) yükleme
library(zoo)
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
# Zamanı tarih formatına çevirme
data$Zaman_Tarih <- as.Date(as.yearqtr(data$Zaman, format = "%YQ%q"))
# data_long’a tarih sütununu ekleme
# Önce data_long’u yeniden oluşturalım, çünkü Zaman_Tarih sütununu eklememiz gerekiyor
data_long <- pivot_longer(data,
cols = c("TP", "YP", "mpt", "mbyat", "mbode", "ipt", "iyat", "iode"),
names_to = "Degisken",
values_to = "Deger")
# Zaman_Tarih sütununu data_long’a eklemek için birleştirme
data_long$Zaman_Tarih <- rep(data$Zaman_Tarih, times = 8) # Her değişken için Zaman_Tarih tekrarlanır
# Çizgi grafik oluşturma (tarih ekseni ile düzenlenmiş)
ggplot(data_long, aes(x = Zaman_Tarih, y = Deger, color = Degisken, group = Degisken)) +
geom_line(size = 1) +
geom_point(size = 0.5) +
labs(title = "Zaman Serisi GrafiÄŸi (2015Q1 - 2024Q4)",
x = "Zaman",
y = "Deger",
color = "Degisken") +
theme_minimal() +
scale_color_brewer(palette = "Set1") +
scale_x_date(date_breaks = "1 year", date_labels = "%Y") + # Sadece yılları göster
theme(axis.text.x = element_text(angle = 45, hjust = 1)) # X ekseni etiketlerini eÄŸme
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Çizgi grafik oluşturma (etiketleri seyreltme)
ggplot(data_long, aes(x = Zaman, y = Deger, color = Degisken, group = Degisken)) +
geom_line(size = 1) +
geom_point(size = 0.5) +
labs(title = "Zaman Serisi GrafiÄŸi (2015Q1 - 2024Q4)",
x = "Zaman",
y = "Deger",
color = "Degisken") +
theme_minimal() +
scale_color_brewer(palette = "Set1") +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_x_discrete(breaks = data$Zaman[seq(1, length(data$Zaman), by = 4)]) # Her 4. etiketi göster
data_normalized <- data
for (col in c("TP", "YP", "mpt", "mbyat", "mbode", "ipt", "iyat", "iode")) {
data_normalized[[col]] <- (data[[col]] - min(data[[col]])) / (max(data[[col]]) - min(data[[col]]))
}
# Veriyi uzun formata çevirme
data_long_normalized <- pivot_longer(data_normalized,
cols = c("TP", "YP", "mpt", "mbyat", "mbode", "ipt", "iyat", "iode"),
names_to = "Degisken",
values_to = "Deger")
# Grafik çizimi (etiketleri seyreltme)
ggplot(data_long_normalized, aes(x = Zaman, y = Deger, color = Degisken, group = Degisken)) +
geom_line(size = 1) +
geom_point(size = 1.5) +
labs(title = "NormalleÅŸtirilmiÅŸ Zaman Serisi GrafiÄŸi (2015Q1 - 2024Q4)",
x = "Zaman",
y = "Normallestirilmis Deger (0-1)",
color = "Degisken") +
theme_minimal() +
scale_color_brewer(palette = "Set1") +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_x_discrete(breaks = data$Zaman[seq(1, length(data$Zaman), by = 4)]) # Her 4. etiketi göster