[R 통계분석] 상관과 회귀
Section 01. 상관계수 > # 서로 다른 상관계수와 그에 따른 산점도의 변화 > > set.seed(9) > rvnorm > r1 plot(r1, main="r=0.8") > abline(lm(r1[,2] ~ r1[,1]), col="red") > > r2 plot(r2, main="r=0") > abline(h=0, col="red") > > r3 plot(r3, main="r=-0.8") > abline(lm(r3[,2] ~ r3[,1]), col="red") > > ## 01) 아버지와 아들 키의 공분산과 상관계수 > > hf https://www.randomservices.org/random/data/Galton.txt", header=T, stringsAsFactors = FALSE, s..
2022. 8. 27.
[R 통계분석] 범주형 자료분석
Section 01. 적합도 검정 > # 자유도가 3인 χ2-분포에서 기각역(α=0.05) > > x dc > alpha tol > par(mar=c(0,1,1,1)) > plot(x, dc, type="l", axes=F, ylim=c(-0.03, 0.25), xlab="", ylab="", col = "blue") > abline(h=0) > abline(h=0, col = "blue") > tol.g polygon(c(tol.g, x[x>tol.g], 15), c(0, dc[x>tol.g], 0), col="red") > text(0, -0.03, "0", cex=0.8) > text(tol, -0.03, expression(chi[0.05]^{2}==2.14), cex=0.8) > > # 적합도 ..
2022. 8. 19.