Re: [R-sig-phylo] hurdle models

2021-08-24 Thread jonnations
Hi Ted,

The R library brms had many distributional families including a log-normal
hurdle distribution. I think this is the one you want as it sounds like you
have a continuous, positive horn length measurement along with your animals
that lack horns. It looks like this family has an extra “hu” parameter to
model the hurdle process. If your measurements are not continuous but are
instead counts or bounded by 0&1, you could look into some of the
zero-inflated models like zi-poisson or zi-beta respectively. There’s also
a zi-gamma distribution family option which could work for you. There is
lots of talk out there on when to use hurdle vs zero-inflated families.
Importantly, you can set up a phylogenetic regression using any of these
families. Just search “brms phylogenetic” for the excellent vignette. This
method will require going Bayesian, but this is probably a good idea
regardless given your small sample size and relatively complex model as you
can use regularizing priors to avoid overfitting.

(Just FYI priors may require a bit of extra thought and care in log-normal
distribution families and the outputs may need to be transformed via
exp(beta). But I’ve never used this family so I’m not totally sure).

Jon



On Tue, Aug 24, 2021 at 5:01 AM  wrote:

> Send R-sig-phylo mailing list submissions to
> r-sig-phylo@r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> or, via email, send a message with subject or body 'help' to
> r-sig-phylo-requ...@r-project.org
>
> You can reach the person managing the list at
> r-sig-phylo-ow...@r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-phylo digest..."
>
>
> Today's Topics:
>
>1. hurdle models (Ted Stankowich)
>
> --
>
> Message: 1
> Date: Tue, 24 Aug 2021 01:05:33 +
> From: Ted Stankowich 
> To: "r-sig-phylo@r-project.org" 
> Subject: [R-sig-phylo] hurdle models
> Message-ID:
> <
> by5pr12mb4820249e759c5ecb4466a4c9f6...@by5pr12mb4820.namprd12.prod.outlook.com
> >
>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi all,
> We're doing an analysis of horn evolution in female ungulates where some
> taxa (30+ species) lack horns entirely and others have horns of varying
> lengths, so it is a mixture of a discrete and continuous variable.
>
> We want to run a phylogenetic analysis on our dataset, and many have
> suggested run a "two part" model or "hurdle" model since we have a zero
> inflation within our continuous data.
>
> We have attempted the "hurdle" function using the "pscl" package, but
> consistently receive this error message:
> Error in hurdle(log10Hornmm ~ LogSHexp..mm., data = HabPrac) :
>   invalid dependent variable, non-integer values
>
> Is it possible to run a phylogenetic analysis using a hurdle model or are
> there other recommendations for dedicated phylo models? We have attached a
> plot of our data. We don't want to degrade it into a discrete 0/1 trait, as
> we already tested it this way in a previous paper. We really would like to
> capture the continuous nature of the horn length in those species that have
> it, while still accounting for the many species lacking horns distributed
> throughout the tree (there are several independent evolutionary origins of
> female horns).
>
> Apologies if we've just missed an obvious phylo model that's commonly used.
>
> Thanks!
> Dr. Ted Stankowich
> Associate Professor
> Associate Chair
> Department of Biological Sciences
> California State University Long Beach
> www.csulb.edu/mammallab
> [cid:image001.png@01D79849.89A0]
>
>
>
> Thanks,
> Ted Stankowich
>
>
>
>
> -- next part --
> An HTML attachment was scrubbed...
> URL: <
> https://stat.ethz.ch/mailman/private/r-sig-phylo/attachments/20210824/c6cfda71/attachment-0001.html
> >
>
> -- next part --
> A non-text attachment was scrubbed...
> Name: image001.png
> Type: image/png
> Size: 23778 bytes
> Desc: image001.png
> URL: <
> https://stat.ethz.ch/mailman/private/r-sig-phylo/attachments/20210824/c6cfda71/attachment-0001.png
> >
>
> -- next part --
> A non-text attachment was scrubbed...
> Name: FemaleBovid Plot 1.pdf
> Type: application/pdf
> Size: 9400 bytes
> Desc: FemaleBovid Plot 1.pdf
> URL: <
> https://stat.ethz.ch/mailman/private/r-sig-phylo/attachments/20210824/c6cfda71/attachment-0001.pdf
> >
>
>
> --
>
> Subject: Digest Footer
>
> ___
> R-sig-phylo mailing list
> R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>
>
> --
>
> End of R-sig-phylo Digest, Vol 163, Issue 1
> ***
>
-- 
Jonathan A. Nations
NSF Postdoctoral R

Re: [R-sig-phylo] R-sig-phylo Digest, Vol 148, Issue 1

2020-05-07 Thread jonnations
Hi Charles,

I’m sorry... I don’t have a solution to your plotting issues, but here are
a couple of ideas. I know there are two ggplot2 extension packages that
plot or wrangle node based graphs: ggraph and tidygraph. Both were written
by the same developer. ggraph plots relational or network data in a ton of
different shapes, including dendrograms. Tidygraph has some kind of
“join_node()” function to connect the nodes of two separate graphs. It
probably makes it easy to sort or order your network nodes as well. I am
sure there is a way to connect or align your tree tips and food web nodes
in a flexible and aesthetically pleasing way using these tools, but it may
take some work. The dev might be willing help you with that!

