logistic_regression:examples_r
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| logistic_regression:examples_r [2024/12/10 14:34] – hkimscil | logistic_regression:examples_r [2024/12/12 10:27] (current) – hkimscil | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== R code ====== | ||
| + | |||
| < | < | ||
| # log cacluation | # log cacluation | ||
| Line 266: | Line 268: | ||
| # P-values | # P-values | ||
| car:: | car:: | ||
| + | </ | ||
| + | ====== output ====== | ||
| + | |||
| + | < | ||
| + | > # log cacluation | ||
| + | > # j = 1 | ||
| + | > j <- log10(10) | ||
| + | > j | ||
| + | [1] 1 | ||
| + | > # 10^j = (10) | ||
| + | > 10^j | ||
| + | [1] 10 | ||
| + | > k <- log2(10) | ||
| + | > k | ||
| + | [1] 3.321928 | ||
| + | > 2^k | ||
| + | [1] 10 | ||
| + | > | ||
| + | > odds       <- function(p)  | ||
| + | > odds.ratio <- function(p1, | ||
| + | > logit      <- function(p)  | ||
| + | > ilogit  | ||
| + | > # exp() is the exponential function | ||
| + | > | ||
| + | > ########## | ||
| + | > # see youtube  | ||
| + | > # https:// | ||
| + | > n.mut <- 23+117 | ||
| + | > n.norm <- 6+210 | ||
| + | > p.cancer.mut <- 23/(23+117) | ||
| + | > p.cancer.norm <- 6/(6+210) | ||
| + | > | ||
| + | > set.seed(1011) | ||
| + | > c <- runif(n.mut, | ||
| + | > # 0 = not cancer, 1 = cancer among mutant gene | ||
| + | > mutant <- ifelse(c> | ||
| + | > | ||
| + | > c <- runif(n.norm, | ||
| + | > # 0 = not cancer, 1 = cancer among normal gene | ||
| + | > normal <- ifelse(c> | ||
| + | > | ||
| + | > # 0 = mutant; 1 = normal | ||
| + | > gene <- c(rep(0, length(mutant)), | ||
| + | > # 0 = not cancer; 1 = cancer | ||
| + | > cancer <- c(mutant, normal) | ||
| + | > | ||
| + | > df <- as.data.frame(cbind(gene, | ||
| + | > head(df) | ||
| + | gene cancer | ||
| + | 1 0 0 | ||
| + | 2 0 1 | ||
| + | 3 0 0 | ||
| + | 4 0 0 | ||
| + | 5 0 0 | ||
| + | 6 0 0 | ||
| + | > df$gene <- factor(df$gene, | ||
| + | > df$cancer <- factor(df$cancer, | ||
| + | > head(df) | ||
| + |     gene    | ||
| + | 1 mutant nocancer | ||
| + | 2 mutant  | ||
| + | 3 mutant nocancer | ||
| + | 4 mutant nocancer | ||
| + | 5 mutant nocancer | ||
| + | 6 mutant nocancer | ||
| + | > tab <- table(df) | ||
| + | > tab | ||
| + | cancer | ||
| + | gene      | ||
| + |   mutant  | ||
| + | norm 210 6 | ||
| + | > tab[1,2] | ||
| + | [1] 19 | ||
| + | > tab[1,1] | ||
| + | [1] 121 | ||
| + | > | ||
| + | > # p.c.m = p.cancer.mut the above | ||
| + | > p.cancer.mutant <- tab[1, | ||
| + | > p.nocancer.mutant <- tab[1, | ||
| + | > p.cancer.mutant | ||
| + | [1] 0.1357143 | ||
| + | > 1-p.cancer.mutant | ||
| + | [1] 0.8642857 | ||
| + | > p.nocancer.mutant | ||
| + | [1] 0.8642857 | ||
| + | > | ||
| + | > p.cancer.norm <-  tab[2, | ||
| + | > p.nocancer.norm <- 1-p.cancer.norm | ||
| + | > p.cancer.norm | ||
| + | [1] 0.02777778 | ||
| + | > p.nocancer.norm | ||
| + | [1] 0.9722222 | ||
| + | > | ||
| + | > odds(p.cancer.mutant) | ||
| + | [1] 0.1570248 | ||
| + | > odds(p.cancer.norm) | ||
| + | [1] 0.02857143 | ||
| + | > odds.ratio(p.cancer.mutant, | ||
| + | [1] 5.495868 | ||
| + | > | ||
| + | > | ||
| + | > ########################################### | ||
| + | > | ||
| + | > load(" | ||
| + | > | ||
| + | > # Shorter name | ||
| + | > nsduh <- nsduh_adult_sub | ||
| + | > tab <- table(nsduh$demog_sex, | ||
| + | > tab | ||
| + |          | ||
| + | No Yes | ||
| + | Male 206 260 | ||
| + | Female 285 249 | ||
| + | > table(nsduh$demog_sex) | ||
| + | |||
| + |   Male Female  | ||
| + |     | ||
| + | > table(nsduh$mj_lifetime) | ||
| + | |||
| + | No Yes | ||
| + | 491 509 | ||
| + | > | ||
| + | > # create functions for odd calculation | ||
| + | > odds       <- function(p)  | ||
| + | > odds.ratio <- function(p1, | ||
| + | > # log odds를 구하는 function | ||
| + | > logit      <- function(p)  | ||
| + | > # probability를 구하는 function  | ||
| + | > # log(p/ | ||
| + | > # p/(1-p) = e^x | ||
| + | > # p = e^x * (1-p) | ||
| + | > # p = e^x - e^x*p | ||
| + | > # p + p*e^x = e^x | ||
| + | > # p*(1+e^x) = e^x | ||
| + | > # p = e^x / (1 +e^x) | ||
| + | > # 따라서 아래는 p를 구하는 평션 | ||
| + | > ilogit  | ||
| + | > # exp() is the exponential function | ||
| + | > | ||
| + | > | ||
| + | > # 위의 펑션으로 구한 값 | ||
| + | > PM.yes <- tab[1, | ||
| + | > PF.yes <- tab[2, | ||
| + | > OM <- odds(PM.yes) | ||
| + | > OF <- odds(PF.yes) | ||
| + | > OR.mvsf <- odds.ratio(PM.yes, | ||
| + | > # outputs | ||
| + | > round(c(PM.yes, | ||
| + | [1] 0.55794 0.46629 1.26214 0.87368 1.44461 | ||
| + | > | ||
| + | > | ||
| + | > library(dplyr) | ||
| + | |||
| + | 다음의 패키지를 부착합니다: | ||
| + | |||
| + | The following objects are masked from ‘package: | ||
| + | |||
| + | filter, lag | ||
| + | |||
| + | The following objects are masked from ‘package: | ||
| + | |||
| + | intersect, setdiff, setequal, union | ||
| + | |||
| + | > # female을 reference로 바꾸는 작업 relevel | ||
| + | > nsduh <- nsduh %> | ||
| + | +    | ||
| + | > | ||
| + | > # generalized linear modeling (glm) for logistic regression | ||
| + | > # note: IV가 종류측정 변인 | ||
| + | > fit.ex6.2 <- glm(mj_lifetime ~ demog_sex, | ||
| + | + family = binomial, data = nsduh) | ||
| + | > summary(fit.ex6.2) | ||
| + | |||
| + | Call: | ||
| + | glm(formula = mj_lifetime ~ demog_sex, family = binomial, data = nsduh) | ||
| + | |||
| + | Coefficients: | ||
| + |               Estimate Std. Error z value Pr(> | ||
| + | (Intercept)  | ||
| + | demog_sexMale  | ||
| + | --- | ||
| + | Signif. codes:  | ||
| + | |||
| + | (Dispersion parameter for binomial family taken to be 1) | ||
| + | |||
| + |     Null deviance: 1386.0  | ||
| + | Residual deviance: 1377.6  | ||
| + | AIC: 1381.6 | ||
| + | |||
| + | Number of Fisher Scoring iterations: 3 | ||
| + | |||
| + | > | ||
| + | > # 아래는 다른 펑션으로 아웃풋이 다름름 | ||
| + | > # library(lessR) | ||
| + | > # fit.ex6.2b <- Logit(mj_lifetime ~ demog_sex, data=nsduh) | ||
| + | > | ||
| + | > # 절편 해석  | ||
| + | > # log(p) = a + b * demog_sex 에서x | ||
| + | > # demog_sexFemale 일 때, b = 0 이므로 | ||
| + | > # log(p) = a = -0.13504 | ||
| + | > a = -0.13504 | ||
| + | > p.femal.yes <- exp(a)/(1 + exp(a)) # 위의 절편에 대한 p 값 계산  | ||
| + | > p.femal.yes  | ||
| + | [1] 0.4662912 | ||
| + | > PF.yes | ||
| + | [1] 0.4662921 | ||
| + | > | ||
| + | > # x = 1일 때, log(x) = a + b | ||
| + | > summary(fit.ex6.2)$coefficient # coefficient 값들 출력 | ||
| + | Estimate Std. Error z value Pr(>|z|) | ||
| + | (Intercept)  | ||
| + | demog_sexMale  | ||
| + | > a <- summary(fit.ex6.2)$coefficient[1, | ||
| + | > b <- summary(fit.ex6.2)$coefficient[2, | ||
| + | > a | ||
| + | [1] -0.1350363 | ||
| + | > b | ||
| + | [1] 0.3678417 | ||
| + | > adash <- a + b | ||
| + | > adash | ||
| + | [1] 0.2328055 | ||
| + | > | ||
| + | > # or | ||
| + | > exp(adash) / (1 + exp(adash)) | ||
| + | [1] 0.5579399 | ||
| + | > ilogit(adash)  | ||
| + | [1] 0.5579399 | ||
| + | > # 위 값은 PM.yes 값과 같다 | ||
| + | > PM.yes | ||
| + | [1] 0.5579399 | ||
| + | > | ||
| + | > # 한편 위에서의 b, coefficient 값은 b 인데 | ||
| + | > # see http:// | ||
| + | > # 아래는 odds ratio 의 값이 된다. (위의 위키문서 읽을 것) | ||
| + | > # 즉, x가 한 unit 증가할 때의 odds값의 ratio를 말한다. | ||
| + | > exp(b) | ||
| + | [1] 1.444613 | ||
| + | > # [1] 1.444613 | ||
| + | > # X변인의 한 unit이 증가함은 female에서 male이 되는 것 | ||
| + | > # 그 때의 odds ratio는 exp(b), 1.444613  | ||
| + | > # female에 비해서 male의 me가 약 1.45배 정도 된다는 것것 | ||
| + | > | ||
| + | > | ||
| + | > # 위의 b값에 대한 CI을 구하기 위해서 confint 펑션을 사용한다 | ||
| + | > confint(fit.ex6.2) | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | 2.5 % 97.5 % | ||
| + | (Intercept)  | ||
| + | demog_sexMale  | ||
| + | > # b값에 대한 것만 알고 싶으므로  | ||
| + | > confint(fit.ex6.2)[2, | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | 2.5 % 97.5 % | ||
| + | demog_sexMale 0.1185985 0.6180806 | ||
| + | > # 그리고 이 값들의 실제 odds ratio값을 보려면  | ||
| + | > exp(confint(fit.ex6.2)[2, | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | 2.5 % 97.5 % | ||
| + | 1.125918 1.855363  | ||
| + | > # 위는 female에서 male이 될면, 즉, 0 -> 1 이 될때의  | ||
| + | > # 마리화나 경험의 (me) odds ratio는 CI 범위는  | ||
| + | > # 1.126 ~ 1.855 즉, 13% 에서 18% 정도 증가한다는 뜻이다다 | ||
| + | > | ||
| + | > # install.packages(" | ||
| + | > library(car) | ||
| + | 필요한 패키지를 로딩중입니다: | ||
| + | |||
| + | 다음의 패키지를 부착합니다: | ||
| + | |||
| + | The following object is masked _by_ ‘.GlobalEnv’: | ||
| + | |||
| + | logit | ||
| + | |||
| + | The following object is masked from ‘package: | ||
| + | |||
| + | recode | ||
| + | |||
| + | > # coefficient probability test | ||
| + | > car:: | ||
| + | Analysis of Deviance Table (Type III tests) | ||
| + | |||
| + | Response: mj_lifetime | ||
| + |             Df  Chisq Pr(> | ||
| + | (Intercept)  | ||
| + | demog_sex  | ||
| + | --- | ||
| + | Signif. codes:  | ||
| + | > | ||
| + | > ######################################## | ||
| + | > ######################################## | ||
| + | > ######################################## | ||
| + | > # numeric IV | ||
| + | > fit.ex6.3 <- glm(mj_lifetime ~ alc_agefirst,  | ||
| + | + family = binomial, data = nsduh) | ||
| + | > summary(fit.ex6.3) | ||
| + | |||
| + | Call: | ||
| + | glm(formula = mj_lifetime ~ alc_agefirst, | ||
| + | data = nsduh) | ||
| + | |||
| + | Coefficients: | ||
| + |               | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | --- | ||
| + | Signif. codes:  | ||
| + | |||
| + | (Dispersion parameter for binomial family taken to be 1) | ||
| + | |||
| + |     Null deviance: 1141.45  | ||
| + | Residual deviance:  | ||
| + | (결측으로 인하여 157개의 관측치가 삭제되었습니다.) | ||
| + | AIC: 972.44 | ||
| + | |||
| + | Number of Fisher Scoring iterations: 5 | ||
| + | |||
| + | > round(summary(fit.ex6.3)$coef, | ||
| + |               | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | > | ||
| + | > | ||
| + | > ilogit(coef(fit.ex6.3)[" | ||
| + | (Intercept)  | ||
| + |   0.9952302  | ||
| + | > or <- exp(coef(fit.ex6.3)[" | ||
| + | > 1-or | ||
| + | alc_agefirst  | ||
| + |     | ||
| + | > | ||
| + | > # 0.9952 = prob of starting marijuana  | ||
| + | > # when the age is zero (intercept이므로) | ||
| + | > | ||
| + | > # age = 0 에서 추정하는 것은 이상함  | ||
| + | > summary(nsduh$alc_agefirst) | ||
| + |    Min. 1st Qu.  Median  | ||
| + |     | ||
| + | > | ||
| + | > # 위의 아웃풋에서 Mean값이 약 17이므로 17을 | ||
| + | > # 기준으로 하여 다시 보면 | ||
| + | > | ||
| + | > nsduh <- nsduh %> | ||
| + | +    | ||
| + | > fit.ex6.3.centered <- glm(mj_lifetime ~ calc_agefirst, | ||
| + | +                            | ||
| + | > summary(fit.ex6.3.centered) | ||
| + | |||
| + | Call: | ||
| + | glm(formula = mj_lifetime ~ calc_agefirst, | ||
| + | data = nsduh) | ||
| + | |||
| + | Coefficients: | ||
| + |               Estimate Std. Error z value Pr(> | ||
| + | (Intercept)  | ||
| + | calc_agefirst -0.28353  | ||
| + | --- | ||
| + | Signif. codes:  | ||
| + | |||
| + | (Dispersion parameter for binomial family taken to be 1) | ||
| + | |||
| + |     Null deviance: 1141.45  | ||
| + | Residual deviance:  | ||
| + | (결측으로 인하여 157개의 관측치가 삭제되었습니다.) | ||
| + | AIC: 972.44 | ||
| + | |||
| + | Number of Fisher Scoring iterations: 5 | ||
| + | |||
| + | > # 우선 나이가 17살일 때 (x=0) | ||
| + | > # 절편 값인 0.5207이 logit 값이 된다.  | ||
| + | > # 이 때, prob 를 구하면 아래와 같다 | ||
| + | > p <- ilogit(coef(fit.ex6.3.centered)[" | ||
| + | > p | ||
| + | (Intercept)  | ||
| + |   0.6273001  | ||
| + | > # 아니면  | ||
| + | > a <- fit.ex6.3.centered$coefficients[" | ||
| + | > exp(a)/ | ||
| + | (Intercept)  | ||
| + |   0.6273001  | ||
| + | > | ||
| + | > # 독립변인인 나이에 대한 해석 | ||
| + | > # b coefficient  | ||
| + | > # 17살일 때를 기준으로 한살씩 증가할 때마다의  | ||
| + | > # 마리화나 경험/ | ||
| + | > # 이를 수치화하면 (odds ratio는 exp(b)이다) | ||
| + | > exp(coef(fit.ex6.3.centered)[" | ||
| + | calc_agefirst  | ||
| + |     0.7531198  | ||
| + | > | ||
| + | > # 이는 17이후에 한살씩 알콜처음 경험을 늦추면  | ||
| + | > # 마리화나 경험율 대 미경험 odds ratio가  | ||
| + | > # 0.247 낮아진다고 할 수 있다 (0.7531 증가는) | ||
| + | > # 1-0.7531로 보는 것 | ||
| + | > | ||
| + | > # 그리고 이에 대한 CI를 보면 아래와 같고 | ||
| + | > confint(fit.ex6.3.centered)[2, | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | 2.5 % 97.5 % | ||
| + | calc_agefirst -0.3375819 -0.232863 | ||
| + | > # 이를 승비로 (odds ratio) 보면  | ||
| + | > exp(confint(fit.ex6.3.centered)[2, | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | 2.5 % 97.5 % | ||
| + | calc_agefirst 0.7134935 0.7922621 | ||
| + | > | ||
| + | > ################################# | ||
| + | > ################################# | ||
| + | > # 1년이 아니라 3년일 경우 | ||
| + | > fit.ex6.3.centered | ||
| + | |||
| + | Call:  glm(formula = mj_lifetime ~ calc_agefirst, | ||
| + | data = nsduh) | ||
| + | |||
| + | Coefficients: | ||
| + |   (Intercept)  | ||
| + |         | ||
| + | Degrees of Freedom: 842 Total (i.e. Null);  | ||
| + | (결측으로 인하여 157개의 관측치가 삭제되었습니다.) | ||
| + | Null Deviance: | ||
| + | Residual Deviance: 968.4 AIC: 972.4 | ||
| + | > coef(fit.ex6.3.centered)[" | ||
| + | calc_agefirst  | ||
| + |     -0.283531  | ||
| + | > coef(fit.ex6.3.centered)[" | ||
| + | calc_agefirst  | ||
| + |     -0.850593  | ||
| + | > exp(coef(fit.ex6.3.centered)[" | ||
| + | calc_agefirst  | ||
| + |     0.4271616  | ||
| + | > | ||
| + | > # CI 의 경우 아래와 같고 | ||
| + | > confint(fit.ex6.3.centered)[2, | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | 2.5 % 97.5 % | ||
| + | -1.012746 -0.698589  | ||
| + | > # 이에 해당하는 값은  | ||
| + | > exp(confint(fit.ex6.3.centered)[2, | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | 2.5 % 97.5 % | ||
| + | 0.3632203 0.4972865  | ||
| + | > | ||
| + | > | ||
| + | > ################################# | ||
| + | > ################################# | ||
| + | > ## Multiple regression | ||
| + | > ################################# | ||
| + | > fit.ex6.3.adj <- glm(mj_lifetime ~ alc_agefirst + | ||
| + | + demog_age_cat6 + demog_sex + | ||
| + | +                        demog_income,  | ||
| + | + family = binomial, data = nsduh) | ||
| + | > # Regression coefficient table | ||
| + | > round(summary(fit.ex6.3.adj)$coef, | ||
| + | Estimate Std. Error z value | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | Pr(>|z|) | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | > coef.values <- coef(fit.ex6.3.adj) | ||
| + | > data.frame(coef.values) | ||
| + | coef.values | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | > | ||
| + | > logit.values <- exp(coef(fit.ex6.3.adj)) | ||
| + | > data.frame(logit.values) | ||
| + | logit.values | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | > | ||
| + | > confint(fit.ex6.3.adj) | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | 2.5 % 97.5 % | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | > exp(confint(fit.ex6.3.adj)) | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | 2.5 % 97.5 % | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | > confint.logit.values <- exp(confint(fit.ex6.3.adj)) | ||
| + | 프로파일링이 완료되길 기다리는 중입니다... | ||
| + | > | ||
| + | > # logit.values 를 Adjusted Odds Ratio로 하고 출력 | ||
| + | > cbind(" | ||
| + | AdjOR 2.5 % | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | 97.5 % | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | > # 절편은 coefficient 해석과 (odds ratio) 관계 없으므로 생략  | ||
| + | > cbind(" | ||
| + | AdjOR 2.5 % 97.5 % | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | > # 소수점 3으로 제약 | ||
| + | > round(cbind(" | ||
| + | +              | ||
| + | AdjOR 2.5 % 97.5 % | ||
| + | alc_agefirst  | ||
| + | demog_age_cat626-34  | ||
| + | demog_age_cat635-49  | ||
| + | demog_age_cat650-64  | ||
| + | demog_age_cat665+  | ||
| + | demog_sexMale  | ||
| + | demog_income$20, | ||
| + | demog_income$50, | ||
| + | demog_income$75, | ||
| + | > | ||
| + | > # OR은 coefficient 값을 이야기하는 것을 다시 확인 | ||
| + | > | ||
| + | > # 또한 wald significant test | ||
| + | > # P-values | ||
| + | > car:: | ||
| + | Analysis of Deviance Table (Type III tests) | ||
| + | Response: mj_lifetime | ||
| + |                 | ||
| + | (Intercept)  | ||
| + | alc_agefirst  | ||
| + | demog_age_cat6  | ||
| + | demog_sex  | ||
| + | demog_income  | ||
| + | --- | ||
| + | Signif. codes:  | ||
| + | 경고메시지(들):  | ||
| + | 1: printHypothesis(L, | ||
| + | one or more coefficients in the hypothesis include | ||
| + |       | ||
| + | the printed representation of the hypothesis will be omitted | ||
| + | 2: printHypothesis(L, | ||
| + | one or more coefficients in the hypothesis include | ||
| + |       | ||
| + | the printed representation of the hypothesis will be omitted | ||
| + | > | ||
| </ | </ | ||
logistic_regression/examples_r.1733808884.txt.gz · Last modified:  by hkimscil
                
                