Discrete Data - Coding

Author

Julissa Martinez

Intro

Below you’ll find all the code used to conduct the analysis.

Loading libraries and data

#installing necessary packages
#install.packages("knitr")  
#install.packages("kableExtra") 
#install.packages("stargazer")

#loading the libraries
library(knitr)
library(readr)
library(gt)
library(broom)
library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.2     ✔ dplyr   1.1.2
✔ tibble  3.2.1     ✔ stringr 1.5.0
✔ tidyr   1.3.0     ✔ forcats 1.0.0
✔ purrr   1.0.1     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
# reading in the data
mxmh_survey_results <- read_csv("mxmh_survey_results.csv")
Rows: 736 Columns: 33
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (26): Timestamp, Primary streaming service, While working, Instrumentali...
dbl  (7): Age, Hours per day, BPM, Anxiety, Depression, Insomnia, OCD

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# naming dataframe 
mxmh_df <- mxmh_survey_results

Data tidying

# renaming the columns 
df <- mxmh_df %>%
  mutate(anxiety = ifelse(Anxiety < 5, "0", "1")) %>%
  mutate(depression = ifelse(Depression < 5, "0", "1")) %>%
  mutate(insomnia = ifelse(Insomnia < 5, "0", "1")) %>%
  mutate(ocd = ifelse(OCD < 5, "0", "1")) %>%
  mutate(meffect = ifelse(`Music effects` == "No effect", 0, 1)) %>%
  rename(classical = `Frequency [Classical]` ) %>%
  rename(country = `Frequency [Country]`) %>%
  rename(edm = `Frequency [EDM]`) %>%
  rename(folk = `Frequency [Folk]`) %>%
  rename(gospel = `Frequency [Gospel]`) %>%
  rename(hiphop = `Frequency [Hip hop]`) %>% 
  rename(jazz = `Frequency [Jazz]` ) %>%
  rename(kpop = `Frequency [K pop]`) %>%
  rename(latin = `Frequency [Latin]`) %>%
  rename(lofi = `Frequency [Lofi]` ) %>%
  rename(metal = `Frequency [Metal]`) %>%
  rename(pop = `Frequency [Pop]`) %>%
  rename(randb = `Frequency [R&B]`) %>%
  rename(rap = `Frequency [Rap]` ) %>%
  rename(rock = `Frequency [Rock]`) %>%
  rename(videogame = `Frequency [Video game music]`) 
  
# creating a vector of columns
columns_to_rename <- c(
  "classical", "country", "edm", "folk", "gospel", "hiphop", "jazz", "kpop",
  "latin", "lofi", "metal", "pop", "randb", "rap", "rock", "videogame"
)

# recoding the variables in the genre columns
df <- df %>%
  mutate(across(all_of(columns_to_rename), ~as.numeric(factor(., levels = c(
    "Never", "Rarely", "Sometimes", "Very frequently"
  ))) - 1))

# removing old columns 
columns_to_remove <- c(
          "Anxiety",
          "Depression",
          "Insomnia",
          "OCD", 
          "Music effects"
            )

mxmh_fin_df <- df %>%
  select(-one_of(columns_to_remove))

# turning variables into numerical values 
mxmh_fin_df$anxiety <- as.numeric(mxmh_fin_df$anxiety)
mxmh_fin_df$depression <- as.numeric(mxmh_fin_df$depression)
mxmh_fin_df$ocd <- as.numeric(mxmh_fin_df$ocd)
mxmh_fin_df$classical <- as.numeric(mxmh_fin_df$classical)
mxmh_fin_df$insomnia <- as.numeric(mxmh_fin_df$insomnia)
mxmh_fin_df$edm <- as.numeric(mxmh_fin_df$edm)
mxmh_fin_df$folk <- as.numeric(mxmh_fin_df$folk)
mxmh_fin_df$gospel <- as.numeric(mxmh_fin_df$gospel)
mxmh_fin_df$hiphop <- as.numeric(mxmh_fin_df$hiphop)
mxmh_fin_df$jazz <- as.numeric(mxmh_fin_df$jazz)
mxmh_fin_df$kpop <- as.numeric(mxmh_fin_df$kpop)
mxmh_fin_df$latin <- as.numeric(mxmh_fin_df$latin)
mxmh_fin_df$lofi <- as.numeric(mxmh_fin_df$lofi)
mxmh_fin_df$metal <- as.numeric(mxmh_fin_df$metal)
mxmh_fin_df$pop <- as.numeric(mxmh_fin_df$pop)
mxmh_fin_df$randb <- as.numeric(mxmh_fin_df$randb)
mxmh_fin_df$rap <- as.numeric(mxmh_fin_df$rap)
mxmh_fin_df$rock <- as.numeric(mxmh_fin_df$rock)
mxmh_fin_df$videogame <- as.numeric(mxmh_fin_df$videogame)

