Hello Dear R user, I want to conduct a Principal components analysis and I need to run two tests to check whether I can do it or not. I found how to run the KMO test, however i cannot find an R fonction for the Bartlett's test of sphericity. Does somebody know if it exists? Thanks for your help! Thibault [[alternative HTML version deleted]]
The formula for the chi-square value is: -( (n-1) - (2*p-5)/6 )* log(det(R)) where n is the number of observations, p is the number of variables, and R is the correlation matrix. The chi square test is then performed on (p^2-p)/2 degrees of freedom. So you can compute it by hand. Or you can use the function below (no warranty) where you supply the data as data frame to the function bartlett.sphere() example: x<-rnorm(100) y<-x+rnorm(100,0,0.1) bartlett.sphere<-function(data){chi.square=-( (dim(data)[1]-1) - (2*dim(data)[2]-5)/6 )* log(det(cor(data,use='pairwise.complete.obs')));cat('chi.square value ', chi.square , ' on ', (dim(data)[2]^2-dim(data)[2])/2, ' degrees of freedom.' , ' p-value: ', 1-pchisq(chi.square,(dim(data)[2]^2-dim(data)[2])/2))} bartlett.sphere(data.frame(x,y)) HTH, Daniel thibault grava-3 wrote:> > Hello Dear R user, > > I want to conduct a Principal components analysis and I need to run two > tests to check whether I can do it or not. I found how to run the KMO > test, however i cannot find an R fonction for the Bartlett's test of > sphericity. Does somebody know if it exists? > > Thanks for your help! > > Thibault > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- View this message in context: http://r.789695.n4.nabble.com/Bartlett-s-Test-of-Sphericity-tp3606765p3607184.html Sent from the R help mailing list archive at Nabble.com.
cortest.bartlett() in the psych package. I've never seen a non-significant Bartlett's test. Jeremy On 17 June 2011 12:43, thibault grava <thibault.grava at gmail.com> wrote:> Hello Dear R user, > > I want to conduct a Principal components analysis and I need to run two > tests to check whether I can do it or not. I found how to run the KMO > test, however i cannot find an R fonction for the Bartlett's test of > sphericity. Does somebody know if it exists? > > Thanks for your help! > > Thibault > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Hi Thibault, Not that I think you'll use this after the above responses, but for the record, have a look at: ?bartlett.test Cheers, Tal ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Fri, Jun 17, 2011 at 10:43 PM, thibault grava <thibault.grava@gmail.com>wrote:> Hello Dear R user, > > I want to conduct a Principal components analysis and I need to run two > tests to check whether I can do it or not. I found how to run the KMO > test, however i cannot find an R fonction for the Bartlett's test of > sphericity. Does somebody know if it exists? > > Thanks for your help! > > Thibault > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Fernando Henrique Ferraz Pereira da Rosa
2011-Oct-09 22:13 UTC
[R] Bartlett's Test of Sphericity
You could also check this function I implemented awhile back: http://www.fernandohrosa.com.br/en/P/sphericity-test-for-covariance-matrices-in-r-sphericity-test/ On Fri, Jun 17, 2011 at 4:43 PM, thibault grava <thibault.grava@gmail.com>wrote:> Hello Dear R user, > > I want to conduct a Principal components analysis and I need to run two > tests to check whether I can do it or not. I found how to run the KMO > test, however i cannot find an R fonction for the Bartlett's test of > sphericity. Does somebody know if it exists? > > Thanks for your help! > > Thibault > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- "Though this be randomness, yet there is structure in't." Fernando H Rosa - Statistician http://www.fernandohrosa.com.br / http://www.feferraz.net - Estatística, Matemática e Computação BankReview.com.br <http://www.bankreview.com.br/> - Escolha melhor seus serviços financeiros! AprendaAlemao.net <http://aprendaalemao.net/> - Seu ponto de partida para melhorar seu Alemão! @fhrosa [[alternative HTML version deleted]]