x=c(4.3,4.5,5.9,5.6,6.1,5.2,3.8,2.1,7.5)
y=c(126,121,116,118,114,118,132,141,108)
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
r=sxy/sqrt(sxx*syy);r
t_compute=r*sqrt((n-2)/(1-r^2));t_compute
alpha=0.05
df=n-2
t_critical=qt(1-alpha/2,df);t_critical
sig_1_tailed=1-pt(abs(t_compute),df);sig_1_tailed
sig_2_tailed=2*sig_1_tailed;sig_2_tailed
