R: An R6 Class to represent a collection of PLNPCAfit

PLNPCAfamily {PLNmodels} | R Documentation

## An R6 Class to represent a collection of PLNPCAfit

### Description

The function `PLNPCA()` 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` -> `PLNPCAfamily`

### Active bindings

`ranks`

  the dimensions of the successively fitted models

### Methods

#### Public methods

- `PLNPCAfamily$new()`

- `PLNPCAfamily$optimize()`

- `PLNPCAfamily$getBestModel()`

- `PLNPCAfamily$plot()`

- `PLNPCAfamily$show()`

- `PLNPCAfamily$clone()`

Inherited methods

- `PLNmodels::PLNfamily$getModel()`

- `PLNmodels::PLNfamily$postTreatment()`

- `PLNmodels::PLNfamily$print()`

#### Method `new()`

Initialize all models in the collection.

##### Usage

    PLNPCAfamily$new(
      ranks,
      responses,
      covariates,
      offsets,
      weights,
      model,
      xlevels,
      control
    )

##### Arguments

`ranks`

  the dimensions of the successively fitted models

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

#### Method `optimize()`

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

##### Usage

    PLNPCAfamily$optimize(control)

##### Arguments

`control`

  a list for controlling the optimization. See details.

#### Method `getBestModel()`

Extract best model in the collection

##### Usage

    PLNPCAfamily$getBestModel(crit = c("BIC", "ICL", "R_squared"))

##### Arguments

`crit`

  a character for the criterion used to performed the selection. Either "BIC", "ICL", or "R_squared". Default is `BIC`

##### Returns

a `PLNPCAfit` object

#### Method `plot()`

Lineplot of selected criteria for all models in the collection

##### Usage

    PLNPCAfamily$plot(criteria = c("loglik", "BIC", "ICL"), annotate = TRUE)

##### Arguments

`criteria`

  A valid model selection criteria for the collection of models. Any of "loglik", "BIC" or "ICL" (all).

`annotate`

  Logical. Should R2 be added to the plot (defaults to `TRUE`)

##### Returns

A `ggplot2` object

#### Method `show()`

User friendly print method

##### Usage

    PLNPCAfamily$show()

#### Method `clone()`

The objects of this class are cloneable with this method.

##### Usage

    PLNPCAfamily$clone(deep = FALSE)

##### Arguments

`deep`

  Whether to make a deep clone.

### See Also

The function `PLNPCA()`, the class `PLNPCAfit()`

### Examples

    data(trichoptera)
    trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
    myPCAs <- PLNPCA(Abundance ~ 1 + offset(log(Offset)), data = trichoptera, ranks = 1:5)
    class(myPCAs)

[Package PLNmodels version 0.10.6 Index]