Learn R Programming

goldfish (version 1.6.10)

examine: Diagnostic functions

Description

Provide diagnostic functions for an object of class result.goldfish. outliers helps to identify outliers events. changepoints helps to identify where a change point in the events sequence is presented using the log-likelihood.

Usage

examineOutliers(
  x,
  method = c("Hampel", "IQR", "Top"),
  parameter = 3,
  window = NULL
)

examineChangepoints( x, moment = c("mean", "variance"), method = c("PELT", "AMOC", "BinSeg"), window = NULL, ... )

Value

NULL if neither outliers nor change points are identified. An object of class ggplot object from a call of ggplot2::ggplot(). It can be modified using the ggplot2 syntax.

Arguments

x

an object of class result.goldfish output from an estimate call.

method

Choice of "AMOC", "PELT" or "BinSeg". For a detail description see cpt.mean or cpt.var. The default value is "PELT".

parameter

An integer that represents the number of absolute outliers to identify, the threshold for the Hampel filter, i.e. parameter * MAD, or the threshold beyond the interquartile range halved, i.e. parameter/2 * IQR.

window

The window half-width for the Hampel filter. By default it is half the width of the event sequence.

moment

character argument to choose between "mean" or "variance". See section Change point for details.

...

additional arguments to be passed to the functions in the changepoint package.

Outliers

examineOutliers creates a plot with the log-likelihood of the events in the y-axis and the event index in the x-axis, identifying observations with labels indicating the sender and recipient.

Change point

The parameter moment controls which method from the package changepoint is used:

"mean"

It uses the cpt.mean function to investigate optimal positioning and (potentially) number of change points for the log-likelihood of the events in mean.

"variance"

It uses the cpt.var function to investigate optimal positioning and (potentially) number of change points for the log-likelihood of the events in variance

The function call creates a plot with the log-likelihood of the events in the y-axis and the event index in the x-axis, highlighting the change point sections identified by the method.

Examples

Run this code
# A multinomial receiver choice model
data("Social_Evolution")
callNetwork <- defineNetwork(nodes = actors, directed = TRUE)
callNetwork <- linkEvents(
  x = callNetwork, changeEvent = calls,
  nodes = actors
)
callsDependent <- defineDependentEvents(
  events = calls, nodes = actors,
  defaultNetwork = callNetwork
)
# \dontshow{
callsDependent <- callsDependent[1:50, ]
# }
mod01 <- estimate(callsDependent ~ inertia + recip + trans,
  model = "DyNAM", subModel = "choice",
  estimationInit = list(
    returnIntervalLogL = TRUE,
    engine = "default_c"
  )
)

examineOutliers(mod01)

examineChangepoints(mod01)

Run the code above in your browser using DataLab