## R Programming Homework Solution on Estimation

• 9th Jun, 2022
• 15:47 PM
```## Question 1 Code
##1(a)   Assuming that Stans claim is true that his apple sweatness is good, we consider below null and alternate hypothesis
# Null Hypothesis : mean >=30
#Alternate Hypothesis: mean<30> #At 5% level of significance that is 95% confidence interval
# From Psychich story of stans we understand that population sigma = 6.8
# Left tail t-test
t_critical =qt(0.05,11)
samp_mean = 28.6
hyp_mean = 30
n=12
sigma = (6.8)/sqrt(n)
t_calculated = (samp_mean-hyp_mean)/sigma/sqrt(n)
if (t_calculated   print('mean<30> }else {
print('mean>=30,stans claims true that his apples are sweater than Bred')
}

# Question 1(b)

sample_mean1=28.6
sample_mean2=29.5
sample_std1=6.8
sample_std2 = 3.6
n1=12
n2=18
pooled_std = ((n1-1)*(sample_std1)^2 + (n2-1)*(sample_std2)^2)/(n1+n2-2)
t_calculated1 = (sample_mean1-sample_mean2)/pooled_std
t_critical1= qt(0.025,n1+n2-2)
if (t_calculated1>t_critical1){
print('Both have equal means')
}else {
print('means are not equal')
}

# Question 1(c)

p1=0.5
q1=0.5
p2=8/18
q2=10/18
n1=12
n2=18
combined_p = ((n1*p1)+(n2*p2))/(n1+n2)
combined_q = 1 - combined_p
alpha=0.05
t_critical = qt(0.975,n1+n2-2)
sigma = sqrt((combined_p*combined_q)/(n1+n2-2))
t_calculated2 = (p1-p2)/sigma
if (t_calculated1   print('Both have equal means')
}else {
print('means are not equal')
}

#Question 1(C)
p1=0.5
q1=0.5
p2=8/18
q2=10/18
n1=12
n2=18
combined_p = ((n1*p1)+(n2*p2))/(n1+n2)
combined_q = 1 - combined_p
alpha=0.05
t_critical = qt(0.975,n1+n2-2)
sigma = sqrt((p1*q1/n1)+(p2*q2/n2))
t_calculated2 = (p1-p2)/sigma
if (t_calculated1   print('Both have equal means')
}else {
print('means are not equal')
}

#Question2
sigm1=4.41
sigma2 = 3.24
f_calculated=4.41/3.24
f_critical = qf(0.98,df1=41,df2=41)
if (f_calculated   print('Both have equal vairance')
}else {
print('variance are not equal')
}
#Question 2(b)
n=625
mean = 5
sigma=2/sqrt(n)
z=qnorm(0.95,mean,sigma)
lower_value = mean - (sigma*z)
upper_value = mean + (sigma*z)
print(upper_value)

#One side test

n=625
mean = 5
sigma=2/sqrt(n)
z=qnorm(0.95,mean,sigma)
lower_value = mean - (sigma*z)
upper_value = mean
print(lower_value)
print(upper_value)

#Question 3
n=70
mean =1000
sigma=500/sqrt(n)
z=qnorm(0.95,mean,sigma)
lower_value = mean - (sigma*z)
upper_value = mean
print(lower_value)
print(upper_value)
```