Running sumary statistics

# creating a vector of genres to describe
describe_vari <- c(
  "classical", "country", "edm", "folk", "gospel", "hiphop", "jazz", "kpop",
  "latin", "lofi", "metal", "pop", "randb", "rap", "rock", "videogame"
)

# running the summary statistics for the vector
summary_results <- mxmh_fin_df %>%
  select(all_of(describe_vari)) %>%
  summary()

# printing
summary_results
   classical        country            edm             folk      
 Min.   :0.000   Min.   :0.0000   Min.   :0.000   Min.   :0.000  
 1st Qu.:1.000   1st Qu.:0.0000   1st Qu.:0.000   1st Qu.:0.000  
 Median :1.000   Median :1.0000   Median :1.000   Median :1.000  
 Mean   :1.336   Mean   :0.8179   Mean   :1.023   Mean   :1.012  
 3rd Qu.:2.000   3rd Qu.:1.0000   3rd Qu.:2.000   3rd Qu.:2.000  
 Max.   :3.000   Max.   :3.0000   Max.   :3.000   Max.   :3.000  
     gospel           hiphop           jazz            kpop       
 Min.   :0.0000   Min.   :0.000   Min.   :0.000   Min.   :0.0000  
 1st Qu.:0.0000   1st Qu.:1.000   1st Qu.:0.000   1st Qu.:0.0000  
 Median :0.0000   Median :1.000   Median :1.000   Median :0.0000  
 Mean   :0.3818   Mean   :1.385   Mean   :1.027   Mean   :0.7351  
 3rd Qu.:1.0000   3rd Qu.:2.000   3rd Qu.:2.000   3rd Qu.:1.0000  
 Max.   :3.0000   Max.   :3.000   Max.   :3.000   Max.   :3.0000  
     latin             lofi           metal           pop            randb     
 Min.   :0.0000   Min.   :0.000   Min.   :0.00   Min.   :0.000   Min.   :0.00  
 1st Qu.:0.0000   1st Qu.:0.000   1st Qu.:0.00   1st Qu.:1.000   1st Qu.:0.00  
 Median :0.0000   Median :1.000   Median :1.00   Median :2.000   Median :1.00  
 Mean   :0.6073   Mean   :1.068   Mean   :1.22   Mean   :2.031   Mean   :1.26  
 3rd Qu.:1.0000   3rd Qu.:2.000   3rd Qu.:2.00   3rd Qu.:3.000   3rd Qu.:2.00  
 Max.   :3.0000   Max.   :3.000   Max.   :3.00   Max.   :3.000   Max.   :3.00  
      rap             rock         videogame   
 Min.   :0.000   Min.   :0.000   Min.   :0.00  
 1st Qu.:0.000   1st Qu.:1.000   1st Qu.:0.00  
 Median :1.000   Median :2.000   Median :1.00  
 Mean   :1.336   Mean   :2.071   Mean   :1.25  
 3rd Qu.:2.000   3rd Qu.:3.000   3rd Qu.:2.00  
 Max.   :3.000   Max.   :3.000   Max.   :3.00  
# creating a vector of mental health disorders to describe
describe_outi <- c(
  "anxiety", "depression", "insomnia", "ocd", "meffect"
  )
# running the summary statistics for the vector
summary_res <- mxmh_fin_df %>%
  select(all_of(describe_outi)) %>%
  summary()
# printing
summary_res
    anxiety         depression        insomnia           ocd        
 Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
 1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000  
 Median :1.0000   Median :1.0000   Median :0.0000   Median :0.0000  
 Mean   :0.6834   Mean   :0.5435   Mean   :0.3927   Mean   :0.2514  
 3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  
 Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000  
                                                                    
    meffect      
 Min.   :0.0000  
 1st Qu.:1.0000  
 Median :1.0000  
 Mean   :0.7679  
 3rd Qu.:1.0000  
 Max.   :1.0000  
 NA's   :8       

Creating a table of summary statistics using visual editor in R.

Figure 1

