b:head_first_statistics:correlation_and_regression
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| b:head_first_statistics:correlation_and_regression [2023/12/13 03:51] – [exercise] hkimscil | b:head_first_statistics:correlation_and_regression [2023/12/13 04:33] (current) – [exercise] hkimscil | ||
|---|---|---|---|
| Line 510: | Line 510: | ||
| > | > | ||
| </ | </ | ||
| + | ===== exercise 2: 직접해보기 ===== | ||
| + | 아래에서처럼 데이터를 R에서 다운로드 받아서 정리한 후에 위에서처럼 sp, ss.x, ss.y, b, a, r, r squared, 등등을 구해 보시오. | ||
| < | < | ||
| ######################## | ######################## | ||
| - | ss <- c(1.9, 2.5, 3.2, 3.8, 4.7, 5.5, 5.9, 7.2) | + | dat |
| - | at <- c(22, 33, 30, 42, 38, 49, 42, 55) | + | # data |
| - | mean.ss <- mean(ss) | + | # bankaccount = 통장갯수 |
| - | mean.at <- mean(at) | + | # income = 수입 |
| - | ss.ss <- sum((ss-mean.sa)^2) | + | # famnum = 부양가족수 |
| - | ss.at <- sum((at-mean.at)^2) | + | # IV = 수입 = income |
| - | df <- 8-1 | + | # DV = 통장갯수 = bankaccount |
| - | var.ss <- ss.ss/df | + | # |
| - | var.at <- ss.at/df | + | # 컬럼 이름 바꾸기 (간단하게) |
| - | sd.ss <- sqrt(var.ss) | + | colnames(dat) |
| - | sd.at <- sqrt(var.at) | + | dat |
| - | sp.ssat | + | attach(dat) |
| - | cov.ssat <- sp.ssat/df | + | dat |
| + | |||
| + | # ss.y | ||
| + | # ss.x | ||
| + | # df.y | ||
| + | # df.x | ||
| + | # sp.xy | ||
| + | # sd.x | ||
| + | # sd.y | ||
| + | |||
| + | # b coefficient | ||
| + | # b | ||
| + | # a intercept | ||
| + | # a | ||
| + | # pred <- a + b*x | ||
| + | # resid <- y - pred | ||
| + | |||
| + | # ss.pred | ||
| + | # ss.resid | ||
| + | # ss.y | ||
| + | |||
| + | # r | ||
| + | # r.sq | ||
| </ | </ | ||
b/head_first_statistics/correlation_and_regression.1702439475.txt.gz · Last modified: by hkimscil