Not sure if it’s immediately possible, but maybe you could use the amazing
ggtree package to plot the tree and then connect it to or align it with a
network graph from ggraph?

Good luck!
Jon



On Thu, May 7, 2020 at 5:03 AM  wrote:

> Send R-sig-phylo mailing list submissions to
> r-sig-phylo@r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> or, via email, send a message with subject or body 'help' to
> r-sig-phylo-requ...@r-project.org
>
> You can reach the person managing the list at
> r-sig-phylo-ow...@r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-phylo digest..."
>
>
> Today's Topics:
>
>1. Combining foodwebs and phylogenetic trees (Charles Lehnen)
>
> --
>
> Message: 1
> Date: Tue, 5 May 2020 20:52:48 -0500
> From: Charles Lehnen 
> To: r-sig-phylo@r-project.org
> Subject: [R-sig-phylo] Combining foodwebs and phylogenetic trees
> Message-ID:
> <
> caa560r6tehdgg5ffcdcwe3sgudrq2hvkkwnjz1eszmmpd+r...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> I have trying to combine foodweb outputs like the bipartite package's
> plotweb() function of bipartiteD3’s bipartite_D3 function with phylogenetic
> trees, similar to a tanglegram. Because of the very large size and a high
> amount of variability in my dataset, standard tanglegrams turn out very
> convoluted, but the plotweb() outputs are still lovely.
>
> I was able to export tips to manually order the tips of the plotweb()
> output to match the order of the phylogenetic tree tips which allowed me to
> align tips manually in Inkscape, but this proved extremely time consuming
> whenever I made an addition to my dataset.
>
> require('ape')
>
> tree1<-read.tree(text="((A,(B,(C,D))),E);")
> tree1<-ladderize(tree1, right = FALSE)
>
> tree2<-read.tree(text="(F,(G,((H,I),(J,K;")
>
> is_tip <- tree1$edge[,2] <= length(tree1$tip.label)
> ordered_tips <- tree1$edge[is_tip, 2]
> tree1tips<-tree1$tip.label[ordered_tips]
>
> is_tip <- tree2$edge[,2] <= length(tree2$tip.label)
> ordered_tips <- tree2$edge[is_tip, 2]
> tree2tips<-tree2$tip.label[ordered_tips]
>
>
> I tried to edit the plotweb() script to accept phylo class variables as an
> additional argument, but that was evidently beyond my abilities at this
> time.
>
> I also tried combing the outputs using the grid package, we were able to
> visually combine outputs next to one another and match the order of the
> tips. However, I have not been able to figure out how to actually line up
> the tips of the trees to the outputs of plotweb(). This becomes very
> evident with my actual, very large dataset
>
> require('ape')
> require('bipartite')
> require('ggplotify')
> require('cowplot')
> require('grid')
>
> tree1<-read.tree(text="((A,(B,(C,D))),E);")
> tree1<-ladderize(tree1, right = FALSE)
>
> tree2<-read.tree(text="(F,(G,((H,I),(J,K;")
>
>
> bipartite<-cbind(c(0,2,3,2,0,0),c(2,0,2,4,8,0),c(4,3,0,0,5,0),c(0,2,0,0,0,1),c(0,7,2,2,0,0))
> colnames(bipartite)<-c("D","C","B","A","E")
> rownames(bipartite)<-c("K","J","I","H","G","F")
> bipartite<-as.data.frame(bipartite)
>
> p12 = as.grob(~cophyloplot(tree1, tree2))
> bipartite = as.data.frame(t(bipartite))
> p3 = as.grob(~plotweb(bipartite,
> method = "normal",
> empty = "false",
> text.rot = "90"
> ))
> grid.newpage()
> grid.draw(p12)
> vp = viewport(x = 0.53, y = 0.6, width = 0.6, height = 0.8, angle = -90)
> pushViewport(vp)
> grid.draw(p3)
>
>
> If anyone could direct me on how to proceed, I would greatly appreciate it!
> I have been coming back to this problem for many months now and have not
> been to solve it
>
> [[alternative HTML version deleted]]
>
>
>
>
> --
>
> Subject: Digest Footer
>
> ___
> R-sig-phylo mailing list
> R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>
>
> --
>
> End of R-sig-phylo Digest, Vol 148, Issue 1
> ***

-- 
Jonathan A. Nations

Re: [R-sig-phylo] PGLS-like model proportional data & zero inflation

2019-10-08 Thread jonnations
Hi,

The great package brms has zero and zero-one inflated distributions
available (poisson and beta I believe). There is a phylogenetic vignette
with the package, and you can run those models with any available
distribution.

Jon Nations

On Tue, Oct 8, 2019 at 5:02 AM  wrote:

