Hypothesis testing using R Experiment :3 Small-Sample Single mean . Experiment :4 Chi-squared test

 #LAB-10

#Hypothesis Testing Using R
#Program-1
x=c(5,2,8,-1,3,0,-2,1,5,0,4,6)
xbar=mean(x)
s=sd(x)
n=12
mu=0
t=(xbar-mu)/(s/sqrt(n))
cat("Test statistic=",t)
alpha=0.05
t.alpha=qt(1-alpha/2,df=n-1)
cat("t-Table value:",t.alpha)

#Program-2
xbar=9900
mu=10000
n=25
s=125
t=(xbar-mu)/(s/sqrt(n))
cat("Test statistic=",t)
alpha=0.05
t.alpha=qt(1-alpha,df=n-1)
cat("t-Table value:",-t.alpha)

#Program-3
xbar=2.1
s=0.3
n=28
mu=2
t=(xbar-mu)/(s/sqrt(n))
cat("Test statistic=",t)
alpha=0.05
t.alpha=qt(1-alpha/2,df=n-1)
cat("t-Table value:",t.alpha)

#Chi-Square test for Independence
#Program-1
x=matrix(c(24,289,9,100,13,565),nrow=2)
View(x)
chisq.test(x)
qchisq(p=0.05,df=2,lower.tail=FALSE)

#Program-2
x=matrix(c(100,20,150,30,20,180),nrow=2)
View(x)
chisq.test(x)
qchisq(p=0.05,df=2,lower.tail=FALSE)

#Student Task
xbar=990
mu=1000
n=26
s=20
t=(xbar-mu)/(s/sqrt(n))
cat("Test statistic=",t)
alpha=0.05
t.alpha=qt(1-alpha,df=n-1)
cat("t-Table value:",-t.alpha)

#Chi-Square test
x=matrix(c(69,81,51,20),nrow=2)
View(x)
chisq.test(x)
qchisq(p=0.05,df=2,lower.tail=FALSE)



Comments

Popular posts from this blog

Probability distributions using R Experiment :1 Binomial Distribution Experiment :2 Poisson Distribution Experiment :3 Normal Distribution

Lines of Regression, Angle between two lines of regression and estimated values of variables. Experiment :1 Finding (a) Regression line of y on x and (b) Regression line of x on y. Experiment :2 Predicting y value for a given x. Experiment :3 Angle between two lines of regression