Author: Nik Kovač

Research question 1: What is the relationship between quality of family relationships and current health status for high school students?

Research question 2: Are high school students from rural areas more likely to be in a romantic relationship compared to students from urban areas?

1 Data

mydata <- read.table("./student-mat.csv", header=TRUE, sep=",", dec=";") ##Creating data frame by importing a csv file

head(mydata[c("address","romantic","famrel","health")],) #Showing only the columns related to our research questions
##   address romantic famrel health
## 1       U       no      4      3
## 2       U       no      5      3
## 3       U       no      4      3
## 4       U      yes      3      5
## 5       U       no      4      5
## 6       U       no      5      5

In a high school, it was decided to send out a survey to students on various topics. 395 students participated. I am only going to show and analyze the ones that fit our research questions.

  • Unit of observation: High school students
  • Variables:
      1. Address type (binary)
      1. Romantic status (binary)
      1. Family relationships (ordinal)
      1. Health status (ordinal)

Explanation of dataset:

  • address: Student’s home address type (binary: “U” - urban or “R” - rural)
  • romantic: Student’s romantic relationship status with levels yes and no
  • famrel: Quality of family relationships (ordinal: from 1 - very bad to 5 - very good)
  • health: Current health status (ordinal: from 1 - very bad to 5 - very good)

The dataset is called Student Alcohol Consumption and I took it from a website called Kaggle: https://www.kaggle.com/datasets/uciml/student-alcohol-consumption/data.

mydata$ID <- seq_along(mydata$school) #Assigning an "ID" number to each student

mydata$addressF <- factor(mydata$address,
                          levels = c("U","R"),
                          labels = c("Urban", "Rural"))
mydata$romanticF <- factor(mydata$romantic,
                           levels = c("no","yes"),
                           labels = c("no", "yes"))
mydata$famrelF <- factor(mydata$famrel,
                         levels = c(1, 2, 3, 4, 5),
                         labels = c("Very bad", "bad", "mediocre", "good", "very good"))
mydata$healthF <- factor(mydata$health,
                         levels = c(1, 2, 3, 4, 5),
                         labels = c("very bad", "bad", "mediocre", "good", "very good"))

head(mydata[c("ID","addressF","romanticF","famrelF","healthF")],)
##   ID addressF romanticF   famrelF   healthF
## 1  1    Urban        no      good  mediocre
## 2  2    Urban        no very good  mediocre
## 3  3    Urban        no      good  mediocre
## 4  4    Urban       yes  mediocre very good
## 5  5    Urban        no      good very good
## 6  6    Urban        no very good very good
summary(mydata[,c("addressF","romanticF","famrelF","healthF")]) #descriptive statistics of all relevant columns
##   addressF   romanticF      famrelF         healthF   
##  Urban:307   no :263   Very bad :  8   very bad : 47  
##  Rural: 88   yes:132   bad      : 18   bad      : 45  
##                        mediocre : 68   mediocre : 91  
##                        good     :195   good     : 66  
##                        very good:106   very good:146

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

  • There are only 26 high school students who graded the quality of their family relationships negatively
  • Most of the students (146) graded their current health status as “very good” while only 47 of them graded it “very bad”
  • There are 307 students that live in a city (Urban) and 88 in a rural area
  • 263 students are not in a romantic relationship, while 132 are

2 Analysis RQ1

Because I am trying to figure out the correlation between two ordinal variables, I will use the spearman rank correlation instead of pearson, because variables are not numeric.

But before doing that I need to check if all assumptions are met for spearman:

  • There is a linear relationship
  • There are no outliers
library(ggplot2)
ggplot(data = subset(mydata,),
       aes(x = health, y = famrel)) +
  geom_bar(stat = "summary", fun = "mean") +
  ylab("Quality of family relationship") +
  xlab("Current health status")

library(car)
## Loading required package: carData
scatterplotMatrix(mydata[ , c("health","famrel")], smooth=FALSE)

Even though the relationship between these variables looks a bit funny, I will still assume it is linear and that there are no outliers, therefore we can still use the data for this homework and the spearman rank correlation test is valid.

cor(mydata$health, mydata$famrel,
    method = "spearman")
## [1] 0.08534102

Explanation of results:

  • r = 0.08

There appears to be a positive, very weak (0 <= r =< 0.1) linear correlation between variables health and famrel.

cor.test(mydata$health, mydata$famrel,
    method = "spearman",
    exact = FALSE)
