# Cprop.test: Test for proportions of one or two samples In RcmdrPlugin.TeachStat: R Commander Plugin for Teaching Statistical Methods

## Description

Performs hypothesis testing and confidence interval for a proportion or difference of two proportions. The values of the samples necessary to perform the function are the number of successes and the number of trails.

## Usage

 ```1 2 3``` ```Cprop.test(ex, nx, ey = NULL, ny = NULL, p.null = 0.5, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, ...) ```

## Arguments

 `ex` numeric value that represents the number of successes of the first sample (see Details). `nx` numerical value representing the total number of trails of the first sample. `ey` (optional) numerical value representing the number of success of the second sample (see Details). `ny` (optional) numerical value representing the total number of trails of the second sample. `p.null` numeric value that represents the value of the population proportion or the difference between the two population proportions, depending on whether there are one or two samples (see Details). `alternative` a character string specifying the alternative hypothesis, must be one of `"two.sided"` (default), `"greater"` or `"less"`. You can specify just the initial letter. `conf.level` confidence level of the interval. `...` further arguments to be passed to or from methods.

## Details

So that the contrast can be made must be fulfilled that at least 1 hit. That is, in the case of a sample `ex` must be greater than or equal to 1 and in the case of two samples, `ex` or `ey` must be greater than or equal to 1.

Furthermore, for the case of a sample value p.null must be strictly positive.

## Value

A list with class "htest" containing the following components:

 `statistic` the value of the test statistic. `parameter` number of trails and value of the population proportion or the difference in population proportions. `p.value` the p-value for the test. `conf.int` a confidence interval for the proportion or for the difference in proportions, appropriate to the specified alternative hypothesis. `estimate` a value with the sample proportions. `null.value` the value of the null hypothesis. `alternative` a character string describing the alternative. `method` a character string indicating the method used, and whether Yates' continuity correction was applied. `data.name` a character string giving the names of the data.

`prop.test`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21``` ```## Proportion for a sample Cprop.test(1,6) # 1 success in 6 attempts #### With a data set: proportion of cars not manufactured in US data(cars93) #data set provided with the package exitos<-sum(cars93\$USA == "nonUS") total<-length(cars93\$USA) Cprop.test(ex=exitos, nx=total) ## Difference of proportions Cprop.test(1,6,3,15) # Sample 1: 1 success in 6 attempts # Sample 2: 3 success in 15 attempts #### With a data set: difference of proportions of cars not manufactured in US #### between manual and automatic exitosx<-sum(cars93\$USA == "nonUS" & cars93\$Manual == "Yes" ) totalx<-sum(cars93\$Manual == "Yes") exitosy<-sum(cars93\$USA == "nonUS" & cars93\$Manual == "No" ) totaly<-sum(cars93\$Manual == "No") Cprop.test(ex=exitosx, nx=totalx,ey=exitosy, ny=totaly) ```