Learn R Programming

paleoTS (version 0.5-1)

fitGpunc: Analyze evolutionary models with unsampled punctuations

Description

Functions required to fit evolutionary models with puntuations that are rapid relative to the temporal spacing of samples (so-called unsampled punctuations).

Usage

fitGpunc(y, ng = 2, minb = 7, pool = TRUE, oshare = TRUE, method=c('Joint', 'AD'), 
         silent = FALSE, hess=FALSE, parallel = FALSE, ...)
         
opt.punc(y, gg, cl = list(fnscale = -1), pool = TRUE, meth = "L-BFGS-B", 
         hess = FALSE, oshare)
opt.joint.punc(y, gg, cl=list(fnscale=-1), pool=TRUE, meth="L-BFGS-B", 
               hess=FALSE, oshare)
logL.punc(p, y, gg)
logL.punc.omega(p, y, gg)
logL.joint.punc(p, y, gg)
logL.joint.punc.omega(p, y, gg)

Arguments

y

a paleoTS object

ng

the number of separate segments in the sequence

minb

the minimum number of samples within a segment to consider

pool

logical indicating whether to pool variances across samples

oshare

logical, if TRUE, the same variance (omega) is assumed across all segments. If FALSE, separate variances are assumd for each segment

method

parameterization to use: based on ancestor-descendant (AD) differences, or on Joint consideration of all samples

silent

if TRUE, less information is printed to the screen as the model is fit

hess

if TRUE, standard errors are computed from the Hessian matrix

parallel

logical, if TRUE, the analysis is parallelized using foreach

other arguments to send to opt.punc

p

parameters of the punctuation model to be optimized

gg

numeric vector indicating membership of each sample in segments 1, 2, .. ng

cl

control list to be passed to optim

meth

optimization method, to be passed to optim

Value

The log-likelihood functions return the log-likelihood of the model for a given set of parameter values (p), assuming that the periods of Stasis have the same variance (logL.punc.omega) or different variances (logL.punc).

Functions fitGpunc and opt.punc return a paleoTSfit object.

In addition, the paleoTSfit object returned by function fitGpunc has the following additional elements:

all.logl

log-likelihoods for all tested partitions of the series into segments

GG

matrix of indices of initial samples of each tested segment configuration; each column of GG corresponds to the elements of all.logl

Details

These functions are used to fit a model with an unsampled punctuation. It is equivalent to a Stasis model in which the optimum instantaneously shifts at one or more points in time; see references below for details. Users are likely only to use fitGpunc, which will calls the other functions in order to find the best parameter estimates and shift points for the segments.

The parallel option uses doParallel and foreach. It detects the number of available cores and uses that number minus one for the parallelization.

References

Hunt, G. 2006. Fitting and comparing models of phyletic evolution: random walks and beyond. Paleobiology 32:578--601. Hunt, G. 2008. Gradual or pulsed evolution: when should punctuational explanations be preferred? Paleobiology 34:360--377.

See Also

sim.punc, opt.GRW, fit.sgs

Examples

Run this code
# NOT RUN {
x<- sim.punc(theta=c(0,5), ns=c(20,20), omega=c(0.5,0.5), vp=0.2)
w<- fitGpunc(x, ng=2, minb=7, pool=TRUE, oshare=TRUE)
print (w$parameters)
## plot using modelFit argument to show the solution
plot(x, modelFit=w)

## now, plot logL with respect to shift point
shift.times<- x$tt[w$GG]
plot(shift.times, w$all.logl, typ="o", cex=0.5, 
     main="Log-likelihood of different shift times")

# }

Run the code above in your browser using DataLab