The function PLNLDA() produces an instance of an object with class PLNLDAfit.
This class comes with a set of methods, some of them being useful for the user:
See the documentation for the methods inherited by PLNfit(), the plot() method for
LDA visualization and predict() method for prediction
PLNmodels::PLNfit -> PLNLDAfit
rankthe dimension of the current model
nb_paramnumber of parameters in the current PLN model
model_para list with the matrices associated with the estimated parameters of the PLN model: Theta (covariates), Sigma (latent covariance), B (latent loadings), P (latent position) and Mu (group means)
percent_varthe percent of variance explained by each axis
corr_mapa matrix of correlations to plot the correlation circles
scoresa matrix of scores to plot the individual factor maps
group_meansa matrix of group mean vectors in the latent space.
new()Initialize a PLNLDAfit object
PLNLDAfit$new(
grouping,
responses,
covariates,
offsets,
weights,
formula,
xlevels,
control
)groupinga factor specifying the class of each observation used for discriminant analysis.
responsesthe matrix of responses (called Y in the model). Will usually be extracted from the corresponding field in PLNfamily-class
covariatesdesign matrix (called X in the model). Will usually be extracted from the corresponding field in PLNfamily-class
offsetsoffset matrix (called O in the model). Will usually be extracted from the corresponding field in PLNfamily-class
weightsan optional vector of observation weights to be used in the fitting process.
formulamodel formula used for fitting, extracted from the formula in the upper-level call
xlevelsnamed listed of factor levels included in the models, extracted from the formula in the upper-level call and used for predictions.
controla list for controlling the optimization. See details.
optimize()Compute group means and axis of the LDA (noted B in the model) in the latent space, update corresponding fields
PLNLDAfit$optimize(grouping, covariates, control)groupingdesign matrix for the grouping variable
covariatesdesign matrix. Automatically built from the covariates and the formula from the call
controla list for controlling the optimization. See details.
XAbundance matrix.
postTreatment()Update R2, fisher and std_err fields and visualization after optimization
PLNLDAfit$postTreatment(grouping, responses, covariates, offsets)groupinga factor specifying the class of each observation used for discriminant analysis.
responsesthe matrix of responses (called Y in the model). Will usually be extracted from the corresponding field in PLNfamily-class
covariatesdesign matrix (called X in the model). Will usually be extracted from the corresponding field in PLNfamily-class
offsetsoffset matrix (called O in the model). Will usually be extracted from the corresponding field in PLNfamily-class
setVisualization()Compute LDA scores in the latent space and update corresponding fields.
PLNLDAfit$setVisualization(scale.unit = FALSE)scale.unitLogical. Should LDA scores be rescaled to have unit variance
plot_individual_map()Plot the factorial map of the LDA
PLNLDAfit$plot_individual_map(
axes = 1:min(2, self$rank),
main = "Individual Factor Map",
plot = TRUE
)axesnumeric, the axes to use for the plot when map = "individual" or "variable". Default it c(1,min(rank))
maincharacter. A title for the single plot (individual or variable factor map). If NULL (the default), an hopefully appropriate title will be used.
plotlogical. Should the plot be displayed or sent back as ggplot object
a ggplot graphic
plot_correlation_map()Plot the correlation circle of a specified axis for a PLNLDAfit object
PLNLDAfit$plot_correlation_map(
axes = 1:min(2, self$rank),
main = "Variable Factor Map",
cols = "default",
plot = TRUE
)axesnumeric, the axes to use for the plot when map = "individual" or "variable". Default it c(1,min(rank))
maincharacter. A title for the single plot (individual or variable factor map). If NULL (the default), an hopefully appropriate title will be used.
colsa character, factor or numeric to define the color associated with the variables. By default, all variables receive the default color of the current palette.
plotlogical. Should the plot be displayed or sent back as ggplot object
a ggplot graphic
plot_LDA()Plot a summary of the PLNLDAfit object
PLNLDAfit$plot_LDA(
nb_axes = min(3, self$rank),
var_cols = "default",
plot = TRUE
)nb_axesscalar: the number of axes to be considered when map = "both". The default is min(3,rank).
var_colsa character, factor or numeric to define the color associated with the variables. By default, all variables receive the default color of the current palette.
plotlogical. Should the plot be displayed or sent back as ggplot object
a grob object
predict()Predict group of new samples
PLNLDAfit$predict(
newdata,
type = c("posterior", "response", "scores"),
scale = c("log", "prob"),
prior = NULL,
control = list(),
envir = parent.frame()
)newdataA data frame in which to look for variables, offsets and counts with which to predict.
typeThe type of prediction required. The default are posterior probabilities for each group (in either unnormalized log-scale or natural probabilities, see "scale" for details), "response" is the group with maximal posterior probability and "scores" is the average score along each separation axis in the latent space, with weights equal to the posterior probabilities.
scaleThe scale used for the posterior probability. Either log-scale ("log", default) or natural probabilities summing up to 1 ("prob").
priorUser-specified prior group probabilities in the new data. If NULL (default), prior probabilities are computed from the learning set.
controla list for controlling the optimization. See PLN() for details.
envirEnvironment in which the prediction is evaluated
show()User friendly print method
PLNLDAfit$show()
clone()The objects of this class are cloneable with this method.
PLNLDAfit$clone(deep = FALSE)deepWhether to make a deep clone.
The function PLNLDA.
if (FALSE) {
data(trichoptera)
trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
myPLNLDA <- PLNLDA(Abundance ~ 1, grouping = Group, data = trichoptera)
class(myPLNLDA)
print(myPLNLDA)
}
Run the code above in your browser using DataLab