R: An R6 Class to represent a collection of PLNfit

PLNfamily {PLNmodels} | R Documentation

## An R6 Class to represent a collection of PLNfit

### Description

super class for `PLNPCAfamily` and `PLNnetworkfamily`. The R6 class benefits from S3 methods such as `getBestModel()`, `getModel()` and `plot()`.

### Details

The parameter `control` is a list controlling the optimization with the following entries:

- "covariance" character setting the model for the covariance matrix. Either "full", "diagonal" or "spherical". Default is "full".

- "trace" integer for verbosity.

- "inception" Set up the initialization. By default, the model is initialized with a multivariate linear model applied on log-transformed data, and with the same formula as the one provided by the user. However, the user can provide a PLNfit (typically obtained from a previous fit), which sometimes speeds up the inference.

- "ftol_rel" stop when an optimization step changes the objective function by less than ftol multiplied by the absolute value of the parameter. Default is 1e-6 when n < p, 1e-8 otherwise.

- "ftol_abs" stop when an optimization step changes the objective function by less than ftol multiplied by the absolute value of the parameter. Default is 0

- "xtol_rel" stop when an optimization step changes every parameters by less than xtol multiplied by the absolute value of the parameter. Default is 1e-4

- "xtol_abs" stop when an optimization step changes every parameters by less than xtol multiplied by the absolute value of the parameter. Default is 0

- "maxeval" stop when the number of iteration exceeds maxeval. Default is 10000

- "maxtime" stop when the optimization time (in seconds) exceeds maxtime. Default is -1 (no restriction)

- "algorithm" the optimization method used by NLOPT among LD type, i.e. "CCSAQ", "MMA", "LBFGS", "VAR1", "VAR2". See NLOPT documentation for further details. Default is "CCSAQ".

### Public fields

`responses`

  the matrix of responses common to every models

`covariates`

  the matrix of covariates common to every models

`offsets`

  the matrix of offsets common to every models

`weights`

  the vector of observation weights

`inception`

  a PLNfit object, obtained when no sparsifying penalty is applied.

`models`

  a list of PLNfit object, one per penalty.

### Active bindings

`criteria`

  a data frame with the values of some criteria (approximated log-likelihood, BIC, ICL, etc.) for the collection of models / fits BIC and ICL are defined so that they are on the same scale as the model log-likelihood, i.e. with the form, loglik - 0.5 penalty

`convergence`

  sends back a data frame with some convergence diagnostics associated with the optimization process (method, optimal value, etc)

### Methods

#### Public methods

- `PLNfamily$new()`

- `PLNfamily$postTreatment()`

- `PLNfamily$getModel()`

- `PLNfamily$plot()`

- `PLNfamily$show()`

- `PLNfamily$print()`

- `PLNfamily$clone()`

#### Method `new()`

Create a new `PLNfamily` object.

##### Usage

    PLNfamily$new(responses, covariates, offsets, weights, control)

##### Arguments

`responses`

  the matrix of responses common to every models

`covariates`

  the matrix of covariates common to every models

`offsets`

  the matrix of offsets common to every models

`weights`

  the vector of observation weights

`control`

  a list for controlling the optimization. See details.

##### Returns

A new `PLNfamily` object

#### Method `postTreatment()`

Update fields after optimization

##### Usage

    PLNfamily$postTreatment()

#### Method `getModel()`

Extract a model from a collection of models

##### Usage

    PLNfamily$getModel(var, index = NULL)

##### Arguments

`var`

  value of the parameter (`rank` for PLNPCA, `sparsity` for PLNnetwork) that identifies the model to be extracted from the collection. If no exact match is found, the model with closest parameter value is returned with a warning.

`index`

  Integer index of the model to be returned. Only the first value is taken into account.

##### Returns

A `PLNfit` object

#### Method `plot()`

Lineplot of selected criteria for all models in the collection

##### Usage

    PLNfamily$plot(criteria, reverse)

##### Arguments

`criteria`

  A valid model selection criteria for the collection of models. Includes loglik, BIC (all), ICL (PLNPCA) and pen_loglik, EBIC (PLNnetwork)

`reverse`

  A logical indicating whether to plot the value of the criteria in the "natural" direction (loglik - penalty) or in the "reverse" direction (-2 loglik + penalty). Default to FALSE, i.e use the natural direction, on the same scale as the log-likelihood.

##### Returns

A `ggplot2` object

#### Method `show()`

User friendly print method

##### Usage

    PLNfamily$show()

#### Method `print()`

User friendly print method

##### Usage

    PLNfamily$print()

#### Method `clone()`

The objects of this class are cloneable with this method.

##### Usage

    PLNfamily$clone(deep = FALSE)

##### Arguments

`deep`

  Whether to make a deep clone.

### See Also

`getModel()`

[Package PLNmodels version 0.11.4 Index]