Hi Antonella,

It could be that the optimization procedure of the log-likelihood fails with your data, or that this procedure tries some values of lambda that return an error in your situation.

You may try to fit successive models with different values of lambda, and select the model with the largest log-likelihood. Something like:

lambda <- seq(0, 1, 0.1)
fit <- list()

form <- Gst ~ log.Body_size + Diet+Behavior + Max_Geo + He

for (i in seq_along(lambda)) {
    cor <- corPagel(lambda[i], phy = gls.phylo1, fixed = TRUE)
fit[[i]] <- gls(form, correlation = cor, data = data, na.action = na.exclude, method = "ML")
}

## get the log-lik from each fit:
sapply(fit, logLik)

You may then do which.min() on the output of the last command or plot this output with respect to lambda. You may also change the values in this last vector to better suits your needs.

Please keep in mind that with this procedure, lambda is a free parameter (which will not be indicated in the outputs from gls): this might be important if you compare models.

Best,

Emmanuel

Le 02/11/2015 18:29, Antonella Soro a écrit :
dear all,

like kari allen in june 2011, i am trying to "to run Pagels GLS in R and I have 
consistently encountered
an error message (see script and error message below). When I fix the
lambda value to 0 or 1, I do get a result, but when I let lambda vary
(ie. set "fixed=F" instead of "fixed=T"), I get an error message. Any ideas?
"

pagel.data<-corPagel(1,phy=gls.phylo1,fixed=FALSE)
pagel.gls8<-gls(Gst~log.Body_size+Diet+Behavior+Max_Geo+He,correlation=pagel.data,data=data,na.action=na.exclude,
 method="ML")

Error in corFactor.corStruct(object) :
   NA/NaN/Inf in foreign function call (arg 1)

i could not find any answer to kari's post.

any help is very much appreciated

thank you very much

antonella

_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/

Reply via email to