diff --git a/DESCRIPTION b/DESCRIPTION index 2eef96b7..62ea0184 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: PLNmodels Title: Poisson Lognormal Models -Version: 1.1.0 +Version: 1.1.1 Authors@R: c( person("Julien", "Chiquet", role = c("aut", "cre"), email = "julien.chiquet@inrae.fr", comment = c(ORCID = "0000-0002-3629-3429")), diff --git a/NEWS.md b/NEWS.md index 0a0b6aed..5af5c3ff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# PLNmodels 1.1.1 (2023-08-24) + +* Change behavior of `predict()` function for PLNfit model to (i) return fitted values if newdata is missing and (ii) perform one VE step to improve fit if responses are provided. +* Fix issue #114 + # PLNmodels 1.1.0 (2023-08-24) * Update documentation of PLN*_param() functions to include torch optimization parameters diff --git a/man/PLNfit.Rd b/man/PLNfit.Rd index 2703ac82..303c21cb 100644 --- a/man/PLNfit.Rd +++ b/man/PLNfit.Rd @@ -285,7 +285,13 @@ The list of parameters \code{config} controls the post-treatment processing, wit \subsection{Method \code{predict()}}{ Predict position, scores or observations of new data. \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{PLNfit$predict(newdata, type = c("link", "response"), envir = parent.frame())}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{PLNfit$predict( + newdata, + responses = NULL, + type = c("link", "response"), + level = 1, + envir = parent.frame() +)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -293,12 +299,21 @@ Predict position, scores or observations of new data. \describe{ \item{\code{newdata}}{A data frame in which to look for variables with which to predict. If omitted, the fitted values are used.} +\item{\code{responses}}{Optional data frame containing the count of the observed variables (matching the names of the provided as data in the PLN function), assuming the interest in in testing the model.} + \item{\code{type}}{Scale used for the prediction. Either \code{link} (default, predicted positions in the latent space) or \code{response} (predicted counts).} +\item{\code{level}}{Optional integer value the level to be used in obtaining the predictions. Level zero corresponds to the population predictions (default if \code{responses} is not provided) while level one (default) corresponds to predictions after evaluating the variational parameters for the new data.} + \item{\code{envir}}{Environment in which the prediction is evaluated} } \if{html}{\out{}} } +\subsection{Details}{ +Note that \code{level = 1} can only be used if responses are provided, +as the variational parameters can't be estimated otherwise. In the absence of responses, \code{level} is ignored and the fitted values are returned +} + \subsection{Returns}{ A matrix with predictions scores or counts. } diff --git a/man/predict.PLNfit.Rd b/man/predict.PLNfit.Rd index 8e7d177b..6bf64b77 100644 --- a/man/predict.PLNfit.Rd +++ b/man/predict.PLNfit.Rd @@ -4,13 +4,24 @@ \alias{predict.PLNfit} \title{Predict counts of a new sample} \usage{ -\method{predict}{PLNfit}(object, newdata, type = c("link", "response"), ...) +\method{predict}{PLNfit}( + object, + newdata, + responses = NULL, + level = 1, + type = c("link", "response"), + ... +) } \arguments{ \item{object}{an R6 object with class \code{\link{PLNfit}}} \item{newdata}{A data frame in which to look for variables and offsets with which to predict} +\item{responses}{Optional data frame containing the count of the observed variables (matching the names of the provided as data in the PLN function), assuming the interest in in testing the model.} + +\item{level}{Optional integer value the level to be used in obtaining the predictions. Level zero corresponds to the population predictions (default if \code{responses} is not provided) while level one (default) corresponds to predictions after evaluating the variational parameters for the new data.} + \item{type}{The type of prediction required. The default is on the scale of the linear predictors (i.e. log average count)} \item{...}{additional parameters for S3 compatibility. Not used}