R: An R6 Class to represent a collection of PLNnetworkfit

PLNnetworkfamily {PLNmodels} | R Documentation

## An R6 Class to represent a collection of PLNnetworkfit

### Description

The function `PLNnetwork()` produces an instance of this class.

This class comes with a set of methods, some of them being useful for the user: See the documentation for `getBestModel()`, `getModel()` and plot()

### Super class

`PLNmodels::PLNfamily` -> `PLNnetworkfamily`

### Active bindings

`penalties`

  the sparsity level of the network in the successively fitted models

`stability_path`

  the stability path of each edge as returned by the stars procedure

`stability`

  mean edge stability along the penalty path

`criteria`

  a data frame with the values of some criteria (variational lower bound J, BIC, ICL and R2, stability) for the collection of models / fits

### Methods

#### Public methods

- `PLNnetworkfamily$new()`

- `PLNnetworkfamily$optimize()`

- `PLNnetworkfamily$stability_selection()`

- `PLNnetworkfamily$coefficient_path()`

- `PLNnetworkfamily$getBestModel()`

- `PLNnetworkfamily$plot()`

- `PLNnetworkfamily$plot_stars()`

- `PLNnetworkfamily$plot_objective()`

- `PLNnetworkfamily$show()`

- `PLNnetworkfamily$clone()`

Inherited methods

- `PLNmodels::PLNfamily$getModel()`

- `PLNmodels::PLNfamily$postTreatment()`

- `PLNmodels::PLNfamily$print()`

#### Method `new()`

Initialize all models in the collection

##### Usage

    PLNnetworkfamily$new(
      penalties,
      responses,
      covariates,
      offsets,
      weights,
      model,
      xlevels,
      control
    )

##### Arguments

`penalties`

  a vector of positive real number controlling the level of sparsity of the underlying network.

`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

`model`

  model used for fitting, extracted from the formula in the upper-level call

`xlevels`

  named listed of factor levels included in the models, extracted from the formula in the upper-level call and used for predictions.

`control`

  a list for controlling the optimization. See details.

##### Returns

Update current `PLNnetworkfit` with smart starting values

#### Method `optimize()`

Call to the C++ optimizer on all models of the collection

##### Usage

    PLNnetworkfamily$optimize(control)

##### Arguments

`control`

  a list for controlling the optimization. See details.

#### Method `stability_selection()`

Compute the stability path by stability selection

##### Usage

    PLNnetworkfamily$stability_selection(
      subsamples = NULL,
      control = list(),
      mc.cores = 1
    )

##### Arguments

`subsamples`

  a list of vectors describing the subsamples. The number of vectors (or list length) determines th number of subsamples used in the stability selection. Automatically set to 20 subsamples with size `10*sqrt(n)` if `n >= 144` and `0.8*n` otherwise following Liu et al. (2010) recommendations.

`control`

  a list controlling the main optimization process in each call to PLNnetwork. See `PLNnetwork()` for details.

`mc.cores`

  the number of cores to used. Default is 1.

#### Method `coefficient_path()`

Extract the regularization path of a `PLNnetworkfamily`

##### Usage

    PLNnetworkfamily$coefficient_path(precision = TRUE, corr = TRUE)

##### Arguments

`precision`

  Logical. Should the regularization path be extracted from the precision matrix Omega (`TRUE`, default) or from the variance matrix Sigma (`FALSE`)

`corr`

  Logical. Should the matrix be transformed to (partial) correlation matrix before extraction? Defaults to `TRUE`

#### Method `getBestModel()`

Extract the best network in the family according to some criteria

##### Usage

    PLNnetworkfamily$getBestModel(
      crit = c("BIC", "loglik", "R_squared", "EBIC", "StARS"),
      stability = 0.9
    )

##### Arguments

`crit`

  character. Criterion used to perform the selection. Is "StARS" is chosen but `$stability` field is empty, will compute stability path.

`stability`

  Only used for "StARS" criterion. A scalar indicating the target stability (= 1 - 2 beta) at which the network is selected. Default is `0.9`.

#### Method `plot()`

Display various outputs (goodness-of-fit criteria, robustness, diagnostic) associated with a collection of PLNnetwork fits (a `PLNnetworkfamily`)

##### Usage

    PLNnetworkfamily$plot(
      criteria = c("loglik", "pen_loglik", "BIC", "EBIC"),
      log.x = TRUE,
      annotate
    )

##### Arguments

`criteria`

  vector of characters. The criteria to plot in `c("loglik", "pen_loglik", "BIC", "EBIC")`. Defaults to all of them.

`log.x`

  logical: should the x-axis be represented in log-scale? Default is `TRUE`.

`annotate`

  logical: should the value of approximated R squared be added to the plot of criteria? Default is `TRUE`.

##### Returns

a `ggplot` graph

#### Method `plot_stars()`

Plot stability path

##### Usage

    PLNnetworkfamily$plot_stars(stability = 0.9, log.x = TRUE)

##### Arguments

`stability`

  scalar: the targeted level of stability in stability plot. Default is `0.9`.

`log.x`

  logical: should the x-axis be represented in log-scale? Default is `TRUE`.

##### Returns

a `ggplot` graph

#### Method `plot_objective()`

Plot objective value of the optimization problem along the penalty path

##### Usage

    PLNnetworkfamily$plot_objective()

##### Returns

a `ggplot` graph

#### Method `show()`

User friendly print method

##### Usage

    PLNnetworkfamily$show()

#### Method `clone()`

The objects of this class are cloneable with this method.

##### Usage

    PLNnetworkfamily$clone(deep = FALSE)

##### Arguments

`deep`

  Whether to make a deep clone.

### See Also

The function `PLNnetwork()`, the class `PLNnetworkfit`

### Examples

    data(trichoptera)
    trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
    fits <- PLNnetwork(Abundance ~ 1, data = trichoptera)
    class(fits)

[Package PLNmodels version 0.10.6 Index]