> Send R-sig-phylo mailing list submissions to
> r-sig-phylo@r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> or, via email, send a message with subject or body 'help' to
> r-sig-phylo-requ...@r-project.org
>
> You can reach the person managing the list at
> r-sig-phylo-ow...@r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-phylo digest..."
>
>
> Today's Topics:
>
>1. PGLS-like model proportional data & zero inflation
>   (Daniel Kissling)
>
> --
>
> Message: 1
> Date: Mon, 7 Oct 2019 16:27:47 +0200
> From: Daniel Kissling 
> To: r-sig-phylo@r-project.org
> Subject: [R-sig-phylo] PGLS-like model proportional data & zero
> inflation
> Message-ID:
>  qo_pjd6f...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
>  Hi R-sig-phylo list members,
>
> does anyone of you know a PGLS-like model that can deal with proportional
> data and with the problems of zero inflation?
>
> I am aware of non-phylogenetic models (e.g. the zero-inflated Poisson (ZIP)
> model, beta-regression for proportional data) to deal with this, but I am
> not aware of similar models for PGLS like analyses.
>
> Any thoughts?
>
> Best
> Daniel Kissling
>
> --
> Dr. W. Daniel Kissling
> Head of Biogeography & Macroecology (BIOMAC) lab
> Associate Professor for Quantitative Biodiversity Science
> Institute for Biodiversity and Ecosystem Dynamics (IBED)
> University of Amsterdam, The Netherlands
> IBED homepage: http://ibed.uva.nl/
> BIOMAC lab: http://biomac.org/
> Personal homepage: www.danielkissling.de
> --
> Currently only working 4 days per week
>
> [[alternative HTML version deleted]]
>
>
>
>
> --
>
> Subject: Digest Footer
>
> ___
> R-sig-phylo mailing list
> R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>
>
> --
>
> End of R-sig-phylo Digest, Vol 141, Issue 3
> ***
>
-- 
Jonathan A. Nations
PhD Candidate
Esselstyn Lab 
Museum of Natural Sciences 
Louisiana State University

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] phylogenetic correction for multiple samples per species along an ecological gradient

2018-08-01 Thread jonnations
You will want to try Bayesian mixed modeling which can handle your species
# problem by using “species” as a group level (i.e. “random”) effect. I
would recommend r packages brms and MCMCglmm and their vignettes. Both have
detailed “phylo” examples.

Maybe check out the r-sig-mixed-model listserv as well. Lots of similar
questions and good advice show up on there.

Good luck!
Jon
-- 
Jonathan A. Nations
PhD Candidate
Esselstyn Lab 
Museum of Natural Sciences 
Louisiana State University

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] Comparing DIC of phylogenetic and non-phylogenetic GLMM run with MCMC (MCMCglmm)

2018-06-21 Thread jonnations
Hi Liam,

I don't have the exact answer you are looking for, but I would highly
recommend the brms package in R. It is incredibly flexible and has
excellent diagnostic tools like LOO and WAIC that are easy to use and
interpret for model selection. I think it would work well for the models
you presented. There is an easy to follow tutorial on phylogenetic mixed
models too.

Also there is another list serve called "r-sig-mixed-models" that you might
be interested in. It's not "phylo" focused, but these sorts of questions
come up on there all the time.

Good luck!
Jon


ps- my first time responding to the list, sorry for any format errors

-- 
Jonathan A. Nations
PhD Candidate
Esselstyn Lab 
Museum of Natural Sciences 
Louisiana State University



>
> Message: 2
> Date: Wed, 20 Jun 2018 19:13:28 +1000
> From: Liam Kendall 
> To: r-sig-phylo@r-project.org
> Subject: [R-sig-phylo] Comparing DIC of phylogenetic and
> non-phylogenetic GLMM run with MCMC (MCMCglmm)
> Message-ID: 
> Content-Type: text/plain; charset="utf-8"
>
> Dear all,
>
> I am conducting an analysis predicting insect body sizes using a
> co-varying trait and their biogeographic region within two model
> formulations using MCMCglmm.
>
> The first model has the structure: log(Weight) ~ log(Trait)+ Biogeography
> + Family (i.e. Taxonomic family of species)
>
> The second model has the structure: log(Weight) ~ log(Trait)+ Biogeography
> + (1|Species/Animal), pedigree = phylogeny, i.e. variance between species
> is constrained by the branch lengths between the species.
>
> The aim of running these two models is compare which is more predictive
> and to increase usability: Including family is user-friendly (and easy for
> the end user, especially if they’re not a taxonomist) whereas the
> phylogenetic model is more attractive theoretically however from a
> predictive sense requires your species of interest to be contained within
> the phylogeny used to fit the model,
>
> Therefore, my question is how best can I compare these two models in model
> selection? Can I compare them directly by their DIC weighting if the only
> difference is the phylogenetic random term? Or is there be a better way to
> compare them? So far, we are also comparing their performance based off
> k-fold cross validation and RMSE but in the ‘age of AIC’, DIC appears a
> good place to start for model selection.
>
> Any advice would be much appreciated.
>
> Best,
> Liam
>
>
> [[alternative HTML version deleted]]
>
>
>
>
> --
>
> Subject: Digest Footer
>
> ___
> R-sig-phylo mailing list
> R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>
>
> --
>
> End of R-sig-phylo Digest, Vol 125, Issue 9
> ***

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/