| PLNmixturefit {PLNmodels} | R Documentation |
An R6 Class to represent a PLNfit in a mixture framework
Description
The function PLNmixture produces a collection of models which are instances of object with class PLNmixturefit.
A PLNmixturefit (say, with k components) is itself a collection of k PLNfit.
This class comes with a set of methods, some of them being useful for the user: See the documentation for ...
Active bindings
nnumber of samples
pnumber of dimensions of the latent space
knumber of components
dnumber of covariates
componentscomponents of the mixture (PLNfits)
latenta matrix: values of the latent vector (Z in the model)
latent_posa matrix: values of the latent position vector (Z) without covariates effects or offset
posteriorProbmatrix ofposterior probability for cluster belonging
membershipsvector for cluster index
mixtureParamvector of cluster proportions
optim_para list with parameters useful for monitoring the optimization
nb_paramnumber of parameters in the current PLN model
entropy_clusteringEntropy of the variational distribution of the cluster (multinomial)
entropy_latentEntropy of the variational distribution of the latent vector (Gaussian)
entropyFull entropy of the variational distribution (latent vector + clustering)
loglikvariational lower bound of the loglikelihood
loglik_vecelement-wise variational lower bound of the loglikelihood
BICvariational lower bound of the BIC
ICLvariational lower bound of the ICL (include entropy of both the clustering and latent distributions)
R_squaredapproximated goodness-of-fit criterion
criteriaa vector with loglik, BIC, ICL, and number of parameters
model_para list with the matrices of parameters found in the model (Theta, Sigma, Mu and Pi)
vcov_modelcharacter: the model used for the covariance (either "spherical", "diagonal" or "full")
fitteda matrix: fitted values of the observations (A in the model)
group_meansa matrix of group mean vectors in the latent space.
Methods
Public methods
Method new()
Optimize a the
Initialize a PLNmixturefit model
Usage
PLNmixturefit$new( responses, covariates, offsets, posteriorProb, formula, control )
Arguments
responsesthe matrix of responses common to every models
covariatesthe matrix of covariates common to every models
offsetsthe matrix of offsets common to every models
posteriorProbmatrix ofposterior probability for cluster belonging
formulamodel formula used for fitting, extracted from the formula in the upper-level call
controla list for controlling the optimization.
Method optimize()
Optimize a PLNmixturefit model
Usage
PLNmixturefit$optimize(responses, covariates, offsets, config)
Arguments
responsesthe matrix of responses common to every models
covariatesthe matrix of covariates common to every models
offsetsthe matrix of offsets common to every models
configa list for controlling the optimization
Method predict()
Predict group of new samples
Usage
PLNmixturefit$predict(
newdata,
type = c("posterior", "response", "position"),
prior = matrix(rep(1/self$k, self$k), nrow(newdata), self$k, byrow = TRUE),
control = PLNmixture_param(),
envir = parent.frame()
)Arguments
newdataA data frame in which to look for variables, offsets and counts with which to predict.
typeThe type of prediction required. The default
posteriorare posterior probabilities for each group ,responseis the group with maximal posterior probability andlatentis the averaged latent coordinate (without offset and nor covariate effects), with weights equal to the posterior probabilities.priorUser-specified prior group probabilities in the new data. The default uses a uniform prior.
controla list-like structure for controlling the fit. See
PLNmixture_param()for details.envirEnvironment in which the prediction is evaluated
Method plot_clustering_data()
Plot the matrix of expected mean counts (without offsets, without covariate effects) reordered according the inferred clustering
Usage
PLNmixturefit$plot_clustering_data( main = "Expected counts reorder by clustering", plot = TRUE, log_scale = TRUE )
Arguments
maincharacter. A title for the plot. An hopefully appropriate title will be used by default.
plotlogical. Should the plot be displayed or sent back as
ggplotobjectlog_scalelogical. Should the color scale values be log-transform before plotting? Default is
TRUE.
Returns
a ggplot graphic
Method plot_clustering_pca()
Plot the individual map of a PCA performed on the latent coordinates, where individuals are colored according to the memberships
Usage
PLNmixturefit$plot_clustering_pca( main = "Clustering labels in Individual Factor Map", plot = TRUE )
Arguments
maincharacter. A title for the plot. An hopefully appropriate title will be used by default.
plotlogical. Should the plot be displayed or sent back as
ggplotobject
Returns
a ggplot graphic
Method postTreatment()
Update fields after optimization
Usage
PLNmixturefit$postTreatment( responses, covariates, offsets, weights, config_post, config_optim, nullModel )
Arguments
responsesthe matrix of responses common to every models
covariatesthe matrix of covariates common to every models
offsetsthe matrix of offsets common to every models
weightsan optional vector of observation weights to be used in the fitting process.
config_posta list for controlling the post-treatment
config_optima list for controlling the optimization during the post-treatment computations
nullModelnull model used for approximate R2 computations. Defaults to a GLM model with same design matrix but not latent variable.
Method show()
User friendly print method
Usage
PLNmixturefit$show()
Method print()
User friendly print method
Usage
PLNmixturefit$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
PLNmixturefit$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
The function PLNmixture, the class PLNmixturefamily