๊ฐœ์ธ๊ณต๋ถ€/R

์„ธ๋ฏธํ”„๋กœ์ ํŠธ02 ์ƒ๊ด€๋ถ„์„

LEE_BOMB 2021. 10. 29. 21:29

3. ๋ณ‘์› ์ˆ˜์™€ ๋…ธ์ธ ์ธ๊ตฌ ๋น„์œจ ์ƒ๊ด€๋ถ„์„

str(total) plot(total$count, total$pop_old_be, xlab="๋ณ‘์› ์ˆ˜", ylab="๋…ธ์ธ์ธ๊ตฌ ์ˆ˜") cor(total$count,total$pop_old_be) #cor -0.5877963 ์Œ์˜ ์ƒ๊ด€๊ด€๊ณ„

[์ด์ƒ์น˜] ํ•˜๋‚˜ ๋ฐœ๊ฒฌ(=์„œ์šธ ๊ฐ•๋‚จ๊ตฌ) y์ถ•์—์„œ ์ค‘์œ„๊ฐ’์ด๊ณ , true random variation์ด ์•„๋‹ˆ๋ผ๋Š” ์ฆ๊ฑฐ๊ฐ€ ์—†์œผ๋ฏ€๋กœ ์ œ๊ฑฐํ•˜์ง€ ์•Š๋Š”๋‹ค.

๋ณ‘์› ์ˆ˜์™€ ๋…ธ์ธ ์ธ๊ตฌ ๋น„์œจ ๋‹จ์ˆœํšŒ๊ท€๋ถ„์„

old = lm(formula = count ~ pop_old_be, total) summary(old)

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 797.323 43.216 18.45 <2e-16 ***
pop_old_be -21.818 1.866 -11.69 <2e-16 ***
Residual standard error: 257.9 on 259 degrees of freedom
Multiple R-squared: 0.3455, Adjusted R-squared: 0.343
F-statistic: 136.7 on 1 and 259 DF, p-value: < 2.2e-16





4. ์ถ”๊ฐ€๋ถ„์„
๊ทธ๋ ‡๋‹ค๋ฉด ์˜์œ ์•„ ๋น„์œจ์€ ๋ณ‘์› ์ˆ˜์™€ ๊ด€๋ จ์ด ์žˆ์„๊นŒ?

plot(total$count, total$pop_child_be, xlab="๋ณ‘์› ์ˆ˜", ylab="์˜์œ ์•„์ธ๊ตฌ ์ˆ˜") cor(total$count,total$pop_child_be) #cor 0.3487594 ์–‘์˜ ์ƒ๊ด€๊ด€๊ณ„


๋ณ‘์› ์ˆ˜์™€ ์˜์œ ์•„ ์ธ๊ตฌ ๋น„์œจ ๋‹จ์ˆœํšŒ๊ท€๋ถ„์„

child = lm(formula = count ~ pop_child_be, total) summary(child)

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -86.199 71.553 -1.205 0.229
pop_child_be 45.140 7.537 5.989 7.03e-09 ***
Residual standard error: 298.8 on 259 degrees of freedom
Multiple R-squared: 0.1216, Adjusted R-squared: 0.1182
F-statistic: 35.87 on 1 and 259 DF, p-value: 7.032e-09





๋ณ‘์› ์ˆ˜์™€ ๋น„๋…ธ์ธ ์ธ๊ตฌ ์ƒ๊ด€๋ถ„์„

cor(total$count,total$pop_be) #cor 0.6180532 ์–‘์˜ ์ƒ๊ด€๊ด€๊ณ„ plot(total$count, total$pop_be, xlab="๋ณ‘์› ์ˆ˜", ylab="๋น„ ๋…ธ์ธ์ธ๊ตฌ ์ˆ˜")


๋ณ‘์› ์ˆ˜์™€ ๋น„๋…ธ์ธ,๋น„์˜์œ ์•„ ์ธ๊ตฌ ๋‹จ์ˆœํšŒ๊ท€๋ถ„์„

peo = lm(formula = count ~ pop_be, total) summary(peo)

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1686.939 159.986 -10.54 <2e-16 ***
pop_be 29.069 2.297 12.65 <2e-16 ***
Residual standard error: 250.6 on 259 degrees of freedom
Multiple R-squared: 0.382, Adjusted R-squared: 0.3796
F-statistic: 160.1 on 1 and 259 DF, p-value: < 2.2e-16