proptestGC: Proportions Procedures

Description Usage Arguments Value Author(s) Examples

View source: R/proptestGC.R

Description

Employs the normal approximation to perform test for one or two proportions.

Usage

1
2
3
4
proptestGC(x,data=parent.frame(),n=numeric(),p=NULL,
                         alternative=c("two.sided","less","greater"),
                         success="yes",first=NULL,conf.level=0.95,
                         correct=TRUE,graph=FALSE,verbose=TRUE)

Arguments

x

Either a formula or a numeric vector. If formula, it must be of the form ~x indicating the single variable under study, or of the form ~x+y, in which case x is the explanatory grouping variable (categorical with two values) and y is the response categorical variable with two values. When summary data are provided, x is a numeric vector of success counts.

data

Data frame that supplies the variables x and y. If any are not in data, then they will be searched for in the parent environment.

n

When not empty, this is a numeric vector giving the size of each sample.

p

Specifies Null Hypothesis value for population proportion. If not set, no test is performed.

alternative

"two.sided" requests computation of a two-sided P-value; other possible values are "less" and "greater".

success

When x is a formula, this argument indicates which value of variable x (in case of ~x) or y (in case of ~x+y) is being counted as a success. When working with formula-data input the value of this parameter MUST be set, even when the variable has only two values.

first

When performing 2-sample procedures, this argument specifies which value of the explanatory variable constitutes the first group.

conf.level

Number between 0 and 1 indicating the confidence-level of the interval supplied.

correct

Applies continuity correction for one-proportion procedures. It is ignored when when 2-proportions are performed.

graph

If TRUE, plot graph of P-value.

verbose

Indicates how much output goes to the console

Value

A list, either of class "gcp1test" (one-proportion) or "gcp2test" (two proportions). Components of this list that may be usefully queried include: "statistic", "p.value", and "interval".

Author(s)

Homer White hwhite0@georgetowncollege.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
data(m111survey)
#2-proportions, formula-data input, 95%-confidence interval only:
proptestGC(~sex+seat,data=m111survey,success="2_middle")

#For other confidence levels, use argument conf.level.  For 90%-interval for one proportion p:
proptestGC(~sex,data=m111survey,success="male",conf.level=0.90)

#one proportion, formula-data input, confidence interval and two-sided test with H_0:  p = 0.33:
proptestGC(~seat,data=m111survey,success="1_front",p=0.33)

#Summary data:
#In first sample, 23 successes out of 100 trials.  In second sample, 33 out of 110.
proptestGC(x=c(23,33),n=c(100,110))

#Summary data:
#In one sample, 40 successes in 100 trials.  Testing whether p = 0.45.
proptestGC(x=40,n=100,p=0.45,correct=TRUE)

#Want less output?  Set argument verbose to FALSE:
proptestGC(~sex+seat,data=m111survey,success="2_middle",p=0.33,verbose=FALSE)

tigerstats documentation built on July 2, 2020, 2:32 a.m.