You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

24 lines
763 B

dose=c(1,1,2,2,3,3)
response=c(0,1,0,1,0,1)
count=c(7,3,5,5,2,8)
toxic = data.frame(dose, response, count)
toxic
out = glm(response~dose,
weights = count,
family = binomial,
data = toxic)
summary(out)
# Coefficients:
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -2.0496 1.0888 -1.882 0.0598 .
# dose 1.1051 0.5186 2.131 0.0331 *
# dose B = 1.1051 => Exp(1.1051) = 3.02
# dose 1 증가시 반응성 3.02배 증가한다고 볼 수 있음
# p-value = 0.03 < 0.05, 귀무가설 기각 => 약의 종류에 따라 반응이 다를 수 있음
plot(response~dose, data=toxic, type="n", main="Predicted Probability of Response")
curve(predict(out, data.frame(dose=x), type="resp"), add=TRUE)