meanFrechet: ~ Function: meanFrechet ~

Description

Compute the Frechet mean

Usage

1
2
meanFrechet(trajLong, timeScale = 0.1, FrechetSumOrMax = "sum",
   aggregationMethod = "all", shuffle = TRUE, sampleSize = NA, methodHclust = "average")

Arguments

trajLong

[data.frame]: trajectories in long format. The data.frame has to be (no choice!) in the following format: the first column should be the individual indentifiant. The second should be the times at which the measurement are made. The third one should be the measurements.

timeScale

[numeric]: allow to modify the time scale, increasing or decreasing the cost of the horizontal shift. If timeScale is very big, then the Frechet mean tends to the euclidienne distance. If timeScale is very small, then it tends to the Dynamic Time Warping.

FrechetSumOrMax

[character]: Like Frechet's distance, the Frechet Mean can be define using the 'sum' function or the 'max' function. This option let the user to chose one or the other.

aggregationMethod

[character]: define the agglomerative method used to compute the mean. Three methods are curently available: "all", "sample" and "hierarchical". See detail.

shuffle

[logical]: shall the order of the agglomeration should be randomly chosen? (only for methods "all" and "sample")

sampleSize

[integer]: define the size of the sample (for method 'sample' only).

methodHclust

[character]: define the distance between two clusters used by the hierarchical clustering. The methods available are the one usable by the function hclust

Details

Compute the Frechet mean, as define in [1]. The main idea of the algorithm is the following:

The Frechet mean of two trajectories can be easely define as the middle of the leash that joint the two trajectories (see meanFrechet2). Then the mean of n individual can be obtain by merging the individual trajectories two by two, then merging the resulting trajectories and so on until there is only one trajectory left. This last trajectory is the Frechet mean. Theoriticaly, the final result depend of the order of agglomeration. In practice, on large sample, this order has little impact on the final result (see [1] for detail).

So far, three agglomeration methods are availables:

Value

A data.frame holding a trajectory.

See Also

meanFrechet2, pathFrechet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
require(lattice)

### Define artificial data
g <- function(x)dnorm(0:20,runif(1,5,15),2)*rnorm(1,5,1)
dn <- data.frame(id=rep(1:20,each=21),
   times=rep((0:20),times=20),
   traj=as.numeric(sapply(1:20,g)),
   weight=1
)

xyplot(traj ~ times, data=dn, groups=id,type="l",ylim=c(0,1.4))
plot(meanFrechet(dn),ylim=c(0,1.4))
plot(meanFrechet(dn,0.001),ylim=c(0,1.4))
plot(meanFrechet(dn,10),ylim=c(0,1.4))

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.