library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
load("NSDUH_2023.Rdata")
model1<-lm(CABINGFLG~IRMARIT,data=data)
summary(model1)
##
## Call:
## lm(formula = CABINGFLG ~ IRMARIT, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.602 -0.597 -0.585 -0.044 84.956
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.6079489 0.0236906 25.662 < 2e-16 ***
## IRMARIT -0.0056991 0.0007594 -7.505 6.22e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.188 on 56703 degrees of freedom
## Multiple R-squared: 0.0009924, Adjusted R-squared: 0.0009748
## F-statistic: 56.33 on 1 and 56703 DF, p-value: 6.225e-14
The model explains that there is significance between marital status and binge alcohol use. Marital status shows a significant relationship to binge alcohol use. I did not have another independent vairable to test.
model1<-lm(CABINGFLG~IRMARIT+SEXIDENT22+CATAGE,data=data)
summary(model1)
##
## Call:
## lm(formula = CABINGFLG ~ IRMARIT + SEXIDENT22 + CATAGE, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.807 -0.647 -0.525 -0.042 84.958
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.4238792 0.0692232 6.123 9.22e-10 ***
## IRMARIT -0.0044706 0.0008849 -5.052 4.38e-07 ***
## SEXIDENT22 0.0015625 0.0012176 1.283 0.19938
## CATAGE 0.0586616 0.0215631 2.720 0.00652 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.188 on 56701 degrees of freedom
## Multiple R-squared: 0.001153, Adjusted R-squared: 0.0011
## F-statistic: 21.81 on 3 and 56701 DF, p-value: 4.144e-14
It shows that marital status and age have a significant relationship to binge alcohol use but not with sexual identity.
plot(model1, which=1)
The model meets linearity by visual inspection.