[R] test for equality of two data sets withmultidimensional variables

John Fox jfox at mcmaster.ca
Tue Jun 21 16:22:57 CEST 2005


Dear Petr and Shengzhe,

Also see ?manova.

John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
-------------------------------- 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Petr Pikal
> Sent: Tuesday, June 21, 2005 7:30 AM
> To: wu sz; r-help at stat.math.ethz.ch
> Subject: Re: [R] test for equality of two data sets 
> withmultidimensional variables
> 
> Hi
> 
> searching in CRAN homepage for hotelling gave me this response
> 
> Thanks everyone for your help on this question. I solved the 
> problem by writing a procedure to calculate Hotelling's T^2 
> for a one-sample, multivariate t-test. Here's how it looks, 
> perhaps it will be useful to others. 
> 
> 
> data <- cbind(rnorm(50, 0.1, .01), rnorm(50,.1,.01),
> rnorm(50,.1,.01))
> k <- ncol(data)
> n <- nrow(data)
> xbar <- apply(data, 2, mean)
> mubar <- rep(0,k) #hypothesized means are zero dbar <- xbar - 
> mubar v <- var(data)
> t2 <- n*dbar%*%solve(v)%*%dbar
> F <- (n-k)*t2/((n-1)*k)
> P <- 1-pf(F,k,n-k) 
> 
> 
> A previous post by Peter B. Mandeville was very helpful, as 
> well as the Johnson/Wichern book on multivariate stats. 
> -S. Schultz 
> 
> and this
> 
> cran.r-project.org/doc/packages/agce.pdf - Podobné stránky 
> 
> CRAN - Package SharedHT2
> SharedHT2: Shared Hotelling T2 test for small sample 
> microarray experiments ...
> Derives a Hotelling T2 statistic having an F-distribution 
> using an empirical ...
> 
> Maybe this is what you want.
> 
> HTH
> Petr
> 
> 
> 
> 
> 
> On 21 Jun 2005 at 13:00, wu sz wrote:
> 
> > Hello there,
> > 
> > I have two data sets with 14 variables each, and wish to do 
> the test 
> > for equality of their covariance matrices and mean vectors. 
> Normally 
> > these tests should be done by chi square test (box provided) and 
> > Hotelling's T square test respectively. Which R functions could do 
> > this kind of test? I just find some functions could do for one 
> > dimension, but no for multidimension. Some one suggests 
> bartlett.test, 
> > but it seems just works for one dimension. Do you know which ones 
> > could do that, or I have to do R programming by myself?
> > 
> > Thank you,
> > Shengzhe
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> 
> Petr Pikal
> petr.pikal at precheza.cz
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list