Re: [R-sig-phylo] Accounting for phylogeny in binary predictor, binary response data

2016-02-10 Thread Joe Felsenstein
I have received phishing spam through the R-sig-phylo mailing list
(pretending I had expressed interest in renting something from them) from

anya_phill...@casetotours.xyz

disguised as a reply to my comment.  So that address should immediately be
removed from the list.

Joe
-
j...@gs.washington.edu
Joe Felsenstein, Department of Genome Sciences and Department of Biology
Box 355065, University of Washington, Seattle, WA  98195-5065

[[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] Accounting for phylogeny in binary predictor, binary response data

2016-02-10 Thread Jörg Albrecht
Dear Grace,

the problem may derive from your specification of the priors. Usually you don’t 
specify the prior for B in MCMCglmm. The problem may also be related to the 
size of your dataset. Estimation of effects can be difficult with binary data, 
when the dataset is small. Below is a small example from Jarrod Hadfield for 
binary regression that accounts for phylogeny.


tree <- rcoal(200)
x <- rnorm(200)
l <- rbv(tree, 1, nodes="TIPS") + x + rnorm(200)
y <- rbinom(200, 1, plogis(l))
dat <- data.frame(y = y, x = x, species = tree$tip.label)
prior1 <- list(R = list(V = 1, fix = 1),
   G = list(G1 = list(V = 1, nu = 1, alpha.mu = 0, alpha.V = 1000)))
# residual variance fixed at 1.
Ainv <- inverseA(tree)$Ainv
m1 <- MCMCglmm(y ~ x, random = ~ species,
   ginverse = list(species = Ainv),
   family = "categorical",
   prior = prior1, data = dat)
# fixed effects should be around zero and one (+/- monte carlo error)
summary(m1$Sol)
# phylogenetic ICC should be 1/(2 + pi^2/3) = 0.189 (+/- monte carlo error)
summary(m1$VCV[, 1] / (rowSums(m1$VCV) + pi^2/3))

Hope this helps,

Jörg

—
Jörg Albrecht, PhD
Postdoctoral researcher
Institute of Nature Conservation
Polish Academy of Sciences
Mickiewicza 33
31-120 Krakow, Poland
www.carpathianbear.pl 
www.globeproject.pl 
www.iop.krakow.pl 
> Am 10.02.2016 um 00:55 schrieb Grace Pold :
> 
> Hello,
> 
> I have characterized a few hundred bacteria from two environments and want to 
> know if the bacteria from one environment is more likely to show a trait than 
> the bacteria isolated from the other environment. So my data is binary in 
> both the independent and in the dependent variable: "environment 1?" yes/no, 
> and "degrades carbon source?" yes/no. If I wasn’t accounting for phylogeny, I 
> think I would use a Chi-Squared test. But I would like to account for 
> phylogeny in my analysis, since some of the bacteria form clusters on my 
> phylogenetic tree with members only from one environment. 
> 
> I thought maybe I could use MCMCglmm to test this, and have been following 
> the examples previously posted on r-sig-phylo and in the MCMCglmm course 
> notes. However, my model either fails to converge even after millions of 
> iterations, or the autocorrelation plot shows strong positive correlations at 
> a range of lags. So I think either I cannot use MCMCglmm for this, or I am 
> specifying my model wrong. Any pointers in the right direction would be 
> greatly appreciated. 
> 
> Here is my model:
> 
> prior.m2c.5 = list(B = list(mu = c(0, 0), V = diag(2) *(1 + pi^2/3)), R = 
> list(V = 1, fix = 1), G = list(G1 = list(V = 1, nu = 1, alpha.mu = 0, alpha.V 
> = 1000)))
> 
> simplemcmcCMCv2_5<-MCMCglmm(carbon01~environment01, random=~animal, 
> pedigree=ctree, data=wcboth, family="categorical”, nitt=1000, 
> burnin=10,thin=2000, prior=prior.m2c.5)   
> 
> Thank you in advance for any help,
> 
> Grace Pold
> 
> Graduate Program in Organismic and Evolutionary Biology
> University of Massachusetts, Amherst
>   [[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/
> 


[[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] Accounting for phylogeny in binary predictor, binary response data

2016-02-10 Thread Brian O'Meara
There's also corDISC in corHMM (disclosure: I'm a coauthor on the package).
It does Pagel 1994 with two or three binary characters, allows for user set
root states (I believe the canonical Pagel (1994) assumes equal freq at the
root, I don't know if phytools uses this same assumption [a lot of programs
assume equilibrium freq]), and allows additional control over the rate
matrix. However, it requires you to specify what sort of rate matrix you
want (has equal rates, all rate different, etc., but you would have to
specify the dependent model matrix): the phytools code seems to loop over
the named Pagel matrices, which are a subset of the possible matrices. So,
I'd summarize it as phytools being more turnkey, corHMM having more control
but less easy to use.

Oh, and in either case, read this and be afraid before starting analyses:
Maddison & FitzJohn, 2014: http://sysbio.oxfordjournals.org/content/64/1/127
.

Best,
Brian

___
Brian O'Meara
Associate Professor
Dept. of Ecology & Evolutionary Biology
U. of Tennessee, Knoxville
http://www.brianomeara.info

Postdoc collaborators wanted: http://nimbios.org/postdocs/
Calendar: http://www.brianomeara.info/calendars/omeara

On Wed, Feb 10, 2016 at 12:41 PM, Heath Blackmon  wrote:

> Grace,
>
> The package phytools includes a function fitPagel if that is the method
> that you want to use.  He has a post on his blog that discusses his
> implementation so it won't be a black box for you:
>
>
> http://blog.phytools.org/2014/12/r-function-for-pagels-1994-correlation.html
>
> cheers
>
> Heath
>
> On Wed, Feb 10, 2016 at 11:14 AM, Joe Felsenstein 
> wrote:
>
> > I do not know offhand whether there is an R implementation, but how about
> > Mark Pagel's 1994 method for testing whether two 0/1 characters changing
> > along a ohylogeny are changing independently?
> >
> > J.F.
> > -
> > j...@gs.washington.edu
> > Joe Felsenstein, Department of Genome Sciences and Department of Biology
> > Box 355065, University of Washington, Seattle, WA  98195-5065
> >
> > [[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/
> >
>
>
>
> --
> *Heath Blackmon, Ph.D.*
>
> *Postdoctoral Researcher*
> *University of Minnesota*
> *coleoguy.github.io *
> *@coleoguy* 
> *Phone 682-444-0538*
>
> [[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/
>

[[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] Accounting for phylogeny in binary predictor, binary response data

2016-02-10 Thread Alejandro Gonzalez Voyer
Hello,

I agree with Joe that Pagel’s 1994 method might be a good option to analyze the 
data. I would only include a word of caution that the method can be sensitive 
to the sample sizes in each of the states (i.e. 0,0 ; 0,1 ; 1,1 ; 1,0 : 
environment yes/no & degrades carbon yes/no) so you should take this into 
account - if it applies - when interpreting your results.

Cheers

Alejandro
___
Dr Alejandro Gonzalez Voyer

Laboratorio de Conducta Animal
Instituto de Ecología
Circuito Exterior S/N
Ciudad Universitaria
Universidad Nacional Autónoma de México
México, D.F.
04510
México

Tel: +52 55 5622 9044
E-mail: alejandro.gonza...@iecologia.unam.mx
Web: www.alejandrogonzalezvoyer.com

> El 10/02/2016, a las 11:41, Heath Blackmon  escribió:
> 
> Grace,
> 
> The package phytools includes a function fitPagel if that is the method
> that you want to use.  He has a post on his blog that discusses his
> implementation so it won't be a black box for you:
> 
> http://blog.phytools.org/2014/12/r-function-for-pagels-1994-correlation.html
> 
> cheers
> 
> Heath
> 
> On Wed, Feb 10, 2016 at 11:14 AM, Joe Felsenstein 
> wrote:
> 
>> I do not know offhand whether there is an R implementation, but how about
>> Mark Pagel's 1994 method for testing whether two 0/1 characters changing
>> along a ohylogeny are changing independently?
>> 
>> J.F.
>> -
>> j...@gs.washington.edu
>> Joe Felsenstein, Department of Genome Sciences and Department of Biology
>> Box 355065, University of Washington, Seattle, WA  98195-5065
>> 
>>[[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/
>> 
> 
> 
> 
> -- 
> *Heath Blackmon, Ph.D.*
> 
> *Postdoctoral Researcher*
> *University of Minnesota*
> *coleoguy.github.io *
> *@coleoguy* 
> *Phone 682-444-0538*
> 
>   [[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/


[[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] Accounting for phylogeny in binary predictor, binary response data

2016-02-10 Thread Heath Blackmon
Grace,

The package phytools includes a function fitPagel if that is the method
that you want to use.  He has a post on his blog that discusses his
implementation so it won't be a black box for you:

http://blog.phytools.org/2014/12/r-function-for-pagels-1994-correlation.html

cheers

Heath

On Wed, Feb 10, 2016 at 11:14 AM, Joe Felsenstein 
wrote:

> I do not know offhand whether there is an R implementation, but how about
> Mark Pagel's 1994 method for testing whether two 0/1 characters changing
> along a ohylogeny are changing independently?
>
> J.F.
> -
> j...@gs.washington.edu
> Joe Felsenstein, Department of Genome Sciences and Department of Biology
> Box 355065, University of Washington, Seattle, WA  98195-5065
>
> [[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/
>



-- 
*Heath Blackmon, Ph.D.*

*Postdoctoral Researcher*
*University of Minnesota*
*coleoguy.github.io *
*@coleoguy* 
*Phone 682-444-0538*

[[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] Accounting for phylogeny in binary predictor, binary response data

2016-02-10 Thread Joe Felsenstein
I do not know offhand whether there is an R implementation, but how about
Mark Pagel's 1994 method for testing whether two 0/1 characters changing
along a ohylogeny are changing independently?

J.F.
-
j...@gs.washington.edu
Joe Felsenstein, Department of Genome Sciences and Department of Biology
Box 355065, University of Washington, Seattle, WA  98195-5065

[[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] Accounting for phylogeny in binary predictor, binary response data

2016-02-10 Thread Anthony R. Ives
Grace,

Maybe this easiest thing to do is just try phylogenetic logistic regression, 
which is appropriate for binary dependent variables regardless of the form of 
the independent variables. You can use phyloglm in the phylolm package, or 
binaryPGLMM in the ape package.

Cheers, Tony




On 2/9/16, 5:55 PM, "R-sig-phylo on behalf of Grace Pold" 
 wrote:

>Hello,
>
>I have characterized a few hundred bacteria from two environments and want to 
>know if the bacteria from one environment is more likely to show a trait than 
>the bacteria isolated from the other environment. So my data is binary in both 
>the independent and in the dependent variable: "environment 1?" yes/no, and 
>"degrades carbon source?" yes/no. If I wasn’t accounting for phylogeny, I 
>think I would use a Chi-Squared test. But I would like to account for 
>phylogeny in my analysis, since some of the bacteria form clusters on my 
>phylogenetic tree with members only from one environment. 
>
>I thought maybe I could use MCMCglmm to test this, and have been following the 
>examples previously posted on r-sig-phylo and in the MCMCglmm course notes. 
>However, my model either fails to converge even after millions of iterations, 
>or the autocorrelation plot shows strong positive correlations at a range of 
>lags. So I think either I cannot use MCMCglmm for this, or I am specifying my 
>model wrong. Any pointers in the right direction would be greatly appreciated. 
>
>Here is my model:
>
>prior.m2c.5 = list(B = list(mu = c(0, 0), V = diag(2) *(1 + pi^2/3)), R = 
>list(V = 1, fix = 1), G = list(G1 = list(V = 1, nu = 1, alpha.mu = 0, alpha.V 
>= 1000)))
>
>simplemcmcCMCv2_5<-MCMCglmm(carbon01~environment01, random=~animal, 
>pedigree=ctree, data=wcboth, family="categorical”, nitt=1000, 
>burnin=10,thin=2000, prior=prior.m2c.5)   
>
>Thank you in advance for any help,
>
>Grace Pold
>
>Graduate Program in Organismic and Evolutionary Biology
>University of Massachusetts, Amherst
>   [[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 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] Accounting for phylogeny in binary predictor, binary response data

2016-02-10 Thread Grace Pold
Hello,

I have characterized a few hundred bacteria from two environments and want to 
know if the bacteria from one environment is more likely to show a trait than 
the bacteria isolated from the other environment. So my data is binary in both 
the independent and in the dependent variable: "environment 1?" yes/no, and 
"degrades carbon source?" yes/no. If I wasn’t accounting for phylogeny, I think 
I would use a Chi-Squared test. But I would like to account for phylogeny in my 
analysis, since some of the bacteria form clusters on my phylogenetic tree with 
members only from one environment. 

I thought maybe I could use MCMCglmm to test this, and have been following the 
examples previously posted on r-sig-phylo and in the MCMCglmm course notes. 
However, my model either fails to converge even after millions of iterations, 
or the autocorrelation plot shows strong positive correlations at a range of 
lags. So I think either I cannot use MCMCglmm for this, or I am specifying my 
model wrong. Any pointers in the right direction would be greatly appreciated. 

Here is my model:

prior.m2c.5 = list(B = list(mu = c(0, 0), V = diag(2) *(1 + pi^2/3)), R = 
list(V = 1, fix = 1), G = list(G1 = list(V = 1, nu = 1, alpha.mu = 0, alpha.V = 
1000)))

simplemcmcCMCv2_5<-MCMCglmm(carbon01~environment01, random=~animal, 
pedigree=ctree, data=wcboth, family="categorical”, nitt=1000, 
burnin=10,thin=2000, prior=prior.m2c.5)   

Thank you in advance for any help,

Grace Pold

Graduate Program in Organismic and Evolutionary Biology
University of Massachusetts, Amherst
[[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/