Author: Edi Oblak

DATA 1

mydata1 <- force(Wong)
head(mydata1)
##     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

Data description

  • id: patient ID number
  • days: number of days post coma at which IQs were measured
  • duration: duration of the coma in days
  • sex: a factor with levels Female and Male
  • age: age of patients in years at the time of injury
  • piq: performance IQ score
  • viq: verbal IQ score

Unit of observation in our data is patient, sample size is 331, which is appropriate for our analysis. It is good to know that there were 200 patients tested, some of them twice. Those who were tested twice were not tested at the same time, but in a relevant time difference.

Source of data: Wong, P. P., Monette, G., and Weiner, N. I. (2001) Mathematical models of cognitive recovery. Brain Injury, 15, 519–530.

Descriptive stistic

summary(mydata1[ , -1]) # We don't want to describe id.
##       days            duration         sex           age              piq              viq        
##  Min.   :   13.0   Min.   :  0.0   Female: 71   Min.   : 6.513   Min.   : 50.00   Min.   : 64.00  
##  1st Qu.:   59.0   1st Qu.:  1.0   Male  :260   1st Qu.:21.737   1st Qu.: 77.00   1st Qu.: 85.00  
##  Median :  150.0   Median :  7.0                Median :26.877   Median : 87.00   Median : 94.00  
##  Mean   :  481.9   Mean   : 14.3                Mean   :31.853   Mean   : 87.56   Mean   : 94.96  
##  3rd Qu.:  416.0   3rd Qu.: 16.0                3rd Qu.:40.923   3rd Qu.: 97.00   3rd Qu.:105.00  
##  Max.   :11628.0   Max.   :255.0                Max.   :80.033   Max.   :133.00   Max.   :132.00
  • Average patient in our sample was 31.85 years old at the time of injury. Half of patients in our sample were yunger than 26.87 years and half of them were older than that at the time of injury.
  • Our sample is conducted out of 71 female patients and 260 male patients.
  • 25 % of patients were tested for IQs in less than 59 days after awakening from coma and 25 % of patients were tested after more than 416 days after awakening from coma. Lowest value of performance IQ is 50 which indicates mental retardation of patient.
  • Average score of performance IQ of patients is 87.56, which is substantially below expected average of 100 for such test. More than 75 % of patients got a score below 97.
  • Average score of verbal IQ of patients is 94.96, which is below expected average of 100 for such test. Less than 25 % of patients got a score above 105.

RESEARCH QUESTION 1

RQ1: Is there a correlation between the scores of patients achieved in performance IQ and verbal IQ?

We can perform some graphical analysis.

library(car)
scatterplotMatrix(mydata1[ , c(-1,-2,-3,-4,-5)], smooth=FALSE)

### Pearson correlation coefficient

rcorr(as.matrix(mydata1[ , c(-1,-2,-3,-4,-5)]), 
      type = "pearson") # Numerical data!
##      piq  viq
## piq 1.00 0.65
## viq 0.65 1.00
## 
## n= 331 
## 
## 
## P
##     piq viq
## piq      0 
## viq  0

H0: Population correlation coefficient between piq and viq is 0. H1: Population correlation coefficient between piq and viq is not 0.

We reject H0 (p < 0.001). There is positive linear correlation between score on performance IQ and verbal IQ of patients after being in coma for several days due to severe injuries of brains. Linear relationship is positive and semi-strong (|r| = 0.65).

DATA 2

mydata2 <- force(Chile)
head(mydata2)
##   region population sex age education income statusquo vote
## 1      N     175000   M  65         P  35000   1.00820    Y
## 2      N     175000   M  29        PS   7500  -1.29617    N
## 3      N     175000   F  38         P  15000   1.23072    Y
## 4      N     175000   F  49         P  35000  -1.03163    N
## 5      N     175000   F  23         S  35000  -1.10496    N
## 6      N     175000   F  28         P   7500  -1.04685    N

Data description

  • region: A factor with levels: C - Central; M - Metropolitan Santiago area; N - North; S - South; SA - city of Santiago.
  • population: Population size of respondent’s community.
  • sex: A factor with levels: F - female; M - male.
  • age: Age in years.
  • education: A factor with levels (note: out of order): P - Primary; PS - Post-secondary; S - Secondary.
  • income: Monthly income, in Pesos.
  • statusquo: Scale of support for the status-quo.
  • vote: A factor with levels: A - will abstain; N - will vote no (against Pinochet); U - undecided; Y - will vote yes (for Pinochet).

Unit of observation in our data is respondent on national survey conducted in April and May of 1988 by FLASCO/Chile. Sample size is 2700, which is appropriate for our analysis. The only problem of data is that there are some missing data, luckily already marked with NA. All the data that should be in factor format is already in the right form.

Source of data: Personal communication from FLACSO/Chile.

Descriptive stistic

