setwd("D:/charls/")
library(lme4)
library(lmerTest)
library(haven)
library(tidyverse)
library(lm.beta)
library(tableone)
library(charlsMAX)
library(httr)
base <- read.csv("base.csv")

base_clhls <- base %>% filter(table==1)
base_charls <- base %>% filter(table==0)

clhls_SO2 <- glm(
  blood ~ SO2_Q + age + sex + marriage + house + activity + smoke + drink + health + sleep + depression + BMI, 
  family = binomial,
  data = base_clhls
)
summary(clhls_SO2)
exp(clhls_SO2$coefficients)
exp(confint(clhls_SO2))
exp(coef(clhls_SO2))

charls_SO2 <- glm(
  blood ~ SO2_Q + age + sex + marriage + house + activity + smoke + drink + health + sleep + depression + BMI, 
  family = binomial,
  data = base_charls
)
summary(charls_SO2)
exp(charls_SO2$coefficients)
exp(confint(charls_SO2))
exp(coef(charls_SO2))

clhls_NO2 <- glm(
  blood ~ NO2_Q + age + sex + marriage + house + activity + smoke + drink + health + sleep + depression + BMI, 
  family = binomial,
  data = base_clhls
)
summary(clhls_NO2)
exp(clhls_NO2$coefficients)
exp(confint(clhls_NO2))
exp(coef(clhls_NO2))

charls_NO2 <- glm(
  blood ~ NO2_Q + age + sex + marriage + house + activity + smoke + drink + health + sleep + depression + BMI, 
  family = binomial,
  data = base_charls
)
summary(charls_NO2)
exp(charls_NO2$coefficients)
exp(confint(charls_NO2))
exp(coef(charls_NO2))

clhls_PM2.5 <- glm(
  blood ~ PM2.5_Q + age + sex + marriage + house + activity + smoke + drink + health + sleep + depression + BMI, 
  family = binomial,
  data = base_clhls
)
summary(clhls_PM2.5)
exp(clhls_PM2.5$coefficients)
exp(confint(clhls_PM2.5))
exp(coef(clhls_PM2.5))

charls_PM2.5 <- glm(
  blood ~ PM2.5_Q + age + sex + marriage + house + activity + smoke + drink + health + sleep + depression + BMI, 
  family = binomial,
  data = base_charls
)
summary(charls_PM2.5)
exp(charls_PM2.5$coefficients)
exp(confint(charls_PM2.5))
exp(coef(charls_PM2.5))

clhls_NDVI <- glm(
  blood ~ NDVI_Q + age + sex + marriage + house + activity + smoke + drink + health + sleep + depression + BMI, 
  family = binomial,
  data = base_clhls
)
summary(clhls_NDVI)
exp(clhls_NDVI$coefficients)
exp(confint(clhls_NDVI))
exp(coef(clhls_NDVI))

charls_NDVI <- glm(
  blood ~ NDVI_Q + age + sex + marriage + house + activity + smoke + drink + health + sleep + depression + BMI, 
  family = binomial,
  data = base_charls
)
summary(charls_NDVI)
exp(charls_NDVI$coefficients)
exp(confint(charls_NDVI))
exp(coef(charls_NDVI))