## 
##  Spearman's rank correlation rho
## 
## data:  mydata$health and mydata$famrel
## S = 9394993, p-value = 0.0903
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##        rho 
## 0.08534102

Explanation of results:

  • H0: There is no correlation (rho = 0)
  • H1: There is correlation (rho =/ 0)
  • p = 0.091

We cannot reject null hypothesis (p > 0.05) and conclude that, statistically, we cannot assume any correlation between the current health status of students and the quality of family relationships.

3 Conclusion RQ1: What is the relationship between quality of family relationships and current health status for high school students?

Research question: What is the relationship between quality of family relationships and current health status for high school students?*

  • We cannot statistically say that there is any relationship between quality of family relationship and current health status for high school students (p > 0.05).

2 Analysis RQ2: Are high school students from rural areas more likely to be in a romantic relationship compared to students from urban areas?

Because I am trying to figure out the association between two categorical variables, I will try to use the Chi-square test. But before that I need to check if all assumptions are met:

  • Observations must be independent
  • All expected frequencies are above 5 (because i have a 2x2 contingency table)

We know that all observations are independent because each unit is only measured once and we will see later that the second assumption is also not violated, therefore we can use the chi-square test:

chi_square <- chisq.test(mydata$addressF, mydata$romanticF,
                         correct= TRUE) #Yates' continuity correction because of 2x2 contingency table
chi_square
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  mydata$addressF and mydata$romanticF
## X-squared = 1.2282e-29, df = 1, p-value = 1

Explanation of results:

  • H0: There is no association between the two categorical variables
  • H1: There is association between the two categorical variables
  • p = 1

We cannot reject the null hypothesis (p > 0.05) and conclude that we cannot statistically say there is association between variables address and romantic.

addmargins(chi_square$observed)
##                mydata$romanticF
## mydata$addressF  no yes Sum
##           Urban 204 103 307
##           Rural  59  29  88
##           Sum   263 132 395
addmargins(round(chi_square$expected,2))
##                mydata$romanticF
## mydata$addressF     no    yes Sum
##           Urban 204.41 102.59 307
##           Rural  58.59  29.41  88
##           Sum   263.00 132.00 395

We can see that all expected values are above 5 and almost the same as our observed values, which gives us an indication that there is no association

addmargins(round(prop.table(chi_square$observed), 3))
##                mydata$romanticF
## mydata$addressF    no   yes   Sum
##           Urban 0.516 0.261 0.777
##           Rural 0.149 0.073 0.222
##           Sum   0.665 0.334 0.999
addmargins(round(prop.table(chi_square$observed, 1), 3), 2)
##                mydata$romanticF
## mydata$addressF    no   yes   Sum
##           Urban 0.664 0.336 1.000
##           Rural 0.670 0.330 1.000
addmargins(round(prop.table(chi_square$observed, 2), 3), 1)
##                mydata$romanticF
## mydata$addressF    no   yes
##           Urban 0.776 0.780
##           Rural 0.224 0.220
##           Sum   1.000 1.000

Explanation of results:

  • 0.516 -> 51.6% of all high school students live in an urban area and do not have a romantic relationship
  • 0.664 -> 66.4% of high school students that live in an urban area, do not have a romantic relationship
  • 0.776 -> 77.6% of high school students that do not have a romantic relationship, live in an urban area
round(chi_square$residuals, 2)
##                mydata$romanticF
## mydata$addressF    no   yes
##           Urban -0.03  0.04
##           Rural  0.05 -0.08

Explanation of results of standardized residuals:

  • Standardized residuals tell us if there are, statistically, more (or less) than expected number of a certain combination of variables and at what alpha value.
  • Since all of our standardized residuals fall into the not statistically significant bracket, we won’t interpret any.
#install.packages("effectsize")
library(effectsize)

effectsize::cramers_v(mydata$addressF, mydata$romanticF)
## Cramer's V (adj.) |       95% CI
## --------------------------------
## 0.00              | [0.00, 1.00]
## 
## - One-sided CIs: upper bound fixed at [1.00].
interpret_cramers_v(0.00)
## [1] "tiny"
## (Rules: funder2019)

3 Conclusion RQ2

Research question 2: Are high school students from rural areas more likely to be in a romantic relationship compared to students from urban areas?

  • Statistically, we cannot claim that there is any association between the address type of a high school student (rural or urban) and whether they are in a romantic relationship or not (p > 0.05).The effect size is tiny. This means that we cannot statistically say that high school students from rural areas are more likely to be in a romantic relationship compared to students from urban areas.