Classical Country EDM Folk Gospel Hip Hop Jazz Kpop Latin Lo-fi Metal Pop R&B Rap Rock Video Game
Min. 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
1st Quartile 1.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 1.00 0.00
Median 1.00 1.00 1.00 1.00 0.00 1.00 1.00 0.00 0.00 1.00 1.00 2.00 1.00 1.00 2.00 1.00
Mean 1.336 0.8179 1.023 1.012 0.3818 1.385 1.027 0.7351 0.6073 1.068 1.22 2.031 1.26 1.336 2.071 1.25
3rd Quartile 2.00 1.00 2.00 2.00 1.00 2.00 2.00 1.00 1.00 2.00 2.00 3.00 2.00 2.00 3.00 2.00
Max. 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00

Figure 2

Anxiety Depression Insomsnia OCD Made Effect
Min. 0.00 0.00 0.00 0.00 0.00
1st Quartile 0.00 0.00 0.00 0.00 1.00
Median 1.00 1.00 0.00 0.00 1.00
Mean 0.6834 0.5435 0.3927 0.2514 0.7679
3rd Quartile 1.00 1.00 1.00 1.00 1.00
Max. 1.00 1.00 1.00 1.00 1.00

Building visuals

# reshape the data 
df_long <- tidyr::gather(mxmh_fin_df[, describe_vari], key = "Genre", value = "Value")

# create boxplots using ggplot2
ggplot(df_long, aes(x = Genre, y = Value, fill = Genre)) +
  geom_boxplot() +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Running the models

Depression

# running the model 
dep_model <- glm(depression ~ 
               classical + 
               country + 
                edm + 
               folk +
               gospel +
               hiphop +
               jazz +
               kpop +
               latin +    
               lofi +
               metal + 
               pop +
               randb +
               rap +
               rock +
               videogame, data = mxmh_fin_df, family = binomial)
# printing the summary
summary(dep_model)

Call:
glm(formula = depression ~ classical + country + edm + folk + 
    gospel + hiphop + jazz + kpop + latin + lofi + metal + pop + 
    randb + rap + rock + videogame, family = binomial, data = mxmh_fin_df)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.6956  -1.1799   0.8169   1.0627   1.8189  

Coefficients:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept) -0.972595   0.281154  -3.459 0.000542 ***
classical    0.052944   0.084828   0.624 0.532543    
country     -0.191774   0.091954  -2.086 0.037019 *  
edm          0.074184   0.079440   0.934 0.350385    
folk         0.073536   0.088270   0.833 0.404801    
gospel      -0.036187   0.118980  -0.304 0.761017    
hiphop       0.010303   0.126903   0.081 0.935293    
jazz        -0.068557   0.095145  -0.721 0.471182    
kpop        -0.059176   0.088021  -0.672 0.501395    
latin        0.086483   0.098997   0.874 0.382339    
lofi        -0.008926   0.087625  -0.102 0.918863    
metal        0.173830   0.083009   2.094 0.036250 *  
pop          0.082056   0.094463   0.869 0.385033    
randb        0.048293   0.098593   0.490 0.624259    
rap          0.174965   0.121606   1.439 0.150213    
rock         0.200595   0.094002   2.134 0.032846 *  
videogame    0.058042   0.080768   0.719 0.472373    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1014.74  on 735  degrees of freedom
Residual deviance:  972.88  on 719  degrees of freedom
AIC: 1006.9

Number of Fisher Scoring iterations: 4
# building the second model
up_dep_model <- glm(depression ~ 
               country + 
               metal + 
               rock, data = mxmh_fin_df, family = binomial)
# printing the summary
summary(up_dep_model)

Call:
glm(formula = depression ~ country + metal + rock, family = binomial, 
    data = mxmh_fin_df)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.5455  -1.1857   0.9063   1.0721   1.5555  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)   
(Intercept) -0.38742    0.17269  -2.243  0.02487 * 
country     -0.15608    0.08314  -1.877  0.06046 . 
metal        0.17384    0.07770   2.237  0.02527 * 
rock         0.23315    0.08566   2.722  0.00649 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1014.74  on 735  degrees of freedom
Residual deviance:  988.53  on 732  degrees of freedom
AIC: 996.53

Number of Fisher Scoring iterations: 4
# creating a table of output 
tab_dep_block <- up_dep_model %>% 
  tidy() %>% 
  gt()

tab_dep_block |>
   tab_header(
      title = "Logistic Regression Output Model for Depression",
    )
Logistic Regression Output Model for Depression
term estimate std.error statistic p.value
(Intercept) -0.3874202 0.17269106 -2.243429 0.024869136
country -0.1560817 0.08313546 -1.877438 0.060458106
metal 0.1738351 0.07769953 2.237273 0.025268476
rock 0.2331541 0.08565690 2.721954 0.006489716

Anxiety

