[R] leveneTest between 2-levels of 3-level factor in R?

Rolf Turner r.turner at auckland.ac.nz
Mon Oct 19 23:13:20 CEST 2015


On 20/10/15 01:02, Dr. Leigh S. Sutherland wrote:
> Still feeling my way around using R...
>
> What I have done so far:
>
> I have a data.frame 'results' with response 'Fail', and three factors
> 'PREP', 'CLEAN' & 'ADHES'. ADHES has 3 levels: Crest Cryst Poly
>
> I calculated the variances:
>
> sigma..k=tapply(Fail,ADHES,var)
> print(sqrt(sigma..k)):
>
> Crest    Cryst     Poly 17.56668 41.64679 39.42669
>
> then used leveneTest to test for constance of variance:
>
> print(leveneTest(Fail~ADHES))

How does leveneTest() find the variables "Fail" and "ADHES" given that 
you do not provide it with a "data" argument?

> Levene's Test for Homogeneity of Variance (center = median)
>        Df F value  Pr(>F)
> group  2   3.929 0.02588 *
>        51
>
> The Question:
> Now I want to use Levene's to test for constance of variance between only
> the Cryst & Poly levels of the factor ADHES, but I cant work out the syntax
> to do this in R.
>
> Could anyone help, please?

I am not at all sure that I understand your somewhat incoherently 
expressed question, but I *think* that what you want to do might be done 
by setting

    ok <- with(results,ADHES%in%c("Cryst","Poly"))
    leveneTest(Fail ~ ADHES, data=results[ok,])

It's hard to say, since you do not provide a reproducible example.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-help mailing list