## Answers

Answer:

1)

2)

a)

> xbar=955 #sample mean

>

> mu0=1000 #hypothesized value

>

> sigma=220 #population standard deviation

>

> n<-seq(10,200,5) # n values from 10 to 200 by margin of 5

>

> pval=rep(0,length(n)) # define p value as same of length of "n"

>

> for(i in 1:length(n)){

+ z= (xbar-mu0)/(sigma/sqrt(n[i]))

+ pval[i]=pnorm(z)

+ }

>

> plot(n,pval,xlab="sample size",ylab="p-value",main = "P value as n increases")

b)

Comment :- as sample size increases the P value is decreases.i.e result become significant as sample size increases.

c) n >= 65 will give us the statistically significant result.

in R it can be done as

> g<-data.frame(n,pval)

> subset(g,pval<0.05)

n pval

12 65 0.049563762

13 70 0.043508256

14 75 0.038245808

15 80 0.033661609

16 85 0.029659883

17 90 0.026160171

18 95 0.023094476

19 100 0.020405033

20 105 0.018042550

21 110 0.015964801

22 115 0.014135485

23 120 0.012523302

24 125 0.011101189

25 130 0.009845691

26 135 0.008736431

27 140 0.007755678

28 145 0.006887969

29 150 0.006119801

30 155 0.005439364

31 160 0.004836313

32 165 0.004301577

33 170 0.003827193

34 175 0.003406162

35 180 0.003032326

36 185 0.002700262

37 190 0.002405192

38 195 0.002142902

39 200 0.001909671

3)

assuming it is two-tailed test

mu0=1000 #hypothesized value

sigma=220 #population standard deviation, sqrt(102)

n=50 #sample size

xbar <- seq(920,1000,5)

pval = 2* (1- pnorm(abs((xbar-mu0)/(sigma/sqrt(n)))))

pval

plot(xbar,pval)

4)

Let indicate the true mean of the population

We want to test the following hypotheses

R code to do this left tail test (all statements starting with # are comments)

xBar<-955 #sample mean

mu0<-1000 #hypothesized value

n<-50 #sample size

#a vector of population standard deviations, from 120 to 250

sigma<-seq(120,250,by=5)

#test statistic

z<- (xBar-mu0)/(sigma/sqrt(n))

#p-values, lower tail values P(Z<-z)

pval<-pnorm(z,lower.tail=TRUE)

#plot

plot(sigma,pval,type="l",xlab="Population standard deviation",ylab="p-value",main="p-value vs population sd")

#set the level of significance

alpha<-0.025

#find the range of population standard deviations with p-val<alpha

sigma[pval<alpha]

#get this plot

a)

We can see that the p-value increases as the population standard deviation increases.

We know that the standard error of mean is calculated using

where

We can see that the standard error of mean increases with the population standard deviation for a given n.

Next the value of test statistics is

We can see that for a given sample average, the absolute value of z decreases (or the value of negative of z increase) with the increase in standard error (that is increase in population standard deviation)

This is a left tail test. Hence the p-value = P(Z<-z) will only increase when the absolute value of z decrease

b) Out put from R is below

we will get statistically significant results when the p-value is less than the level of significance alpha.

For a level of significance alpha=0.025, we can see that we will get statistically significant results when the population standard deviation is between 120 to 160 (approximate), holding the sample average and sample size constant

5)

We reject the null hypothesis when p value<0.05 ie z<-1.645

ie

ie

ie is the rejection region interms of

b)*tru_mu<-seq(800,1000,by=10)* will generate numbers from 800 to 1000 in intervals of 10

c) power of the test is probability of rejecting the null hypothesis when actually it not true

P(

When true the command interms of qnorm is

norm(1.57) will give you the required probability

so here the required r code is

*z<-{948.82-trumu}/{220/sqrt(50)} z*

*power<- pnorm(z)* will give you the vector of probabilities corresponding to the alternatives from 800 to 1000 in the interval of 10

d) *plot( tru_mu,power, main="power curve", ylab="power of the test",xlab="mu")*

e) From the graph when mu ranges from 800 to 920 power is greater than 80%

Note: the r codes are given in italics

We begin with computing the test statistic xbar 955 # sample mean siama22O > n50 # hypothesized value # population standard deviation, sqrt(O2) #sample size # test statistic L0 1440 We then compute the critical value at 05 significance level apha-025 zapha- qnorml-apha) > Ζ.alpha # critical value pval pnormz) pval- pval L1 O148 # lower tail p-value From above R output, we conclude a level of significance, alpha- O05 from standard normal table, two tailed z apha/2 -l90 since our test is two-tailed reject Ho, if zo < 490 OR if zo 1.90 b. p-value 0.148