z_test: Z-test

View source: R/z_test.R

z_testR Documentation

Z-test

Description

This function asks you a sequence of questions in order to execute a z-test. It finds a confidence interval and a p-value, produces a plot, and indicates how this could be queried directly from R.

Usage

z_test()

Examples


*******
Z-TESTS
*******

> z_test()
What is the *population* standard deviation? 4
What is your sample mean? 8
What is the theoretical mean you are testing against (called mu_0)? 7.5
What is your sample size? 36
What is your desired confidence level? .90
Are you doing a one-sided or two-sided test? Possible answers are 'less', 'greater', and 'two-sided'. two-sided
The probability of getting this result or more extreme for xbar if mu really is 7.5 is
p =  0.4532547

You can get this result by typing:
  2*(1-pnorm(8,7.5,4/sqrt(36))
     
     
     The 90% confidence interval for the population mean is
     6.903431  < mu <  9.096569
     
     You can get this result by finding:
       zstar = 1-qnorm((1-0.9)/2,0,1) = 1.644854
     
     and then calculating:
       8 - 1.644854 x 4/sqrt(36)  and  8 + 1.644854 x 4/sqrt(36)
       
       
       
       
       
       
> z_test()
What is the *population* standard deviation? 4
What is your sample mean? 8
What is the theoretical mean you are testing against (called mu_0)? 7.5
What is your sample size? 16
What is your desired confidence level? .99
Are you doing a one-sided or two-sided test? Possible answers are 'less', 'greater', and 'two-sided'. less
The probability of getting this result or more extreme for xbar if mu really is 7.5 is
p =  0.6914625

You can get this result by typing:
  pnorm(8,7.5,4/sqrt(16))


The 99% confidence interval for the population mean is
5.424171  < mu <  10.57583

You can get this result by finding:
  zstar = 1-qnorm((1-0.99)/2,0,1) = 2.575829

and then calculating:
  8 - 2.575829 x 4/sqrt(16)  and  8 + 2.575829 x 4/sqrt(16)

jrpriceUPS/Math160UPS documentation built on April 28, 2024, 12:41 p.m.