1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
|
# Regression #################################################################
x = c(1.9, 0.8, 1.1, 0.1, -0.1, 4.4, 4.6, 1.6, 5.5, 3.4) # 독립변수
y = c(0.7, -1.0, -0.2, -1.2, -0.1, 3.4, 3.0, 0.8, 3.7, 2.0) # 종속변수
cor.test(x,y)
cor.test(x,y, alternative="greater")
cor.test(x,y, alternative="less")
out = lm(y ~ x) # 단순선형회귀
aa=summary(out) # 기본 분석결과 확인
aa
intc = aa$coefficients[1]
slop = aa$coefficients[2]
par(mfrow=c(1,2))
plot(x, y, pch=20, col="red") # plotting
abline(out, col="blue") # 회귀선 추가
plot(x, y, pch=20, col="red") # plotting
abline(out, col="blue") # 회귀선 추가
abline(a=0, b=0 , col='red', lty = 'dashed')
abline(v=0, col='red', lty = 'dashed')
abline(h=0, col='blue', lty = 'dashed')
text(0, 3, 'y=0.87378x - 0.92592', pos=4, cex=1.5)
|