Eksik veri inceleme Bu ödevde, TIMSS 2015 uygulamasına ait bir kitapçığın Türkiye ve Amerika verilerini kullanacaksınız.

Veri seti adı: “TRUSA.RDS”. Bu veri setini R ortamına aktarınız.

Veri setinde eksik veri olup olmadığını kontrol ediniz.

Kitapçıktaki 35 maddenin toplamını hesaplayarak veri setine yeni bir sütun olarak ekleyiniz.

Toplam puanın her iki ülkeye göre betimsel istatistiklerini hesaplayınız.

Toplam puanın, Türkiye ve ABD örneklemlerinde farklılaşıp farklılaşmadığını t testi ile test ediniz.

Veri setinde %5, %10 ve %15 oranında eksik veriler oluşturunuz.

Oluşturulan eksik veri setlerinde önce eksik verinin rastgele olup olmadığını test ediniz. Ardından, liste bazında silme yöntemiyle eksik verileri temizleyerek e seçeneğinde gerçekleştirdiğiniz t testini tekrarlayınız. Tam veri ile elde edilen sonuçlarla karşılaştırınız.

f seçeneğinde oluşturulan veri setlerindeki eksik verileri, belirlediğiniz bir kayıp veri atama yöntemiyle doldurunuz. Daha sonra, e seçeneğinde gerçekleştirdiğiniz t testini tekrar ediniz ve tam veri ile elde edilen sonuçlarla karşılaştırınız.

Eksik veri oranının uygulanan yöntemlerin performansına etkisini açıklayınız.

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

a. Data tanımlama

TRUSA <- readRDS("TRUSA.RDS")

b. Kayıp veri kontrol

library(naniar)
miss_var_table(TRUSA)
## # A tibble: 1 × 3
##   n_miss_in_var n_vars pct_vars
##           <int>  <int>    <dbl>
## 1             0     38      100

c. Toplam puan hesaplama

SUM <- TRUSA %>% dplyr :: select(starts_with("M")) %>% rowSums()
TRUSA$SUM <- SUM

d. toplam puanın betimsel istatistikleri

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(psych)
describe.by(TRUSA$SUM, TRUSA$CNT)
## Warning in describe.by(TRUSA$SUM, TRUSA$CNT): describe.by is deprecated.
## Please use the describeBy function
## 
##  Descriptive statistics by group 
## group: TUR
##    vars   n  mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 435 13.45 7.57     11   12.74 7.41   2  32    30 0.71    -0.61 0.36
## ------------------------------------------------------------ 
## group: USA
##    vars   n  mean   sd median trimmed mad min max range skew kurtosis   se
## X1    1 716 17.05 7.53     17   16.92 8.9   1  34    33  0.1     -0.9 0.28

e. Bağımsız örneklem t testi

library(effsize) # effect size hesaplamak için
## 
## Attaching package: 'effsize'
## The following object is masked from 'package:psych':
## 
##     cohen.d
t_test_result <- t.test(SUM~CNT, data=TRUSA,var.equal = TRUE)
print(t_test_result)
## 
##  Two Sample t-test
## 
## data:  SUM by CNT
## t = -7.8348, df = 1149, p-value = 1.064e-14
## alternative hypothesis: true difference in means between group TUR and group USA is not equal to 0
## 95 percent confidence interval:
##  -4.493049 -2.693382
## sample estimates:
## mean in group TUR mean in group USA 
##          13.45287          17.04609

# Cohen d hesaplama

cohen_d_result <- effsize::cohen.d(TRUSA$SUM[TRUSA$CNT == "TUR"],
                          TRUSA$SUM[TRUSA$CNT == "USA"],
                          pooled = TRUE)
print(cohen_d_result)
## 
## Cohen's d
## 
## d estimate: -0.4762813 (small)
## 95 percent confidence interval:
##      lower      upper 
## -0.5971341 -0.3554285

f. veri setinde % eksik veri oluşturma

library(mvdalab)   # introNas fonksiyonu rastgele eksik veri oluşturuyor
## 
## Attaching package: 'mvdalab'
## The following object is masked from 'package:psych':
## 
##     smc
TRUSA_5 <- introNAs(TRUSA, percent = 5)
TRUSA_10 <- introNAs(TRUSA, percent = 10)
TRUSA_15 <- introNAs(TRUSA, percent = 15)

TRUSA_5 %>% is.na() %>% colSums()
##   IDSTUD   IDBOOK  M042182  M042081  M042049  M042052  M042076 M042302A 
##       54       68       53       60       51       49       69       56 
## M042302B M042302C  M042100  M042202  M042240  M042093  M042271  M042268 
##       58       66       63       48       63       65       62       55 
##  M042159  M042164  M042167  M062208 M062208A M062208B M062208C M062208D 
##       56       46       64       63       61       45       41       49 
##  M062153 M062111A M062111B  M062237  M062314  M062074  M062183  M062202 
##       50       45       59       50       61       57       62       58 
##  M062246  M062286  M062325  M062106  M062124      CNT      SUM 
##       49       59       70       68       68       66       57
TRUSA_10 %>% is.na() %>% colSums()
##   IDSTUD   IDBOOK  M042182  M042081  M042049  M042052  M042076 M042302A 
##      116      111      107      113      115      109      117      120 
## M042302B M042302C  M042100  M042202  M042240  M042093  M042271  M042268 
##      119      119      130      137      130      114      113      126 
##  M042159  M042164  M042167  M062208 M062208A M062208B M062208C M062208D 
##      142      110      114      116      122      112      100      112 
##  M062153 M062111A M062111B  M062237  M062314  M062074  M062183  M062202 
##      118      126       94      111       96      115      105       99 
##  M062246  M062286  M062325  M062106  M062124      CNT      SUM 
##      108      105      125      102      119      124      118
TRUSA_15 %>% is.na() %>% colSums()
##   IDSTUD   IDBOOK  M042182  M042081  M042049  M042052  M042076 M042302A 
##      170      162      172      151      170      177      160      168 
## M042302B M042302C  M042100  M042202  M042240  M042093  M042271  M042268 
##      177      172      172      161      199      178      191      164 
##  M042159  M042164  M042167  M062208 M062208A M062208B M062208C M062208D 
##      180      183      172      173      189      164      185      171 
##  M062153 M062111A M062111B  M062237  M062314  M062074  M062183  M062202 
##      167      186      167      176      165      171      154      158 
##  M062246  M062286  M062325  M062106  M062124      CNT      SUM 
##      176      210      173      162      185      163      159