Author: Nik Kovač

Research question: Can we say that the average mathematical and verbal IQs for post-coma patients are the same?

1 Data

#install.packages("carData") #installing missing package
library(carData) #Activating package
mydata <- force(Wong) #Creating data frame
head(mydata) #Showing first 6 rows of mydata
##     id days duration  sex      age piq viq
## 1 3358   30        4 Male 20.67077  87  89
## 2 3535   16       17 Male 55.28816  95  77
## 3 3547   40        1 Male 55.91513  95 116
## 4 3592   13       10 Male 61.66461  59  73
## 5 3728   19        6 Male 30.12731  67  73
## 6 3790   13        3 Male 57.06229  76  69
any_na <- any(is.na(mydata)) #checking if there are any missing values in the dataset
print(any_na)
## [1] FALSE
colnames(mydata)<- c("ID","Post_Coma","Coma","Gender","Age","Mathematical","Verbal") #Renaming the columns
mydata$Age <- floor(mydata$Age) #Rounding down the age column
head(mydata)
##     ID Post_Coma Coma Gender Age Mathematical Verbal
## 1 3358        30    4   Male  20           87     89
## 2 3535        16   17   Male  55           95     77
## 3 3547        40    1   Male  55           95    116
## 4 3592        13   10   Male  61           59     73
## 5 3728        19    6   Male  30           67     73
## 6 3790        13    3   Male  57           76     69

In a hospital, it was decided to test post-coma patients’ IQs. 331 patients were randomly selected, and each of them took a test on mathematical IQ and verbal IQ.

  • Unit of observation: Post-coma patients
  • Variables:
      1. Mathematical IQ score (numeric)
      1. Verbal IQ score (numeric)

Explanation of dataset:

  • ID: Patient ID number
  • Post_Coma: Number of days post coma at which IQs were measured
  • Coma: Duration of the coma in days
  • Gender: Gender of the patient with levels male and female
  • Age: Age of the patient at the time of injury in years
  • Mathematical: Patient’s performance IQ (mathematical)
  • Verbal: Patient’s verbal IQ

The dataset is called Wong and I took it from the carData package.

summary(mydata[ , -1]) #descriptive statistics of all columns except "ID", because it does not tell us anything
##    Post_Coma            Coma          Gender         Age       
##  Min.   :   13.0   Min.   :  0.0   Female: 71   Min.   : 6.00  
##  1st Qu.:   59.0   1st Qu.:  1.0   Male  :260   1st Qu.:21.00  
##  Median :  150.0   Median :  7.0                Median :26.00  
##  Mean   :  481.9   Mean   : 14.3                Mean   :31.36  
##  3rd Qu.:  416.0   3rd Qu.: 16.0                3rd Qu.:40.00  
##  Max.   :11628.0   Max.   :255.0                Max.   :80.00  
##   Mathematical        Verbal      
##  Min.   : 50.00   Min.   : 64.00  
##  1st Qu.: 77.00   1st Qu.: 85.00  
##  Median : 87.00   Median : 94.00  
##  Mean   : 87.56   Mean   : 94.96  
##  3rd Qu.: 97.00   3rd Qu.:105.00  
##  Max.   :133.00   Max.   :132.00

From this table we can gather a lot of information and I will explain some:

  • We can see that the mathematical and verbal IQ means in the sample size are not the same
  • The minimum mathematical IQ score in the sample is 14 points lower than the minimum verbal
  • There are 71 female patients in the study and 260 male
  • Ages of the patients range from 6 years to 80 years

2 Analysis

Because I am trying to figure out the difference between two arithmetic means between two comparable numeric variables, I will try to use the parametric test: Paired samples t-test

Parametric test for paired samples

t.test(mydata$Mathematical, mydata$Verbal, 
       paired = TRUE, 
       alternative = "two.sided") #paired samples t-test
## 
##  Paired t-test
## 
## data:  mydata$Mathematical and mydata$Verbal
## t = -11.02, df = 330, p-value < 2.2e-16
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  -8.730247 -6.085463
## sample estimates:
## mean difference 
##       -7.407855
mydata$Difference <- mydata$Mathematical - mydata$Verbal #Creating a new column with the differences in scores for each patient

library(effectsize)
cohens_d(mydata$Difference) #effect size
## Cohen's d |         95% CI
## --------------------------
## -0.61     | [-0.72, -0.49]
interpret_cohens_d(0.61, rules = "sawilowsky2009") #interpreting effect size
## [1] "medium"
## (Rules: sawilowsky2009)

Explanation of results:

Based on the sample data we reject null hypothesis (p<0.001) and conclude that the average mathematical IQ score of post-coma patients is not the same as the average verbal IQ score. On average post-coma patients score better on the verbal IQ test. The size of differences is medium.

Now I need to figure out if all assumptions are met:

Since we already know that both variables are numeric and comparable, we go on to test the normality assumption:

#install.packages("ggplot2")
library(ggplot2)
ggplot(mydata, aes(x = Difference)) +
  geom_histogram(binwidth = 5, color = "black", fill = "skyblue") +
  xlab("Differences")

From the histogram we can assume that there are no outliers but we cannot assume that normality of differences is met, so I will test it with the shapiro-wilk normality test:

shapiro.test(mydata$Difference)
## 
##  Shapiro-Wilk normality test
## 
## data:  mydata$Difference
## W = 0.98496, p-value = 0.001576

Explaining the results:

Based on the sample data we reject the null hypothesis (p=0.002) and conclude that differences on the population are not normally distributed.

This means that we cannot trust the validity of the parametric paired samples t-test, so we will use an alternative non-parametric Wilcoxon’s signed rank test.

Nonparametric test for paired samples

wilcox.test(mydata$Mathematical, mydata$Verbal, 
            paired = TRUE,
            correct = FALSE,
            exact = FALSE,
            alternative = "two.sided") #Wilcoxon's signed rank test
## 
##  Wilcoxon signed rank test
## 
## data:  mydata$Mathematical and mydata$Verbal
## V = 9481.5, p-value < 2.2e-16
## alternative hypothesis: true location shift is not equal to 0
library(effectsize)
effectsize(wilcox.test(mydata$Mathematical, mydata$Verbal, 
                       paired = TRUE,
                       correct = FALSE,
                       exact = FALSE,
                       alternative = "two.sided"))
## r (rank biserial) |         95% CI
## ----------------------------------
## -0.63             | [-0.70, -0.55]
interpret_rank_biserial(0.63)
## [1] "very large"
## (Rules: funder2019)

Explanation of results:

Based on the sample data we reject the null hypothesis (p<0.001) and conclude that the location distributions for mathematical IQ scores and verbal IQ scores are different. The average mathematical IQ score is not the same as the average verbal IQ score of post-coma patients, the average verbal IQ scores were higher. The difference in location distributions is very large.

3 Conclusion

Research question: Can we say that the average mathematical and verbal IQs for post-coma patients are the same?

  • We cannot statistically say that the average mathematical and verbal IQs for post-coma patients are the same, in fact we can claim that not only are they different, but the verbal IQ scores are higher than mathematical.