## [1] 0
Veri setinde eksik veri bulunmamaktadır.
gt
paketi ile, SES tablosu
flextable
ile yapılmıştır.library(gt)
library(dplyr)
cinsiyet_df <- veri %>%
count(Cinsiyet) %>%
mutate(Oran = round(n / sum(n) * 100, 1))
cinsiyet_df %>%
gt() %>%
tab_header(title = "Cinsiyet Dağılımı") %>%
fmt_number(columns = Oran, decimals = 1) %>%
cols_label(Cinsiyet = "Cinsiyet", n = "Frekans", Oran = "Oran (%)") %>%
tab_options(
table.align = "center", # Tabloyu ortalar
column_labels.font.weight = "bold" # Başlıkları kalın yapar
)
Cinsiyet Dağılımı | ||
Cinsiyet | Frekans | Oran (%) |
---|---|---|
1 | 257 | 77.6 |
2 | 74 | 22.4 |
library(flextable)
ses_df <- veri %>%
count(SES) %>%
mutate(Oran = round(n / sum(n) * 100, 1))
ses_df %>%
flextable() %>%
set_header_labels(SES = "SES", n = "Frekans", Oran = "Oran (%)") %>%
theme_vanilla() %>%
autofit()
SES | Frekans | Oran (%) |
---|---|---|
1 | 18 | 5.4 |
2 | 262 | 79.2 |
3 | 51 | 15.4 |
cinsiyet_df <- veri %>%
count(Cinsiyet) %>%
mutate(Oran = round(n / sum(n) * 100, 1))
ggplot(cinsiyet_df, aes(x = factor(Cinsiyet, labels = c("Kadin", "Erkek")), y = n, fill = factor(Cinsiyet))) +
geom_bar(stat = "identity", show.legend = FALSE) +
geom_text(aes(label = paste0(n, " (", Oran, "%)")), vjust = 5, size = 5) +
scale_fill_manual(values = c("steelblue", "darkred")) +
theme_minimal() +
labs(title = "Cinsiyet Dagilimi", x = "Cinsiyet", y = "Frekans")
ses_df <- veri %>%
count(SES) %>%
mutate(Oran = round(n / sum(n) * 100, 1))
ggplot(ses_df, aes(x = factor(SES, labels = c("Dusuk", "Orta", "Yuksek")), y = n, fill = factor(SES))) +
geom_bar(stat = "identity", show.legend = FALSE) +
geom_text(aes(label = paste0(n, " (", Oran, "%)")), vjust = 1.5, size = 3) +
scale_fill_manual(values = c("darkgreen", "orange", "purple")) +
theme_minimal() +
labs(title = "SES Dagilimi", x = "SES", y = "Frekans")
b1 <- c("WV1", "WV2", "WV3", "WV4", "WV5", "WV6", "WV7", "WV8", "WV9")
b2 <- c("WV10", "WV11", "WV12", "WV13", "WV14", "WV15", "WV16")
veri3 <- veri2 %>%
mutate(
b1_top = rowSums(select(., all_of(b1)), na.rm = TRUE),
b2_top = rowSums(select(., all_of(b2)), na.rm = TRUE)
)
ggplot(veri3, aes(x = b1_top)) +
geom_histogram(bins = 15, fill = "blue", alpha = 0.7, color = "black") +
theme_minimal() +
labs(title = "Boyut 1 Puan Dağılımı", x = "Boyut 1 Puanı", y = "Frekans")
ggplot(veri3, aes(x = b2_top)) +
geom_histogram(bins = 15, fill = "red", alpha = 0.7, color = "black") +
theme_minimal() +
labs(title = "Boyut 2 Puan Dağılımı", x = "Boyut 2 Puanı", y = "Frekans")
Önce boyut 2 için ortalama ve standart sapma hesapladım
Toplam puan grafiğinde ortalamanın üstüne değerini yazacağım
çizgiyi geom_vline
ile çizdirdim.
geom_vline
ortalamanın 1 standart sapma fazlasına da
birer referans çizgisi ekledim.
annote
ile çizgilerin üzerine yazdım.
b2_ort <- mean(veri3$b2_top, na.rm = TRUE)
b2_sd <- sd(veri3$b2_top, na.rm = TRUE)
ggplot(veri3, aes(x = b2_top)) +
geom_histogram(fill = "yellow", alpha = 1, color = "black") +
geom_vline(xintercept = b2_ort, color = "red", linetype = "solid", size = 1) +
annotate("text", x = b2_ort, y = 10, label = paste("Ortalama:", round(b2_ort, 2)), color = "black", vjust = -1) + geom_vline(xintercept = b2_ort + b2_sd, color = "blue", linetype = "dashed", size = 1) +
annotate("text", x = b2_ort + b2_sd, y = 10, label = "+1 SD", color = "black", vjust = -1) + geom_vline(xintercept = b2_ort - b2_sd, color = "blue", linetype = "dashed", size = 1) +
annotate("text", x = b2_ort - b2_sd, y = 10, label = "-1 SD", color = "black", vjust = -1) + theme_minimal() +
labs(title = "Boyut 2 Puan Dagilimi ve Referans Cizgileri", x = "Boyut 2 Puani", y = "Frekans")
Z puanı
outliars_b1 <- which(abs(z_puanlari$b1_top) > 3)
outliars_b2 <- which(abs(z_puanlari$b2_top) > 3)
veri3[outliars_b1, c("b1_top")]
## # A tibble: 1 × 1
## b1_top
## <dbl>
## 1 9
## # A tibble: 0 × 1
## # ℹ 1 variable: b2_top <dbl>
Boyut 1’de 9 veri uç değer olarak belirlenmiştir.
Ek kanıt sunmak adına kutu grafiği ile de bakıldı.
Kutu Grafiği
Önce boyut 1 ve boyut 2’deki uç değerler belirlendi
Uç değerleri içseren satır numaraları belirlendi (Bouyt 2’de uç değer olmadığı için sadece boyut 1 için kodlamaya devam edildi.)
plotly
paketi ile kutu grafiği çizildi.
Bu pakette grafiğin üzerinde uç değerlere gelindiğinde hangi satırlarda olduğu gösteriliyor.
out_boyut1 <- boxplot.stats(veri3$b1_top)$out
out_boyut2 <- boxplot.stats(veri3$b2_top)$out
uc_boyut1 <- which(veri3$b1_top %in% out_boyut1)
uc_boyut2 <- which(veri3$b2_top %in% out_boyut2)
uc_boyut1
## [1] 21 22 36 37 64 73 273 315 330
## integer(0)
plot_ly() %>%
add_boxplot(y = veri3$b1_top, name = "Boyut 1", boxpoints = "outliers", marker = list(color = "red")) %>%
add_markers(x = rep("Boyut 1", length(out_boyut1)),
y = veri3$b1_top[out_boyut1],
text = paste("Satır No:", out_boyut1),
showlegend = FALSE,
marker = list(color = "red", size = 10)) %>%
layout(title = "Boyut 1 Uç Değer Analizi",
yaxis = list(title = "Boyut 1 Puanı"),
xaxis = list(title = "Boyut"))
Kutu grafiğine göre de boyut 1’de 9 adet uç değer belirlenmiştir.
Aşağıdaki kod ile, 9 adet uç değer veri setinden kaldırılmış, veri seti veri4 olarak kaydedilmiştir.
## # A tibble: 5 × 20
## Cinsiyet SES WV1 WV2 WV3 WV4 WV5 WV6 WV7 WV8 WV9 WV10
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2 2 5 6 5 7 7 6 5 7 7 4
## 2 2 3 2 6 5 6 6 7 7 7 7 7
## 3 2 2 7 7 7 7 7 7 7 7 7 2
## 4 2 2 2 4 4 6 4 2 5 2 4 5
## 5 2 2 7 6 7 7 5 6 5 7 7 4
## # ℹ 8 more variables: WV11 <dbl>, WV12 <dbl>, WV13 <dbl>, WV14 <dbl>,
## # WV15 <dbl>, WV16 <dbl>, b1_top <dbl>, b2_top <dbl>
karsilastirma_df <- data.frame(
Özellik = c("N", "Boyut 1 Ortalama", "Boyut 1 Standart Sapma",
"Boyut 2 Ortalama", "Boyut 2 Standart Sapma"),
Veri3 = c(nrow(veri3),
round(mean(veri3$b1_top, na.rm = TRUE), 2),
round(sd(veri3$b1_top, na.rm = TRUE), 2),
round(mean(veri3$b2_top, na.rm = TRUE), 2),
round(sd(veri3$b2_top, na.rm = TRUE), 2)),
Veri4 = c(nrow(veri4),
round(mean(veri4$b1_top, na.rm = TRUE), 2),
round(sd(veri4$b1_top, na.rm = TRUE), 2),
round(mean(veri4$b2_top, na.rm = TRUE), 2),
round(sd(veri4$b2_top, na.rm = TRUE), 2))
)
karsilastirma_df <- karsilastirma_df %>% mutate(across(everything(), as.character))
karsilastirma_df %>%
kable(col.names = c("Özellik", "Veri3", "Veri4"), caption = "Veri3 / Veri4 Karşılaştırması") %>%
kable_styling(full_width = FALSE, position = "center")
Özellik | Veri3 | Veri4 |
---|---|---|
N | 331 | 327 |
Boyut 1 Ortalama | 49.15 | 49.26 |
Boyut 1 Standart Sapma | 11.53 | 11.54 |
Boyut 2 Ortalama | 33.03 | 33 |
Boyut 2 Standart Sapma | 9.83 | 9.87 |
Çok değişkenli uç değerler için mahalanobis mesafelerine bakılır.
Ki-kare dağılımına göre kritik sınır (p < 0.001), sd=2 olarak alınacak(2 değişken).
Kritik sınırdan büyük olan gözlemler uç değer olarak belirlenip silinecek.
veri_maha <- veri4[, c("b1_top", "b2_top")]
mhlnbs <- mahalanobis(
veri_maha,
center = colMeans(veri_maha, na.rm = TRUE),
cov = cov(veri_maha, use = "complete.obs")
)
cutoff <- qchisq(p = 0.999, df = ncol(veri_maha))
uc_degerler_maha <- which(mhlnbs > cutoff)
veri4[uc_degerler_maha, ]
## # A tibble: 0 × 20
## # ℹ 20 variables: Cinsiyet <dbl>, SES <dbl>, WV1 <dbl>, WV2 <dbl>, WV3 <dbl>,
## # WV4 <dbl>, WV5 <dbl>, WV6 <dbl>, WV7 <dbl>, WV8 <dbl>, WV9 <dbl>,
## # WV10 <dbl>, WV11 <dbl>, WV12 <dbl>, WV13 <dbl>, WV14 <dbl>, WV15 <dbl>,
## # WV16 <dbl>, b1_top <dbl>, b2_top <dbl>
Mahalanobis mesafesi analizine göre veri setinde çok değişkenli uç değerler yoktur.
SÜRE: 1 SAAT 40 DAKİKA