| kmlShape {kmlShape} | R Documentation |
This function run k-means for longitudinal data using some shape respecting distance and mean.
kmlShape(myClds, nbClusters = 3, timeScale = 0.1, FrechetSumOrMax = "max", toPlot="both", parAlgo=parKmlShape())
myClds |
[ |
nbClusters |
[ |
timeScale |
[ |
FrechetSumOrMax |
[ |
toPlot |
[ |
parAlgo |
[ |
This function run k-means for longitudinal data using a shape
respecting distance (distFrechet) and a shape
respecting mean (meanFrechet). See [1] for details.
An object of class Clds in which the field
'clustersSenators', 'clusters' and 'trajMeans' are now filled.
###########
### Example
### Generating artificial data
nbLignes <- 20
trajG <- matrix(0,nbLignes,10)
for(i in 1:(nbLignes/2)){
trajG[i,] <- dnorm(1:10,runif(1,3,8),1)*rnorm(1,10,0.1)
}
for(i in (nbLignes/2+1):nbLignes){
trajG[i,] <- dnorm(1:10,runif(1,3,8),1)*rnorm(1,5,0.1)
}
myClds <- cldsWide(data.frame(1:20,trajG))
plot(myClds)
### kmlshape
par(ask=FALSE)
kmlShape(myClds,2)
par(ask=TRUE)
plot(myClds)
###########
### Example 2
### Generating artificial data
nbLignes <- 12
trajH <- matrix(0,nbLignes,10)
for(i in 1:(nbLignes/3)){
trajH[i,] <- pnorm(1:10,runif(1,3,8),1)*rnorm(1,10,1)
}
for(i in (nbLignes/3+1):(2*nbLignes/3)){
trajH[i,] <- dnorm(1:10,runif(1,3,8),1)*rnorm(1,13,1)
}
for(i in (2*nbLignes/3+1):nbLignes){
trajH[i,] <- pnorm(1:10,runif(1,3,8),1)*rnorm(1,5,0.1)
}
myClds2 <- cldsWide(data.frame(1:60,trajH))
plot(myClds2)
### kmlshape
par(ask=FALSE)
kmlShape(myClds2,3)
par(ask=TRUE)
plot(myClds2)