summary(mydata2)
##  region     population     sex           age        education       income         statusquo          vote    
##  C :600   Min.   :  3750   F:1379   Min.   :18.00   P   :1107   Min.   :  2500   Min.   :-1.80301   A   :187  
##  M :100   1st Qu.: 25000   M:1321   1st Qu.:26.00   PS  : 462   1st Qu.:  7500   1st Qu.:-1.00223   N   :889  
##  N :322   Median :175000            Median :36.00   S   :1120   Median : 15000   Median :-0.04558   U   :588  
##  S :718   Mean   :152222            Mean   :38.55   NA's:  11   Mean   : 33876   Mean   : 0.00000   Y   :868  
##  SA:960   3rd Qu.:250000            3rd Qu.:49.00               3rd Qu.: 35000   3rd Qu.: 0.96857   NA's:168  
##           Max.   :250000            Max.   :70.00               Max.   :200000   Max.   : 2.04859             
##                                     NA's   :1                   NA's   :98       NA's   :17
  • There are 1379 females and 1321 males in our sample data. One of all respondents didn’t state his age, 98 of them did not report on their income and 17 of them didn’t respond on the question about their support for the status-quo. There are some more missing responds which we didn’t mentioned.
  • Average respondent in our sample was 38.55 years old at the time of surveying. Half of respondents were younger than 36 years and half of them were older than that.
  • Minimal reported monthly income of respondent was 2500 Pesos, and maximal 200000 Pesos. 25 % of respondents reported average monthly income lower than 7500 Pesos, 75 % of respondents reported average monthly income lower than 35000 Pesos.
  • 25 % of respondents reported that they earn more than 35000 Pesos per month.
  • There are 1107 respondents in our sample data, who reported that they have only primary education, 462 reported that they have post-secondary education and 1120 of them stated that they have secondary education.

RESEARCH QUESTION 2

RQ2: Does education level vary depending on gender of respondent?

Note: We are using gender for explaining variable “sex”.

Assumptions: - Observations must be independent. - Up to 20 % of the expected frequencies can be between 1 and 5, none of them less than 1.

Pearson Chi2 test

H0: There is no association between categorical variables education and gender. H1: There is association between categorical variables education and gender.

results <- chisq.test(mydata2$education, mydata2$sex, 
                      correct = FALSE) # We skip Yates' correction!

results
## 
##  Pearson's Chi-squared test
## 
## data:  mydata2$education and mydata2$sex
## X-squared = 18.219, df = 2, p-value = 0.0001106
addmargins(results$observed)
##                  mydata2$sex
## mydata2$education    F    M  Sum
##               P    607  500 1107
##               PS   199  263  462
##               S    566  554 1120
##               Sum 1372 1317 2689
round(results$expected, 2)
##                  mydata2$sex
## mydata2$education      F      M
##                P  564.82 542.18
##                PS 235.72 226.28
##                S  571.45 548.55
round(results$res, 2)
##                  mydata2$sex
## mydata2$education     F     M
##                P   1.77 -1.81
##                PS -2.39  2.44
##                S  -0.23  0.23

We reject H0 (p < 0.001). We can conclude that there is association between categorical variables education and gender.

  • Primary education (variable P) is not statistically correlated (std.res < 1.96) with gender of participant. Std.res for females with primary education is 1.77 and for males -1.81. We can also claim that secondary education is not statistically correlated (std.res < 7.96) with gender of participant. Std.res for females with secondary education is -0.23 and for males 0.23.
  • There is less than expected females who claimed to have post-secondary education (std.res = -2.39 -> alpha = 5 %).
  • There is more than expected males who claimed to have post-secondary education (std.res = 2.44 -> alpha = 5 %).
addmargins(round(prop.table(results$observed), 3))
##                  mydata2$sex
## mydata2$education     F     M   Sum
##               P   0.226 0.186 0.412
##               PS  0.074 0.098 0.172
##               S   0.210 0.206 0.416
##               Sum 0.510 0.490 1.000
addmargins(round(prop.table(results$observed, 1), 3), 2) 
##                  mydata2$sex
## mydata2$education     F     M   Sum
##                P  0.548 0.452 1.000
##                PS 0.431 0.569 1.000
##                S  0.505 0.495 1.000
addmargins(round(prop.table(results$observed, 2), 3), 1) 
##                  mydata2$sex
## mydata2$education     F     M
##               P   0.442 0.380
##               PS  0.145 0.200
##               S   0.413 0.421
##               Sum 1.000 1.001

For easier grading I explained first numbers in tables (those on position [1,1] in the above matrixes).

  • Out of 2689 participants there is 22.6 % (607/2689) of them that are female and have primary education.

  • Out of all participants who has primary school there is 54.8 % (607/1107) of females.

  • Out of all participants who are female there is 44.2 % (607/1372) of those who has primary education.

library(effectsize)
effectsize::cramers_v(mydata2$education, mydata2$sex)
## Cramer's V (adj.) |       95% CI
## --------------------------------
## 0.08              | [0.04, 1.00]
## 
## - One-sided CIs: upper bound fixed at [1.00].
interpret_cramers_v(0.08)
## [1] "very small"
## (Rules: funder2019)

We can conclude that there is association between categorical variables education and gender, although the effect is very small (|r| = 0.08).