Description Usage Arguments Value Author(s) Examples
View source: R/gap_statistic.R
Computing within cluster dissimilarity for different numbers of cluster k and the Gap statistic.
1 2 | gap_statistic(dist, kseq, steps, lambda = .7, bezier = NULL,
xcor = c(0,1,-1), ycor = c(0,1.5,1.5))
|
dist |
p x p distance matrix, where p is the number of trajectories. |
kseq |
A sequence of cluster sized, for which the within cluster dissimilarity should be computed |
steps |
The number of data points on the generated trajectories. |
lambda |
Lambda parameter of the exponential distribution, from which the parameters for the Bezier curve are drawn, which we use to generate trajectories. To get a feel for this parameter, try out values and look at the generated data. |
bezier |
Provide a custom sequence of Bezier curve parameters. |
xcor |
x-coordinates of the start point, the non-selected box and the end-point in that order. |
ycor |
y-coordinates of the start point, the non-selected box and the end-point in that order. |
The function returns a list:
WCD_data |
Within cluster dissimilarity for each k for the real data. |
WCD_syn |
Within cluster dissimilarity for each k for the generated data. |
Gaps |
The difference values of |
cl_data |
Cluster assignments for each k |
cl_syn |
Cluster assignments for each k and the generated data |
Jonas Haslbeck <jonashaslbeck@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
# Example data
head(data_sp2015)
# Preprocess Data
stre <- list("start"=c(0,0), "left"=c(-1,1.5), "right"=c(1,1.5))
steps <- 5
data_pr <- prepr(data_sp2015, i.xyt = c('x', 'y', 't'), i.id=c('id.ptp', 'id.trial'),
type='spatial', stretch = stre, steps = steps)$data
data_pr$x[data_pr$chosen.box==1] <- data_pr$x[data_pr$chosen.box==1] * -1 # all endpoints to one side
# Compute distance matrix
id <- 1:1344 # no of unique trials
dist <- mta:::distmat(id, data_pr$x , data_pr$y, steps)
# Call Gap statistic function
gapobj <- gap_statistic(dist, kseq=1:10, steps=5)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.