The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
Many simple hypotheses are concerned with whether the proportion of one
group (e.g. females) with a certain characteristic (e.g. tobacco smoking) is
different from that of another group (e.g. males). In the package
ctest
, which is now loaded automatically when
R starts up, is the function
prop.test()
. This function tests whether two or more samples
divided on a dichotomous variable have the same proportions of each value.
Here's an example:
> sexsmoke<-matrix(c(70,120,65,140),ncol=2,byrow=T) > rownames(sexsmoke)<-c("male","female") > colnames(sexsmoke)<-c("smoke","nosmoke") > prop.test(sexsmoke)
In this case, we passed a matrix of "successes" (i.e. smokers) and "failures"
(i.e. non-smokers). prop.test()
will also accept separate vectors
of "successes" and "totals", like this:
> prop.test(c(70,65),c(190,205))
You can also specify the hypothetical proportions, if you want to test the samples against a particular set of values, whether your hypothesis is directional, and the confidence interval in the case of a two sample test.
> prop.test(c(70,65),c(190,205),conf.level=0.99) > prop.test(c(70,65),c(190,205),c(0.33,0.33))
An alternative function is fisher.test()
, also in the package
ctest
. This function performs Fisher's exact test on contingency
tables. For a function that will perform multiple comparisons of proportions,
see the group.prop.test function.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.