[问题] GLM回归请教

楼主: jasonfghx (工人)   2018-04-06 10:35:29
[问题类型]:
程式咨询(我想用R 做某件事情,但是我不知道要怎么用R 写出来)
[软件熟悉度]:
入门(写过其他程式,只是对语法不熟悉)
[问题叙述]:
[1] "Age" "Blood Pressure" "Specific
Gravity"
[4] "Albumin" "Sugar" "Red Blood
Cellsabnormal"
[7] "Red Blood Cellsnormal" "Pus Cellabnormal" "Pus
Cellnormal"
[10] "Pus Cell clumpsnotpresent" "Pus Cell clumpspresent"
"Bacterianotpresent"
[13] "Bacteriapresent" "Blood Glucose Random" "Blood Urea"
[16] "Serum Creatinine" "Sodium" "Potassium"
[19] "Hemoglobin" "Packed Cell Volume" "White Blood
Cell Count"
[22] "Red Blood Cell Count" "Hypertensionno"
"Hypertensionyes"
[25] "Diabetes Mellitus yes" "Diabetes Mellitusno" "Diabetes
Mellitusyes"
[28] "Coronary Artery Diseaseno" "Coronary Artery Diseaseyes" "Appetitegood"
[31] "Appetitepoor" "Pedal Edemano" "Pedal
Edemayes"
[34] "Anemiano" "Anemiayes" "Classckd"
[37] "Classnotckd"
这是我全部的变量,我想针对"Classckd" 对其他变量做回归
想请教是否有什么语法可以比较简洁的去做回归
例如data.glm1 <- glm(formula=Classckd~`Pus Cellabnormal`+Age+`Red Blood
Cellsnormal`,data=data.training,family=binomial(link = "logit"))
我想继续加其他变量进去,但是如果打他的名字感觉会程式码很长
想说有没有办法就只打行的数字就好, 只是我试了几个都编译不过
a<-names(data.training)
像我试着把所有名目存到a ,formula=Classckd~ 在这后面加工好像都是无法判读
求是否有比较好的方法 除了全部贴上外
谢谢
[程式范例]:
[关键字]:
Glm
作者: F0011010101 (法客)   2018-04-06 10:55:00
formula=Classckd~.
作者: clansoda (小笨)   2018-04-06 10:55:00
我想你是要这个idx <- c(1, 3, 5) # 假设你只要第1、3跟5个columns
作者: che122333 (che122333)   2018-04-06 18:28:00
推一楼写法,意思是除了y以外的变量都会自动塞进自变量去跑回归

Links booklink

Contact Us: admin [ a t ] ucptt.com