Learn R Programming

rEMM (version 0.1-2)

build: Building an EMM using New Data

Description

Add new data to an EMM.

Usage

build(x, newdata, ...)
reset(x)

Arguments

x
an EMM object.
newdata
a vector (one observation), or a matrix or data.frame (each row is an observation)
...
further arguments. If newdata is a matrix or a data.frame verbose = TRUE can be used to monitor the progress of building the model.

Value

  • A new EMM object with the data added.

Details

For build() the dissimilarity between the new observation and the centers of the clusters is calculated. The new observation is assigned to the closest cluster if the dissimilarity value is smaller than the threshold (for the state). If no such state exists, a new state is created for the observation. This simple clustering algorithm is called nearest neighbor threshold nearest neighbor (threshold NN).

After clustering, the EMM is updated. An edge with weight 1 from the current state to the new state (determined by the chosen cluster) is added. If this edge already existed, the weight is incremented by one. The new state becomes the current state.

NAs are handled in the data by using only the other dimensions if the data for dissimilarity computation (see package~proxy).

reset resets the current state to NA for reading in a new sequence. A row of all NA in newdata for build also resets the current state.

See Also

Class "EMM", fade and dist in proxy.

Examples

Run this code
## load EMMTraffic data
data("EMMTraffic")
EMMTraffic

## create EMM
emm <- EMM(measure="eJaccard", threshold=0.2)

## build model using EMMTraffic data
emm <- build(emm, EMMTraffic)

size(emm)
plot(emm, method = "graph") ## plot needs Rgraphviz installed

Run the code above in your browser using DataLab