online_log_mixture: Create an S4 object to fit the online logistic mixture model

Description Usage Arguments Value See Also Examples

View source: R/1-onlineLogMixture.R

Description

This function allows you to initialize an online logistic regression model. After initialization by providing the model description (in terms of the number of predictors $p$ of each logistic regression model and the number of mixture components $k$) one can use the add.observation method to add observations and update the parameters and call the summary() and plot() methods.

Usage

1
2
online_log_mixture(p, k, beta = matrix(runif(k * p, -1, 1), nrow = k),
  ak = generate_probability_vector(k), ll.window = 500, trace = FALSE)

Arguments

p

Number of predictors for each logistic regression model

k

Number of mixture components

beta

A $k$ by $p$ matrix with the true regression coefficients for each mixture component

ak

A vector of length $k$ summing to 1 for the mixture probabilties

ll.window

The length of the (lagged) mean log-likelihood window

trace

Whether or not the parameter estimates and the lagged mean log likelihood should be traced can be set to an integer, $x > 0$, and it will store a snapshot every x-th datapoint. WARINING: when using trace=1 the object grows large very quickly

Value

An object of class "online_log_mixture" The object contains the following slots:

params

A list containing all the parameters of the model. Contains the objects beta, Sak, n

descriptives

A list containing the (lagged) mean log-likelihood, the max log-likelihood, and the AIC and BIC approximations

trace

A list containing the trace of each of the parameters

See Also

For more detailed examples see add_observation

Examples

1
2
online_log_mixture(3,2)
online_log_mixture(2,4, ak=c(.1,.2,.3,.4), trace=100)

MKaptein/ofmlr documentation built on Sept. 25, 2020, 11:46 a.m.