In: Statistics and Probability
Solve with given information
>xBar=955 #sample mean
>mu0=1000 #hypothesized value
>sigma=220 #population standard deviation, sqrt(102)
>n=50 #sample size >z= (xbar-mu0)/(sigma/sqrt(n))
>z #test statistic [1] 1.446 >alpha=.025
>zalpha=qnorm(1-alpha) >zalpha #critical value
[1] 1.96
>pval=pnorm(z)
>pval #lower tail p-value
[1] 0.148
1. Here we will consider how the p-value will change with the sample size, keeping all of the other information the same. Create a vector, called “n”, of different sample sizes, from 10 to 200 at an increment of 5. You can do this using the seq() command. Use this vector of sample sizes, along with the information in question 1 and the pnorm() function, to create a vector of p-values that is the same length as the vector n. Plot the vector of sample sizes on the horizontal axis and the vector of p-values on the vertical axis using the plot function. Label the axes.
a. Paste the figure below. What happens to the p-value as the sample size increases?
b. What range of sample sizes will give you a statistically significant result, holding the population standard deviation and sample average constant?
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