s-news
[Top] [All Lists]

Re: Cramer's V statistics

To: Gerald.Jean@spgdag.ca
Subject: Re: Cramer's V statistics
From: Marc Schwartz <MSchwartz@MedAnalytics.com>
Date: Tue, 30 Sep 2003 17:18:49 -0500
Cc: s-news@wubios.wustl.edu
In-reply-to: <OF54B8BF51.A71D4F4C-ON85256DB1.006C470E@spgdag.ca>
Organization: MedAnalytics, Inc.
References: <OF54B8BF51.A71D4F4C-ON85256DB1.006C470E@spgdag.ca>
Reply-to: MSchwartz@MedAnalytics.com
On Tue, 2003-09-30 at 14:44, Gerald.Jean@spgdag.ca wrote:
> Hello S-users,
> 
> anyone aware of an implementation to calculate the Cramer's V statistics?
> 
> Thanks,
> 
> Gérald Jean


Here is an implementation for R of the V statistic itself. Be sure to
make changes as appropriate for S-Plus:

# Calculate Cramer's V
# For 2 x 2 tables V = Phi
# x = matrix
calc.CV <- function(x)
{
  CV <- sqrt(chisq.test(x, correct = FALSE)$statistic /
            (sum(x) * min(dim(x) - 1)))

  invisible(as.numeric(CV))
}


As implemented you need to assign the result of the function:

V <- calc.CV(x)

HTH,

Marc Schwartz



<Prev in Thread] Current Thread [Next in Thread>