Apnea Analysis

Author

Batoul Kalot

Apnea and hypopnea are sleep conditions that affect breathing. Apnea is when breathing completely stops for a short time, while hypopnea is when breathing becomes shallow or reduced.

These conditions can disturb sleep and may affect a person’s health over time.

In this study, we analyze data to understand the relationship between age and the number of apnea events. The aim is to see if age has an effect on how often these events occur.

Loading data

Patient Age Gender BMI Recording hours Apnea-Hypopnea Index (AHI) # apnea events # hypopnea events avg duration (hypo)apnea events
1 48 Male 30.8 7.0 39.7 142 136 22
2 77 Male 35.3 11.9 10.2 29 93 20
3 61 Male 33.2 7.1 63.1 242 208 25
4 66 Male 26.9 9.0 10.4 52 42 34
5 33 Male 35.9 9.1 35.4 42 280 23
6 68 Male 45.0 4.1 58.4 87 150 20

Manipultaing column data names

names(Apnea_data) <- make.names(names(Apnea_data))
view(Apnea_data)

So now in this data, we have eight variables to be studied and six to be defined:

BMIBody Mass Index, a medical screening tool that uses a person’s height and weight to estimate total body fat and categorize them into weight categories.

Recording hours refers to the total duration the device was actively delivering therapy and in use while you were sleeping.

AHI is the average number of times your breathing stops or becomes significantly sallow per hour of sleep.

Levels of AHI Security:

Normal:Less than 5 events per hour.

Mild:5 to 14 events per hour.

Moderate:15 to 29 events per hour.

Severe:30 or more events per hour.

apnea events represent instances where breathing stops completely or becomes shallow for 10 seconds or more, causing a decrease in oxygen levels and temporary arousal from sleep.

hypopnea events represents partial airway blockages lasting at least 10 seconds, where breathing becomes abnormally shallow and is accompanied by a significant drop in blood oxygen levels(typically 3% or 4% or more) or a brain arousal.

Avg duration(hypo) Average duration of Hypopneas(measured in seconds).

Visualizing correlations between variables

Apnea_data %>% ggplot(aes(x=Age,y=X..hypopnea..events))+
  geom_point(col="green")+
  facet_wrap(~Gender)

We observed spread of hypopnea events after age 68 for females and wide spread after 60 for males with a little spread between 40 and 50.

Studying coreelation between BMI & Apnea-hypopnea Index

Apnea_data %>% ggplot(aes(x=BMI,y=Apnea.Hypopnea..Index..AHI.))+
  geom_point(col="green")+
  geom_smooth(method="lm",
                se=FALSE,
                color="lightblue")
`geom_smooth()` using formula = 'y ~ x'

We noticed based on this graph somewhat a linear relationship, but with tiny outliers(seeing we can keep them in our data-not very far).

Studying relation between recording hours of the CPAP therapy and apnea events.

Apnea_data %>% ggplot(aes(x=Recording..hours,y=X..apnea..events))+
  geom_point(col="blue")

So after checking this point graph, we conclude apnea events can’t be recorded by less than seven hours sleep.

Apnea_data %>% ggplot(aes(x=Age,y=avg.duration....hypo.apnea.events))+
  geom_point(col="red")+
  facet_wrap(~Gender)

As shown in this facet point graph, hypo.apnea average duration is higher in males recordings especially after age 60.

Now we will create a new variable to classify AHI into severity levels.

Apnea_data$severity <- cut(Apnea_data$Apnea.Hypopnea..Index..AHI.,
                           breaks=c(-Inf,5,15,30,Inf),
                           labels=c("Normal","Mild","Moderate","Severe"),
                           right=FALSE)
table(Apnea_data$severity)

  Normal     Mild Moderate   Severe 
       7        7        5       11 

Count of severity levels

ggplot(Apnea_data,aes(x=severity))+
  geom_bar(fill="skyblue")

Boxplot Severity vs Age

ggplot(Apnea_data,aes(x=severity,y=Age))+
  geom_boxplot(fill="lightgreen")

So we have more Moderate levels with older people,mild and then severe.

ggplot(Apnea_data,aes(x=Age,y=Apnea.Hypopnea..Index..AHI.,
                      color=severity))+
  geom_point()

Here, points dispersion are colored by severity levels-much more clear visualization

Summary Statistics

Summary <-aggregate(Apnea.Hypopnea..Index..AHI. ~ severity,data=Apnea_data,mean)
gt(Summary) %>% opt_stylize(style=4,color="gray")
severity Apnea.Hypopnea..Index..AHI.
Normal 2.914286
Mild 9.885714
Moderate 26.600000
Severe 49.409091

“Patients with higher AHI values fall into moderate and severe categories, which may indicate increased health risks. The relationship between age and severity suggests that apnea events may become more frequent with age.”

Building Model

Model <- lm(X..apnea..events ~ Age+Gender+BMI+Recording..hours+
              Apnea.Hypopnea..Index..AHI.+X..hypopnea..events+
              avg.duration....hypo.apnea.events,data=Apnea_data)
summary(Model)

Call:
lm(formula = X..apnea..events ~ Age + Gender + BMI + Recording..hours + 
    Apnea.Hypopnea..Index..AHI. + X..hypopnea..events + avg.duration....hypo.apnea.events, 
    data = Apnea_data)

Residuals:
    Min      1Q  Median      3Q     Max 
-51.616 -15.105   5.606  15.372  50.557 

Coefficients:
                                   Estimate Std. Error t value Pr(>|t|)    
(Intercept)                       -144.0132    67.1047  -2.146   0.0432 *  
Age                                 -0.6290     0.5687  -1.106   0.2806    
GenderMale                          11.4380    14.8018   0.773   0.4479    
BMI                                 -4.6665     1.4879  -3.136   0.0048 ** 
Recording..hours                    30.4777     5.0362   6.052 4.32e-06 ***
Apnea.Hypopnea..Index..AHI.          8.1975     0.4253  19.274 2.88e-15 ***
X..hypopnea..events                 -0.7876     0.0985  -7.996 5.95e-08 ***
avg.duration....hypo.apnea.events    1.3712     1.0577   1.296   0.2083    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 27.07 on 22 degrees of freedom
Multiple R-squared:  0.9608,    Adjusted R-squared:  0.9483 
F-statistic: 77.05 on 7 and 22 DF,  p-value: 5.319e-14

According to this modeling summary, we will eliminate three variables predicted as effectors in the apnea events as they don’t give significant p values.