[R] Bartlett Test

Amit Patel amitrhelp at yahoo.co.uk
Mon Mar 1 18:12:33 CET 2010

Apparently the vectors that I have are lists and when I try to conduct the Bartlett test I am getting errors. I may be using it wrong. I am not an R expert>

xbartlett2 <- c(Samp1,Samp2)
#Samp1 & 2 are lists
gbartlett24 <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)

Attempt 1
> gazant <- bartlett.test(xbartlett2~gbartlett24)$p.value
Error in model.frame.default(formula = xbartlett2 ~ gbartlett24) : 
  invalid type (list) for variable 'xbartlett2'

xbartlett2 <- c(Samp1,Samp2)

> gazant <- bartlett.test(xbartlett2, gbartlett24)$p.value
Error in bartlett.test.default(xbartlett2, gbartlett24) : 
  there must be at least 2 observations in each group

(There are at least 2 unique observations in each group)

Thanks in advance

----- Original Message ----
From: "Richardson, Patrick" <Patrick.Richardson at vai.org>
To: Amit Patel <amitrhelp at yahoo.co.uk>; "r-help at r-project.org" <r-help at r-project.org>
Sent: Mon, 1 March, 2010 14:31:15
Subject: RE: [R] Bartlett Test


From the help page "If x is a list, its elements are taken as the samples or fitted linear models to be compared for homogeneity of variances. In this case, the elements must either all be numeric data vectors or fitted linear model objects, g is ignored, and one can simply use bartlett.test(x) to perform the test. If the samples are not yet contained in a list, use bartlett.test(list(x, ...)). 

Otherwise, x must be a numeric data vector, and g must be a vector or factor object of the same length as x giving the group for the corresponding elements of x. "


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Amit Patel
Sent: Monday, March 01, 2010 9:26 AM
To: r-help at r-project.org
Subject: [R] Bartlett Test


I am trying to conduct a Bartlett test between two groups Samp 1 and Samp 2, both of which are vectors of equal length. I cant find any information on how to do this. Does the data need to be in a structured list. 

Thanks in advance

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

More information about the R-help mailing list