# Difference between revisions of "R Hackathon 1/ContinuousData"

## Inferring Models for Continuous Characters in R

Introductory material on continuous models: Brownian motion (BM), Pagel transformations, Ornstein-Uhlenbeck models.

## A Note about Multiple Implementations of these Methods

Currently, there are multiple implementations of several of these models across different packages. The results are not always the same across methods, however, because either the purpose of the analysis is slightly different across packages, or the implementations use different computational strategies. The models that currently have multiple implementations as of this writing (13 December 2007) are (i) Brownian motion and (ii) Orstein-Uhlenbeck with one optimum.

Brownian motion

Currently, there are three packages that implement inference of the BM model: ape in function ace(), geiger in function fit.continuous(), and ouch in function brown.fit(). The function ace() will return a log-likelihood and a parameter estimate for the BM model, but these are conditional upon the reconstructed trait values of the nodes. This is consistent with the main purpose of ace(), which is to reconstruct ancestral trait values. However, this log-likelihood and BM parameter are not comparable with other model fitting results, which are not conditioned on particular trait values for internal nodes. Thus, unless your main focus is on ancestral reconstructions, you should probably be using the functions in either geiger or ouch to fit the BM model.

The functions in geiger and ouch share the approach of not conditioning the model fits on particular values at ancestral nodes. However, although the log-likelihoods and rate estimates tend to be similar across these two packages, they are not the same. This difference seems to result from the different computational strategies used in the functions: fitContinuous() in geiger directly maximizes the likelihood, while brown.fit() in ouch uses generalized least-squares (GLS) to solve for the rate parameter and the log-likelihood. In principle, GLS and ML should approach the same solution, but algorithmic differences will cause the solutions to differ (Check with Marguerite on this).

Orstein-Uhlenbeck