[R-sig-ME] genetic distance as covariance matrix through ginverse?
s06mw3 at abdn.ac.uk
Thu Jun 5 11:18:01 CEST 2014
MCMCglmm needs the generalized inverse (your M1) formatted in a specific
way - for example as the "dgCMatrix" class defined in the Matrix package.
Substituting the lines below gets the model to work. NOTE, I had to
substitute "0.00" wherever you had NA in the M matrix in order to invert
it. This is probably not the best practice and maybe some simulations
to determine the sensitivity of your parameter estimates when there is
error (i.e., saying NA=0.00) in your genetic distance matrix.
M1<-ginv(M) #I have also been using M in the model with the same error
dimnames(M1) <- list(c("sp1","sp2","sp3","sp4"),c("sp1","sp2","sp3","sp4"))
M1 <- as(ginv(M), "dgCMatrix")
M1 at Dimnames <- list(c("sp1", "sp2", "sp3", "sp4"), c("sp1", "sp2", "sp3", "sp4"))
Dr. Matthew E. Wolak
School of Biological Sciences
University of Aberdeen
Aberdeen AB24 2TZ
office phone: +44 (0)1224 273255
On 04/06/14 19:33, Dean Castillo wrote:
> I am currently using MCMCglmm to model species ability to cross with one
> another. For most of the datasets species relationships can be defined by a
> phylogeny and I can simply incorporate this information into the model
> using the pedigree or ginverse options.
> I would like to run similar models now but for subspecies/races that do not
> have well defined phylogenies (the questions is identical). I have genetic
> distances for some of the species in these data sets (some I have complete
> pairwise genetic distances, others I only have distances for specific
> species pairs). I have considered making a simple NJ tree based on
> distance matrices and incorporating this "phylogeny" via pedigree or
> ginverse, but this strategy will not work without complete pairwise
> Is there a way to utilize the distance matrix (complete or more sparse)
> directly? Since the genetic distance matrix looks very similar to the
> relationship matrix "A" in the MCMCglmm tutorial and coursenotes I tried
> incorporating it into the model but have run into a few errors.
> Here is the fake data I have been playing around with. Any help would be
> greatly appreciated
> #Genetic Distance Matrix. I have also been replacing NA with 0 but still
> encounter same error
> x <- c( 0.07 ,0.08, 0.11,NA,
> 0.16, NA)
> M <- matrix(0, 4, 4)
> M[lower.tri(M)] <- x
> M <- t(M)
> M[lower.tri(M)] <- x
> dimnames(M) <- list(c("sp1","sp2","sp3","sp4"),c("sp1","sp2","sp3","sp4"))
> #Fake response variable, species ID, and categorical predictor
> # want to run a model for y~ma taking into account species
> #define prior
> prior1=list(R=list(V=p.var/2, n=1), G=list(G1=list(V=p.var/2, n=1)))
> M1<-ginv(M) #I have also been using M in the model with the same error
> dimnames(M1) <- list(c("sp1","sp2","sp3","sp4"),c("sp1","sp2","sp3","sp4"))
> #The error I receive.
> Error in FUN(X[[1L]], ...) :
> trying to get slot "Dim" from an object of a basic class ("matrix") with
> no slots
> [[alternative HTML version deleted]]
> R-sig-mixed-models at r-project.org mailing list
The University of Aberdeen is a charity registered in Scotland, No SC013683.
Tha Oilthigh Obar Dheathain na charthannas clàraichte ann an Alba, Àir. SC013683.
More information about the R-sig-mixed-models