OneSampleCI: One-Sample Confidence Intervals

Description Usage Arguments Details Value Note Author(s) References Examples

Description

Compute confidence intervals on the population mean, population variance, and population proportion. In addition, it computes prediction interval for a single future observation from a normal distribution.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#CI for pupulation mean of a normal distribution when the population variance is known:
Zinterval(level,sigma,sample) # if sample available
Zinterval(level,sigma,n,barx) # if stats are provided
# Choice of sample size for estimating the population mean when error is specified
sample.size.Zinterval(level,sigma,E)

#CI for pupulation mean when the population variance is unknown and the distribution is normal
#or when the sample size is smaller than 25:
Tinterval(level,sample) # if sample available
Tinterval(level,n,barx,s) # if stats are provided

#Large-sample CI for pupulation mean:
AZinterval(level,sample) # if sample available
AZinterval(level,n,barx,s) # if stats are provided

#CI for pupulation variance (or standard deviation) of a normal distribution:
Chi2interval(level,sample) # if sample available
Chi2interval(level,n,s) # if stats are provided

#Large-sample CI for a pupulation proportion:
Propinterval(level,n,X)
# Choice of sample size for estimating a population proportion when error is specified
sample.size.Propinterval(level,ini.p,E) # using an intial guess
sample.size.Propinterval(level,ini.p=0.5,E) # using the conservative apporach

# Prediction interval of a single future observation form a normal distribution:
Predinterval(level,sample) # if sample available
Predinterval(level,n,barx,s) # if stats are provided

Arguments

level

the confidence level

sample

a vector of the observed sample

sigma

the known population standard deviation

s

the observed sample standard deviation

barx

the observed sample mean

n

the sample size

X

number of observations belongs to a class of interest

E

specified error in sample size calculation

ini.p

A initial estimate of the populatin proportion. Default is 0.5 which corresponds to the conservative approach

df

the degrees of freedom of a t or chi.square distribution

q

a quantile value

Details

Compute CIs for the population mean, population variance, and population proportaion and PI for a single future observation from a normal distribution.

Value

interval

As long as the function has "interval", the outcome contains a two-sided CI (or PI) and the two one-sided confidence bounds.

sample.size

As long as the function has "sample.size", the outcome is the minimum sample size required to control the error to be no larger than E.

t.quantile

quantile of a t distribution

Chi2.quantile

quantile of a chi.square distribution

Note

deweiwang@stat.sc.edu

Author(s)

Dewei Wang

References

Chapter 8 of the textbook "Applied Statistics and Probability for Engineers" 7th edition

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#Zinterval
#must include the = sign
x=c(64.1, 64.7, 64.5, 64.6, 64.5, 64.3, 64.6, 64.8, 64.2, 64.3)
Zinterval(level=0.95,sigma=1,sample=x)
Zinterval(level=0.99,sigma=1,sample=x)
sample.size.Zinterval(E=0.5,sigma=1,level=0.95)
# Using stats, must include the = sign
Zinterval(level=0.95,sigma=2,n=9,barx=98)

#Tinterval
#must include the = sign
Tinterval(level=0.95,n=10,barx=1000,s=20)
Tinterval(level=0.95,n=25,barx=1000,s=20)
Tinterval(level=0.99,n=10,barx=1000,s=20)
Tinterval(level=0.99,n=25,barx=1000,s=20)

#Large-sample Zinterval
#must include the = sign
x=scan("https://raw.githubusercontent.com/Harrindy/StatEngine/master/Data/Mercury.csv")
AZinterval(level=0.95,sample=x)

#Chi.square interval for variance/standard deviation
#must include the = sign
Chi2interval(level=0.95,n=20,s=0.01532)

#CIs for a porpulation proportion
#must include the = sign
Propinterval(level=0.95,n=85,X=10)
sample.size.Propinterval(level=0.95,ini.p=0.12,E=0.05)
sample.size.Propinterval(level=0.95,ini.p=0.5,E=0.05)

#Prediction interval for normal distribution
#must include the = sign
x=c(19.8, 10.1, 14.9, 7.5, 15.4, 15.4, 15.4, 18.5, 7.9, 12.7, 11.9, 11.4, 11.4,
14.1, 17.6, 16.7, 15.8, 19.5, 8.8, 13.6, 11.9, 11.4)
Tinterval(level=0.95,sample=x)
Predinterval(level=0.95,sample=x)

Harrindy/StatEngine documentation built on Nov. 19, 2021, 1:10 p.m.