x=c(1.5,1.8,2.4,3.0,3.5,3.9,4.4,4.8,5.0)
y=c(4.8,5.7,7.0,8.3,10.9,12.4,13.1,13.6,15.3)
n=length(x);n
sumx=sum(x);sumx
sumxx=sum(x*x);sumxx
sumy=sum(y);sumy
sumyy=sum(y*y);sumyy
sumxy=sum(x*y);sumxy
xbar=mean(x);xbar
ybar=mean(y);ybar
sxx=sumxx-sumx^2/n;sxx
syy=sumyy-sumy^2/n;syy
sxy=sumxy-sumx*sumy/n;sxy
b=sxy/sxx;b
a=ybar-b*xbar;a
r=sxy/sqrt(sxx*syy);r
SSE=syy-b*sxy;SSE
SSR=b^2*sxx;SSR
SST=SSE+SSR;SST
r_square=r^2;r_square
adjust_R_square=1-((n-1)/(n-2))*(SSE/SST);adjust_R_square
s_square=SSE/(n-2);s_square
s=sqrt(s_square);s
alpha=0.05
df=n-2
t_critical=qt(1-alpha/2,df);t_critical
conf_slope=t_critical*s/sqrt(sxx);conf_slope
lower_slope=b-conf_slope;lower_slope
upper_slope=b+conf_slope;upper_slope
conf_intercept=t_critical*s*sqrt(sumxx/(n*sxx));conf_intercept
lower_intercept=a-conf_intercept;lower_intercept
upper_intercept=a+conf_intercept;upper_intercept
