quickfit: Quick fit of one-step migration

Description Usage Arguments Details Value Examples

View source: R/quickfit.r

Description

Using k-means clustering to get quick fits of 2 or 3 cluster centers in X-Y coordinates.

Usage

1
quickfit(T, X, Y, dt = 1, n.clust = 2, plotme = TRUE)

Arguments

T

time

X

x coordinate of movement

Y

y coordinate of movement

dt

duration of migration (arbitrarily = 1)

n.clust

number of clusters (2 or 3)

plotme

whether or not to plot the result

Details

This function does estimates the locations and times of migration, but not the duration (dt). It is most useful for obtaining a "null" estimate for seeding the likelihood estimation.

Value

a named vector of initial estimates:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require(marcher)

## Load simulated data
data(SimulatedTracks)

# plot the MOU simulation
scan_track(MOU.sim)

# quick fit - setting dt = 10
(pm.0 <- with(MOU.sim, quickfit(T, X, Y, dt = 10)))

# interactive locator process
if(interactive()){
 (with(MOU.sim, locate_shift(T, X, Y)))
}

# fit the model
fit <- with(MOU.sim, estimate_shift(T, X, Y))

## Three cluster example

# plot the three range shift simulation
scan_track(MOU.3range)

# quick fit 
## (note - this may not always work!)
with(MOU.3range, quickfit(T, X, Y, dt = 10, n.clust = 3))

if(interactive()){
  with(MOU.3range, locate_shift(T, X, Y, n.clust = 3))
}

EliGurarie/marcher documentation built on Oct. 17, 2020, 3:55 a.m.