# running the model 
anx_model <- glm(anxiety ~ 
               classical + 
               country + 
                edm + 
               folk +
               gospel +
               hiphop +
               jazz +
               kpop +
               latin +    
               lofi +
               metal + 
               pop +
               randb +
               rap +
               rock +
               videogame, data = mxmh_fin_df, family = binomial)

# printing the summary
summary(anx_model)

Call:
glm(formula = anxiety ~ classical + country + edm + folk + gospel + 
    hiphop + jazz + kpop + latin + lofi + metal + pop + randb + 
    rap + rock + videogame, family = binomial, data = mxmh_fin_df)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.1781  -1.3049   0.7474   0.8787   1.3846  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)  
(Intercept)  0.03030    0.28810   0.105   0.9162  
classical   -0.09134    0.08912  -1.025   0.3054  
country     -0.08521    0.09556  -0.892   0.3725  
edm         -0.04106    0.08473  -0.485   0.6280  
folk         0.15873    0.09584   1.656   0.0977 .
gospel      -0.10561    0.12308  -0.858   0.3908  
hiphop      -0.05957    0.13567  -0.439   0.6606  
jazz        -0.07999    0.10040  -0.797   0.4256  
kpop         0.11533    0.09495   1.215   0.2245  
latin       -0.11592    0.10372  -1.118   0.2637  
lofi         0.08650    0.09455   0.915   0.3603  
metal        0.10283    0.08889   1.157   0.2473  
pop          0.14550    0.09912   1.468   0.1421  
randb       -0.02998    0.10500  -0.286   0.7753  
rap          0.15987    0.13051   1.225   0.2206  
rock         0.08081    0.09887   0.817   0.4137  
videogame    0.14568    0.08680   1.678   0.0933 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 918.91  on 735  degrees of freedom
Residual deviance: 888.06  on 719  degrees of freedom
AIC: 922.06

Number of Fisher Scoring iterations: 4
# building the second model
up_anx_model <- glm(anxiety ~ 
                      folk +
                      videogame,  data = mxmh_fin_df, family = binomial)
# printing the summary
summary(up_anx_model)

Call:
glm(formula = anxiety ~ folk + videogame, family = binomial, 
    data = mxmh_fin_df)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.7935  -1.4099   0.7959   0.9129   1.0116  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)   
(Intercept)  0.40345    0.13868   2.909  0.00362 **
folk         0.12823    0.08085   1.586  0.11275   
videogame    0.19894    0.07600   2.618  0.00885 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 918.91  on 735  degrees of freedom
Residual deviance: 908.68  on 733  degrees of freedom
AIC: 914.68

Number of Fisher Scoring iterations: 4
# creating a table of output 
table_anx_block <- up_anx_model %>% 
  tidy() %>% 
  gt()

table_anx_block |>
   tab_header(
      title = "Logistic Regression Output Model for Anxiety",
    )
Logistic Regression Output Model for Anxiety
term estimate std.error statistic p.value
(Intercept) 0.4034483 0.13867760 2.909254 0.003622927
folk 0.1282251 0.08085105 1.585942 0.112752487
videogame 0.1989361 0.07599823 2.617641 0.008853992

Insomnia

# running the model 
ins_model <- glm(insomnia ~ 
               classical + 
               country + 
                edm + 
               folk +
               gospel +
               hiphop +
               jazz +
               kpop +
               latin +    
               lofi +
               metal + 
               pop +
               randb +
               rap +
               rock +
               videogame, data = mxmh_fin_df, family = binomial)

# printing the summary
summary(ins_model)

Call:
glm(formula = insomnia ~ classical + country + edm + folk + gospel + 
    hiphop + jazz + kpop + latin + lofi + metal + pop + randb + 
    rap + rock + videogame, family = binomial, data = mxmh_fin_df)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.4791  -1.0002  -0.8075   1.2334   1.8128  

Coefficients:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept) -1.376413   0.291068  -4.729 2.26e-06 ***
classical    0.139214   0.086662   1.606 0.108185    
country     -0.105530   0.094731  -1.114 0.265281    
edm          0.137614   0.080090   1.718 0.085752 .  
folk        -0.021922   0.089663  -0.244 0.806846    
gospel      -0.016917   0.122454  -0.138 0.890125    
hiphop       0.030940   0.129460   0.239 0.811109    
jazz        -0.054866   0.096639  -0.568 0.570213    
kpop        -0.013986   0.089561  -0.156 0.875904    
latin        0.154256   0.099167   1.556 0.119822    
lofi         0.073336   0.088982   0.824 0.409844    
metal        0.279731   0.084508   3.310 0.000933 ***
pop         -0.036255   0.097127  -0.373 0.708944    
randb        0.062117   0.100628   0.617 0.537041    
rap          0.004953   0.123802   0.040 0.968090    
rock         0.055296   0.097369   0.568 0.570101    
videogame    0.072549   0.081838   0.886 0.375349    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 986.13  on 735  degrees of freedom
Residual deviance: 949.35  on 719  degrees of freedom
AIC: 983.35

