[R] homogenity inside groups
Petr PIKAL
petr.pikal at precheza.cz
Fri Nov 16 14:40:45 CET 2007
Thank you. I will try.
Petr
petr.pikal at precheza.cz
r-help-bounces at r-project.org napsal dne 16.11.2007 13:21:13:
> On Fri, 2007-11-16 at 11:49 +0100, Petr PIKAL wrote:
> > Yes, that is what I meant. It is not a species but some products and I
> > have various parameters measured for each product. But basically I
thought
> > that ecological data are quite similar.
> >
> > So I would be glad to be able to try your code.
> >
> > Thank you
>
> Dear Petr,
>
> The code is attached the file. The functions use my analogue package (on
> CRAN). I haven't written the Rd files yet but the functions are quite
> simple and require few arguments. The code chunk below use data from the
> vegan package as an example.
>
> require(vegan)
> require(analogue)
> data(varespec)
> dis <- vegdist(varespec)
> groups <- factor(c(rep(1,16), rep(2,8)), labels =
c("grazed","ungrazed"))
> mod <- dispersion(dis, groups)
> mod
> anova(mod)
> system.time(permDisp(mod))
> system.time(perm.mod <- permDisp(mod, nperm = 9999))
> perm.mod
> plot(mod)
> boxplot(mod)
>
> Hope you find it useful and if you have any comments, let me know.
>
> All the best,
>
> G
>
> >
> > Petr Pikal
> > petr.pikal at precheza.cz
> >
> > Gavin Simpson <gavin.simpson at ucl.ac.uk> napsal dne 15.11.2007
18:32:08:
> >
> > > On Thu, 2007-11-15 at 16:07 +0100, Petr PIKAL wrote:
> > > > Dear all
> > > >
> > > > I would like to show my audience that some variables are
homogenous
> > inside
> > > > groups but different outside. I can use by with summary for all
> > variables
> > > >
> > > > by(iris[,1:4], iris$Species, summary)
> > > >
> > > > what can be quite messy in case of more than few variables and
about 8
> >
> > > > groups
> > > >
> > > > or densityplot for one variable
> > > >
> > > > densityplot(~Petal.Length | Species, iris)
> > > >
> > > > I have two questions:
> > > >
> > > > 1. Is there any other plot to show all variables at once?
> > Something
> > > > like
> > > >
> > > > densityplot(~iris[,1:4] | Species, iris)
> > > >
> > > > 2. Is it possible to evaluate homogenity of many (20-30)
> > variables
> > > > inside groups by some other function/table/graph?
> > >
> > > Hi Petr,
> > >
> > > I haven't replied-all by the way, in case I've misunderstood, but...
> > >
> > > If you mean that you have a data set with say 10 samples split into
2
> > > groups, and for each sample you have measured many variables (say
> > > species in a quadrat or lots of morphological parameters on
individual
> > > plants), then one way might be to look at the work of Marti Anderson
> > > [*]. She has developed a method that calculates the multivariate
> > > distance between each sample in a group and that group's
multivariate
> > > centroid. You then take these distances to group centroid and do an
> > > ANOVA on them, the general point being that this is a multivariate
> > > analogue of something like a Levene's test and if groups variances
are
> > > heterogeneous then one or more groups will have a higher/lower mean
> > > distance to centroid than the other groups.
> > >
> > > groups <- something.that.gives.groups.as.a.factor()
> > > dis <- something.that.gives.distances.centroids(my_data, groups)
> > > anova(lm(dis ~ groups))
> > >
> > > If this is the case, then I have some code that I'm currently
working on
> > > which does this, which works (!) and which I can send to you. Marti
> > > tests for homogeneity using a permutation test. I have that as well,
but
> > > currently it doesn't give the same results as Marti's PERMDISP2
> > > programme (standalone Fortran, source not available), though I can't
see
> > > what I'm doing wrong, if anything - and my permutation p-value
closely
> > > matches the ANOVA p-value for tests where the data don't violate
ANOVA
> > > assumptions too grossly - Levene's test is quite robust in this
regard.
> > >
> > > Let me know if this is what you meant and if the code will be useful
and
> > > I'll send a reply to the list for the archives and send you my code.
> > >
> > > All the best,
> > >
> > > G
> > >
> > > [*] Anderson, M.J. (2006) Distance-based tests for homogeneity of
> > > multivariate dispersions. Biometrics 62, 245--253
> > >
> > > http://www.stat.auckland.ac.nz/~mja/Programs.htm
> > >
> > > >
> > > > Thank you
> > > >
> > > > Petr Pikal
> > > > petr.pikal at precheza.cz
> > > >
> > > > ______________________________________________
> > > > 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.
> > > --
> > >
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> > > Dr. Gavin Simpson [t] +44 (0)20 7679 0522
> > > ECRC, UCL Geography, [f] +44 (0)20 7679 0565
> > > Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
> > > Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
> > > UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
> > >
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> > >
> >
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> Dr. Gavin Simpson [t] +44 (0)20 7679 0522
> ECRC, UCL Geography, [f] +44 (0)20 7679 0565
> Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
> Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
> UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> [příloha r_permdisp.R odstraněna uživatelem Petr PIKAL/CTCAP]
> ______________________________________________
> 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.
More information about the R-help
mailing list