- pyPLNmodels.sample_pln(pln_param, *, seed: int | None = None, return_latent=False) Tensor
Sample from the Poisson Log-Normal (Pln) model.
- Parameters:
pln_param (PlnParameters object) – parameters of the model, containing the coeficient, the exog, the components and the offsets.
seed (int or None, optional(keyword-only)) – Random seed for reproducibility. Default is None.
return_latent (bool, optional(keyword-only)) – If True will return also the latent variables. Default is False.
- Returns:
tuple[torch.Tensor, torch.Tensor, torch.Tensor] if return_latent is True – Tuple containing endog (torch.Tensor), gaussian (torch.Tensor), and ksi (torch.Tensor)
torch.Tensor if return_latent is False
See also
PlnParameters()
- pyPLNmodels.get_simulation_parameters(*, n_samples: int = 100, dim: int = 25, nb_cov: int = 1, rank: int = 5, add_const: bool = True, zero_inflated: bool = False) PlnParameters
Generate simulation parameters for a Poisson-lognormal model.
- Parameters:
n_samples (int, optional(keyword-only)) – The number of samples, by default 100.
dim (int, optional(keyword-only)) – The dimension of the data, by default 25.
nb_cov (int, optional(keyword-only)) – The number of exog, by default 1. If add_const is True, then there will be nb_cov+1 exog as the intercept can be seen as a exog.
rank (int, optional(keyword-only)) – The rank of the data components, by default 5.
add_const (bool, optional(keyword-only)) – If True, will add a vector of ones in the exog.
zero_inflated (bool, optional(keyword-only)) – If True, the model will be zero inflated. Default is False.
- Returns:
The generated simulation parameters.
- Return type:
- class pyPLNmodels.PlnParameters(*, components: Tensor | ndarray | DataFrame, coef: Tensor | ndarray | DataFrame, exog: Tensor | ndarray | DataFrame, offsets: Tensor | ndarray | DataFrame, coef_inflation: Tensor | ndarray | DataFrame | None = None)
Bases:
object
- __init__(*, components: Tensor | ndarray | DataFrame, coef: Tensor | ndarray | DataFrame, exog: Tensor | ndarray | DataFrame, offsets: Tensor | ndarray | DataFrame, coef_inflation: Tensor | ndarray | DataFrame | None = None)
Instantiate all the needed parameters to sample from the PLN model.
- Parameters:
components (: Union[torch.Tensor, np.ndarray, pd.DataFrame](keyword-only)) – Components of size (p, rank)
coef (: Union[torch.Tensor, np.ndarray, pd.DataFrame](keyword-only)) – Coefficient of size (d, p)
exog (: Union[torch.Tensor, np.ndarray, pd.DataFrame] or None(keyword-only)) – Covariates, size (n, d) or None
offsets (: Union[torch.Tensor, np.ndarray, pd.DataFrame](keyword-only)) – Offset, size (n, p)
coef_inflation (Union[torch.Tensor, np.ndarray, pd.DataFrame, None], optional(keyword-only)) – Coefficient for zero-inflation model, size (d, p) or None. Default is None.
- property coef
Coef of the model.
- property coef_inflation
Inflation coefficient of the model.
- property components
Components of the model.
- property covariance
Covariance of the model.
- property exog
Data exog.
- property offsets
Data offsets.