Number of Fisher Scoring iterations: 4
# building the second model
up_ins_model <- glm(insomnia ~ 
                      metal, data = mxmh_fin_df, family = binomial)

# printing the summary
summary(up_ins_model)

Call:
glm(formula = insomnia ~ metal, family = binomial, data = mxmh_fin_df)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.2074  -0.9696  -0.8611   1.2723   1.5310  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept) -0.80120    0.11565  -6.928 4.28e-12 ***
metal        0.29049    0.06727   4.318 1.57e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 986.13  on 735  degrees of freedom
Residual deviance: 967.20  on 734  degrees of freedom
AIC: 971.2

Number of Fisher Scoring iterations: 4
# creating a table of output 
tab_ins_block <- up_ins_model %>% 
  tidy() %>% 
  gt()

tab_ins_block |>
   tab_header(
      title = "Logistic Regression Output Model for Insomnia",
    )
Logistic Regression Output Model for Insomnia
term estimate std.error statistic p.value
(Intercept) -0.8011968 0.11565393 -6.927537 4.282314e-12
metal 0.2904862 0.06726736 4.318384 1.571761e-05

OCD

# running the model 
ocd_model <- glm(ocd ~ 
               classical + 
               country + 
                edm + 
               folk +
               gospel +
               hiphop +
               jazz +
               kpop +
               latin +    
               lofi +
               metal + 
               pop +
               randb +
               rap +
               rock +
               videogame, data = mxmh_fin_df, family = binomial)

# printing the summary
summary(ocd_model)

Call:
glm(formula = ocd ~ classical + country + edm + folk + gospel + 
    hiphop + jazz + kpop + latin + lofi + metal + pop + randb + 
    rap + rock + videogame, family = binomial, data = mxmh_fin_df)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.1200  -0.7932  -0.6825   1.2099   2.0614  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept) -1.6293793  0.3197028  -5.097 3.46e-07 ***
classical    0.0509547  0.0971696   0.524   0.6000    
country      0.1258562  0.1022820   1.230   0.2185    
edm          0.2051822  0.0878916   2.334   0.0196 *  
folk         0.0921871  0.0987825   0.933   0.3507    
gospel      -0.0228280  0.1347288  -0.169   0.8655    
hiphop       0.0288641  0.1430378   0.202   0.8401    
jazz        -0.1219191  0.1087569  -1.121   0.2623    
kpop         0.1135355  0.0954701   1.189   0.2344    
latin       -0.0861682  0.1109688  -0.777   0.4374    
lofi         0.0840196  0.0977568   0.859   0.3901    
metal        0.0358254  0.0951819   0.376   0.7066    
pop          0.0357090  0.1089260   0.328   0.7430    
randb        0.0665520  0.1103705   0.603   0.5465    
rap         -0.0165953  0.1361124  -0.122   0.9030    
rock        -0.0842560  0.1072204  -0.786   0.4320    
videogame    0.0006406  0.0922376   0.007   0.9945    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 829.95  on 735  degrees of freedom
Residual deviance: 811.72  on 719  degrees of freedom
AIC: 845.72

Number of Fisher Scoring iterations: 4
# building the second model
up_ocd_model <- glm(ocd ~ 
                      edm, data = mxmh_fin_df, family = binomial)

# printing the summary
summary(up_ocd_model)

Call:
glm(formula = ocd ~ edm, family = binomial, data = mxmh_fin_df)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-0.9244  -0.7539  -0.6776   1.4535   1.7799  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept) -1.35446    0.12530  -10.81  < 2e-16 ***
edm          0.24182    0.07954    3.04  0.00237 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 829.95  on 735  degrees of freedom
Residual deviance: 820.77  on 734  degrees of freedom
AIC: 824.77

Number of Fisher Scoring iterations: 4
# creating a table of output 
tab_ocd_block <- up_ocd_model %>% 
  tidy() %>% 
  gt()

tab_ocd_block |>
   tab_header(
      title = "Logistic Regression Output Model for OCD",
    )
Logistic Regression Output Model for OCD
term estimate std.error statistic p.value
(Intercept) -1.3544627 0.1252986 -10.809882 3.09067e-27
edm 0.2418158 0.0795442 3.040018 2.36564e-03