{r cars} library(haven) Data<-read_xpt("C:/Users/adolp/Desktop/Statistics 2/BRFSS/LLCP2019.XPT")
head(Data, n=10)
SubData<-names(Data)
newnames<-tolower(gsub(pattern = "_",replacement = "",x = SubData))
names(Data)<-newnames
library(car)
Data$Alc<-Recode(Data$acedrink, recodes ="7:9=NA; 1=1;2=0")
Data$Alc<-Recode(Data$Alc, recodes ="7:9=NA; 1='Yes';0='No'")
Data$Dep<-Recode(Data$acedeprs, recodes ="7:9=NA; 1=1;2=0")
Data$Dep<-Recode(Data$Dep, recodes ="7:9=NA; 1='Yes';0='No'")
Data$Mhlth<-Recode(Data$ment14d, recodes ="7:9=NA; 1=0;2=1;3=1")
Data$Mhlth<-Recode(Data$Mhlth, recodes ="7:9=NA; 1='Yes';0='No'")
IV 1: Did you live with anyone who was a problem drinker or alcoholic? (coded 1 = 1, 2 = 0)
IV 2: Did you live with anyone who was depressed, mentally ill, or suicidal? (coded 1 = 1, 2 = 0)
DV: Mental Health Status(recoded into binary outcome, 1 = 0, 2 & 3 = 1)
RQ: Do growing up in a household with a problem drinker or alcoholic or live with anyone who was depressed, mentally ill, or suicidal affect the current mental health status? Both variables are anticipated to be associated with Mental Health Status, with respondents who grew up with anyone who was depressed, mentally ill, or suicidal indicating more current mental health status.
library(tableone)
library(survey)
library(questionr)
des<-svydesign(ids=~1, strata=~ststr, weights=~llcpwt, data = Data)
t1<-CreateTableOne(vars = c("Alc", "Dep"), strata = "Mhlth", test = T, data = Data)
print(t1,format="p")
st1<-svyCreateTableOne(vars = c("Alc", "Dep"), strata = "Mhlth", test = T, data = des)
print(st1,format="p")
Results: The corrected model, analysis using survey design, was not substantially different than the descriptive results of not using a survey design. In regard to the research question, growing up in a household with a problem drinker or alcoholic accounted for more current mental health status compared to respondents who grew up with anyone who was depressed, mentally ill, or suicidal.