options(scipen=999)
options(digits=9)

d0=0
alpha=0.05
x1=c(102,96,98,95,92,114)
x2=c(127,115,91,124,98,107,122)
n1=length(x1);n1
n2=length(x2);n2
xbar1=mean(x1);xbar1
xbar2=mean(x2);xbar2
xbar1-xbar2
s1=sd(x1);s1
s2=sd(x2);s2
standard_error=sqrt(s1^2/n1+s2^2/n2);standard_error
v=(s1^2/n1+s2^2/n2)^2/((s1^2/n1)^2/(n1-1)+(s2^2/n2)^2/(n2-1));v
t_compute=((xbar1-xbar2)-d0)/standard_error;t_compute
t_critical=qt(1-alpha/2,v);t_critical
one_tailed_sig=1-pt(abs(t_compute),v);one_tailed_sig
two_tailed_sig=2*one_tailed_sig;two_tailed_sig

library(TeachingDemos)
x1=c(102,96,98,95,92,114)
x2=c(127,115,91,124,98,107,122)
var.test(x1,x2)

library(TeachingDemos)
x1=c(102,96,98,95,92,114)
x2=c(127,115,91,124,98,107,122)
t.test(x1,x2,mu=0,var.equal=FALSE)


d0=0
alpha=0.05
x1=c(102,96,98,95,92,114)
x2=c(127,115,91,124,98,107,122)
n1=length(x1);n1
n2=length(x2);n2
xbar1=mean(x1);xbar1
xbar2=mean(x2);xbar2
xbar1-xbar2
s1=sd(x1);s1
s2=sd(x2);s2
standard_error=sqrt(s1^2/n1+s2^2/n2);standard_error
v=10
t_compute=((xbar1-xbar2)-d0)/standard_error;t_compute
t_critical=qt(1-alpha/2,v);t_critical
one_tailed_sig=1-pt(abs(t_compute),v);one_tailed_sig
two_tailed_sig=2*one_tailed_sig;two_tailed_sig