[R] chisq.test error: x and y must have at least 2 levels
kjetil at entelnet.bo
Sat Nov 8 03:37:11 CET 2003
On 7 Nov 2003 at 8:19, Thomas Lumley wrote:
Just to make the point more clear:
> fisher.test( matrix(c(42,0,0,0),2,2))
Fisher's Exact Test for Count Data
data: matrix(c(42, 0, 0, 0), 2, 2)
p-value = 1
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
The confidence interval for odds ratio goes from 0 to infinity,
a rather clear way of saying there is no information.
> On Fri, 7 Nov 2003, Christoph Bier wrote:
> > Peter Dalgaard wrote:
> > > Well, the error message might be slightly beside the point, but the
> > > issue would seem to be that there are no "ja"'s inside either vector.
> > > I.e. it first reduces each factor to those levels that are actually
> > > present, then checks whether there are at least two levels.
> > Thanks for this explanation.
> > > You can't do a chisquare test on a table that looks like this
> > >
> > > nein ja
> > > nein 42 0
> > > ja 0 0
> > >
> > Hm, and now? There is data like this and I need to do a chisquare
> > test. Spencer's answer seems to be the solution.
> > Is my data that uncommon, that chisq.test hasn't a built-in
> > function to avoid this error?
> It's not that your data are uncommon. Your data contain no information
> about whether `ja' answers tend to occur together for the two variables,
> because there no `ja' answers.
> R-help at stat.math.ethz.ch mailing list
More information about the R-help