Sunteți pe pagina 1din 3

setwd("C:\\Users\\Administrator\\Desktop")

fm <- read.csv("latest2.csv",stringsAsFactors = F)

fm$control <- 0

fm$control[fm$systolic>=140] <- 1

fm$control[fm$diastolic>=90] <- 1

table(fm$control)

fm[,c("systolic","diastolic","control")]

fm$wt <- as.numeric(fm$Last.weight.in.2016.kg)

fm$bmi <- fm$wt/((fm$Height)/100)^2

fm$age <- as.numeric(fm$Age)

fm$sex <- NA

fm$sex[fm$Sex=="Male"]<- 1

fm$sex[fm$Sex=="Female"]<- 0

model1 <- glm(control~age+bmi+sex,data=fm,family=binomial)

summary(model1)

library(epicalc)

logistic.display(model1)

table(fm$age)

fm$age2<-NA

fm$age2[fm$age>=80]<- 1

fm$age2[fm$age<80]<-0

model2 <- glm(control~age2+bmi+sex,data=fm,family=binomial)

summary(model2)

fm$fu <- as.numeric(fm$Hypertension.follow.up.in.2016)

fm$fu2<- NA

fm$fu2[fm$fu==1]<-1

fm$fu2[fm$fu>1]<-0
model3 <- glm(control~age2+bmi+sex+fu2,data = fm,family = binomial)

summary(model3)

fm$ldl2 <- as.numeric(fm$LDL.C)

fm$sugar <- as.numeric(fm$Fasting.plasma.sugar)

model4 <- glm(control~age+bmi+sex+sugar+ldl2,data = fm,family = binomial)

summary(model4)

model5 <- glm(control~age2+bmi+sex+sugar+ldl2+fu2,data = fm,family = binomial)

summary(model5)

fm$ldl3<-as.numeric(fm$LDL.C)

fm$ldl3[fm$LDL.C>100]<-1

fm$ldl3[fm$LDL.C<=100]<-0

fm$sugar2<-NA

fm$sugar2[fm$sugar>=200]<-1

fm$sugar2[fm$sugar<200]<-0

fm$choles<-as.numeric(fm$X.Total.cholesterol.)

fm$choles2<-NA

fm$choles2[fm$choles>200]<-1

fm$choles2[fm$choles<=200]<-0

model6 <-glm(control~age2+bmi+sex+sugar2+ldl3+fu2+choles2,data = fm,family = binomial)

summary(model6)

fm$renal<-as.character(fm$Renal.complication)

fm$renal2[fm$renal=="No"]<-0

fm$renal2[fm$renal!="No"]<-1

model7 <-glm(control~age2+bmi+sex+sugar2+ldl3+fu2+choles2+renal2,data = fm,family = binomial)

summary(model7)

fm$comorbid<-as.character(fm$Co.morbidity)

fm$comorbid2[fm$comorbid==""]<-0
fm$comorbid2[fm$comorbid!="Other"&&fm$comorbid!=""]<-1

table(fm$comorbid2)

fm$hdl<-as.numeric(fm$HDL.C)

fm$hdl2[fm$hdl>=60]<-0

fm$hdl2[fm$hdl<60]<-1

model8 <-glm(control~age2+bmi+sex+sugar2+ldl3+fu2+choles2+renal2+hdl,data = fm,family =


binomial)

summary(model8)

fm$TG<-as.numeric(fm$Triglyceride.)

fm$TG2[fm$TG>=150]<-1

fm$TG2[fm$TG<150]<-0

model9 <-glm(control~age2+bmi+sex+sugar2+ldl3+fu2+choles2+renal2+hdl+TG2,data = fm,family =


binomial)

summary(model9)

fm$alb<-as.character(fm$albuminuria.)

fm$alb2[fm$alb=="<30"]<-0

fm$alb2[fm$alb!="<30"]<-1

model10 <-glm(control~age2+bmi+sex+sugar2+ldl3+fu2+choles2+renal2+hdl+TG2+alb2,data =
fm,family = binomial)

summary(model10)