[R] Bartlett' test

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Mon Nov 30 14:26:08 CET 2009


Silvano wrote:
> Hi,
> 
> I have an experiment with 5 treatments, of which 2 with 10 repetitions
> and 2 with 7 replications.
> I conducted the test of Bartlett step-by-step and compared with the
> value calculated directly by the R and the values are different.
> Anyone know tell me why?

The first term in M looks wrong when group sizes differ, but it would be
much easier to check if you gave the actual group variances.


(and PLEASE don't hijack other threads. This has nothing to do with
kernlab's ksvm!)

> 
> 
> #-------------------
> 
> n = length(trat)
> I = 4
> 
> (M = 2.3026*((n-I)*log10(mean(tapply(valor,trat,var))) -
> (9*log10(vari[1])+9*log10(vari[2])+6*log10(vari[3])+6*log10(vari[4]))))
> (C = 1 + 1/(3*(4-1))*((1/9 + 1/9 + 1/6 + 1/6) - 1/(9+9+6+6)))
> (B = M/C)
> 
>> B
> 1.748670
> 
>> qchisq(.05, 3, lower.tail=F)    # Valor tabelado
> [1] 7.814728
> 
> #-----------------------------------------
> # Teste de Bartlett de forma direta no R -
> #-----------------------------------------
> 
> bartlett.test(valor,trat)
> 
>        Bartlett test of homogeneity of variances
> 
> data:  valor and trat
> Bartlett's K-squared = 0.7845, df = 3, p-value =
> 0.8532


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907




More information about the R-help mailing list