reduceNbId: ~ Function: reduceNbId ~

Description Usage Arguments Details Value Examples

View source: R/reduceTraj.R

Description

This function 'summerize' a (big) population in a smaller groups of individual. Hopefully, the smaller groups will have the same properties than the whole population. The trajectories of the smaller groups are called the 'senator' (since they are representing the whole population). The 'election' is done using the classical k-means algorithm. The trajectories should be in 'wide' format.

Usage

1
reduceNbId(id, trajWide, nbSenators = 64, imputationMethod = "linearInterpol")

Arguments

id

[vector(factor)]: unique identifier for each trajectories.

trajWide

[data.frame]: data.frame that hold the trajectories (in wide format).

nbSenators

[integer] number of trajectories that will be use to represent the population (i.e., number of clusters used by k-means).

imputationMethod

[character]: Method that will be used to impute the missing values.

Details

This function 'summerize' a (big) population in a smaller groups of individual. Hopefully, the smaller groups will have the same properties than the whole population. The trajectories of the smaller groups are called the 'senator' (since they are representing the whole population). The 'election' is done using the classical k-means algorithm. The trajectories should be in 'wide' format.

Value

A list with three fields:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  par(mfrow=c(1,3))
  ### Some artificial data
  myTraj <- t(sapply(1:1000,function(x)dnorm(1:200,runif(1,50,150),20)*rnorm(1,10,2)))
  matplot(t(myTraj),type="l",ylim=c(0,0.33))

  ### Election of 64 senator
  ### All individual is closed to one senators. Senators are representatives.
  election64 <- reduceNbId(id=1:1000,myTraj,nbSenators=64)
  matplot(t(election64$senatorsWide[,-1]),type="l",ylim=c(0,0.33))

  ### Election of 4 senators. They are not representatives.
  election4 <- reduceNbId(id=1:1000,myTraj,nbSenators=4)
  matplot(t(election4$senatorsWide[,-1]),type="l",ylim=c(0,0.33))

kmlShape documentation built on May 29, 2017, 10:19 a.m.