R: An R6 Class to represent a PLNfit in a sparse inverse...

PLNnetworkfit {PLNmodels} | R Documentation

## An R6 Class to represent a PLNfit in a sparse inverse covariance framework

### Description

The function `PLNnetwork()` produces a collection of models which are instances of object with class `PLNnetworkfit`.

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

### Super class

`PLNmodels::PLNfit` -> `PLNnetworkfit`

### Active bindings

`penalty`

  the level of sparsity in the current model

`n_edges`

  number of edges if the network (non null coefficient of the sparse precision matrix)

`nb_param`

  number of parameters in the current PLN model

`pen_loglik`

  variational lower bound of the l1-penalized loglikelihood

`model_par`

  a list with the matrices associated with the estimated parameters of the pPCA model: Theta (covariates), Sigma (latent covariance) and Theta (latent precision matrix). Note Omega and Sigma are inverse of each other.

`EBIC`

  variational lower bound of the EBIC

`density`

  proportion of non-null edges in the network

`criteria`

  a vector with loglik, penalized loglik, BIC, EBIC, ICL, R_squared, number of parameters, number of edges, and graph density

### Methods

#### Public methods

- `PLNnetworkfit$new()`

- `PLNnetworkfit$update()`

- `PLNnetworkfit$optimize()`

- `PLNnetworkfit$postTreatment()`

- `PLNnetworkfit$latent_network()`

- `PLNnetworkfit$plot_network()`

- `PLNnetworkfit$show()`

- `PLNnetworkfit$clone()`

Inherited methods

- `PLNmodels::PLNfit$VEstep()`

- `PLNmodels::PLNfit$compute_fisher()`

- `PLNmodels::PLNfit$compute_standard_error()`

- `PLNmodels::PLNfit$predict()`

- `PLNmodels::PLNfit$print()`

- `PLNmodels::PLNfit$set_R2()`

#### Method `new()`

Initialize a `PLNnetworkfit` object

##### Usage

    PLNnetworkfit$new(
      penalty,
      responses,
      covariates,
      offsets,
      weights,
      formula,
      xlevels,
      control
    )

##### Arguments

`penalty`

  a 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`

  an optional vector of observation weights to be used in the fitting process.

`formula`

  model formula 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 `PLNnetwork()` call

`control`

  a list for controlling the optimization of the PLN model used at initialization. See `PLNnetwork()` for details.

#### Method `update()`

Update fields of a `PLNnetworkfit` object

##### Usage

    PLNnetworkfit$update(
      penalty = NA,
      Theta = NA,
      Sigma = NA,
      Omega = NA,
      M = NA,
      S2 = NA,
      Z = NA,
      A = NA,
      Ji = NA,
      R2 = NA,
      monitoring = NA
    )

##### Arguments

`penalty`

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

`Theta`

  matrix of regression matrix

`Sigma`

  variance-covariance matrix of the latent variables

`Omega`

  precision matrix of the latent variables. Inverse of Sigma.

`M`

  matrix of mean vectors for the variational approximation

`S2`

  matrix of variance vectors for the variational approximation

`Z`

  matrix of latent vectors (includes covariates and offset effects)

`A`

  matrix of fitted values

`Ji`

  vector of variational lower bounds of the log-likelihoods (one value per sample)

`R2`

  approximate R^2 goodness-of-fit criterion

`monitoring`

  a list with optimization monitoring quantities

#### Method `optimize()`

Call to the C++ optimizer and update of the relevant fields

##### Usage

    PLNnetworkfit$optimize(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`

  an optional vector of observation weights to be used in the fitting process.

`control`

  a list for controlling the optimization of the PLN model used at initialization. See `PLNnetwork()` for details.

#### Method `postTreatment()`

Compute PCA scores in the latent space and update corresponding fields.

##### Usage

    PLNnetworkfit$postTreatment(responses, covariates, offsets, weights, nullModel)

##### 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`

  an optional vector of observation weights to be used in the fitting process.

`nullModel`

  null model used for approximate R2 computations. Defaults to a GLM model with same design matrix but not latent variable.

#### Method `latent_network()`

Extract interaction network in the latent space

##### Usage

    PLNnetworkfit$latent_network(type = c("partial_cor", "support", "precision"))

##### Arguments

`type`

  edge value in the network. Can be "support" (binary edges), "precision" (coefficient of the precision matrix) or "partial_cor" (partial correlation between species)

##### Returns

a square matrix of size `PLNnetworkfit$n`

#### Method `plot_network()`

plot the latent network.

##### Usage

    PLNnetworkfit$plot_network(
      type = c("partial_cor", "support"),
      output = c("igraph", "corrplot"),
      edge.color = c("#F8766D", "#00BFC4"),
      remove.isolated = FALSE,
      node.labels = NULL,
      layout = layout_in_circle,
      plot = TRUE
    )

##### Arguments

`type`

  edge value in the network. Either "precision" (coefficient of the precision matrix) or "partial_cor" (partial correlation between species).

`output`

  Output type. Either `igraph` (for the network) or `corrplot` (for the adjacency matrix)

`edge.color`

  Length 2 color vector. Color for positive/negative edges. Default is `c("#F8766D", "#00BFC4")`. Only relevant for igraph output.

`remove.isolated`

  if `TRUE`, isolated node are remove before plotting. Only relevant for igraph output.

`node.labels`

  vector of character. The labels of the nodes. The default will use the column names ot the response matrix.

`layout`

  an optional igraph layout. Only relevant for igraph output.

`plot`

  logical. Should the final network be displayed or only sent back to the user. Default is `TRUE`.

#### Method `show()`

User friendly print method

##### Usage

    PLNnetworkfit$show()

#### Method `clone()`

The objects of this class are cloneable with this method.

##### Usage

    PLNnetworkfit$clone(deep = FALSE)

##### Arguments

`deep`

  Whether to make a deep clone.

### See Also

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

### Examples

    ## Not run:
    data(trichoptera)
    trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
    nets <- PLNnetwork(Abundance ~ 1, data = trichoptera)
    myPLNnet <- getBestModel(nets)
    class(myPLNnet)
    print(myPLNnet)

    ## End(Not run)

[Package PLNmodels version 0.11.4 Index]