0
간단한 회귀 회귀 함수를 만들었지 만 실행하면 변수 이름이 의도 한대로 나타나지 않습니다. 예를 들어 ...로그 회귀 함수의 레이블이있는 변수
#Simple Logistic Regression Function
logr <- function(y, x) {
model <- glm(y ~ x, data = gt2, family = "binomial")
print(summary(model))
exp(cbind(OR = coef(model), confint(model)))
}
나는 당신이 볼 수 있듯이
logr(gt2$EDGT, gt2$age)
Call:
glm(formula = y ~ x, family = "binomial", data = gt2)
Deviance Residuals:
Min 1Q Median 3Q Max
-0.8250 -0.8125 -0.7856 1.5902 1.7696
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.89974 0.16721 -5.381 7.41e-08 ***
**x** -0.01962 0.02223 -0.882 0.378
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 434.32 on 373 degrees of freedom
Residual deviance: 433.51 on 372 degrees of freedom
(3 observations deleted due to missingness)
AIC: 437.51
Number of Fisher Scoring iterations: 4
Waiting for profiling to be done...
OR 2.5 % 97.5 %
(Intercept) 0.4066735 0.2916710 0.5623434
**x** 0.9805752 0.9370358 1.0228424
가의 예측은 ...
결과이 나오 ... 콘솔이에 입력 할 수 있습니다 "X"로 레이블이 지정됩니다. 적절한 변수 이름으로 레이블을 붙이려면 어떻게해야합니까? 정말 고마워! 다음 변경된 기능 이제
logr <- function(y, x, data) {
model <- glm(reformulate(x, y), data=data, family = "binomial")
print(summary(model))
exp(cbind(OR = coef(model), confint(model)))
}
,
logr("setosa", "Sepal.Width", temp)
가 resu을 생산을
먼저 일부 데이터,
# reproducible data
temp <- iris
# y variable
temp$setosa <- as.integer(temp$Species == "setosa")
:
감사합니다. –