residuals.initgmf | R Documentation |
Extract the residuals of an initialized GMF model and, if required, compute the eigenvalues of the residuals covariance/correlation matrix. Moreover, if required, return the partial residual of the model obtained by excluding the matrix decomposition from the linear predictor.
## S3 method for class 'initgmf'
residuals(
object,
...,
type = c("deviance", "pearson", "working", "response", "link"),
partial = FALSE,
normalize = FALSE,
fillna = FALSE,
spectrum = FALSE,
ncomp = 50
)
## S3 method for class 'initgmf'
resid(
object,
...,
type = c("deviance", "pearson", "working", "response", "link"),
partial = FALSE,
normalize = FALSE,
fillna = FALSE,
spectrum = FALSE,
ncomp = 50
)
object |
an object of class |
... |
further arguments passed to or from other methods |
type |
the type of residuals which should be returned |
partial |
if |
normalize |
if |
fillna |
if |
spectrum |
if |
ncomp |
number of eigenvalues to be calculated (only if |
If spectrum=FALSE
, a matrix containing the selected residuals.
If spectrum=TRUE
, a list containing the residuals (res
), the first ncomp
eigenvalues of the residual covariance matrix, say (lambdas
), the variance explained by the first
ncomp
principal component of the residuals (explained.var
), the variance not
explained by the first ncomp
principal component of the residuals (residual.var
),
the total variance of the residuals (total.var
).
residuals.sgdgmf
and resid.sgdgmf
for more details on the residual computation.
# Load the sgdGMF package
library(sgdGMF)
# Generate data from a Poisson model
data = sim.gmf.data(n = 100, m = 20, ncomp = 5, family = poisson())
# Fit a GMF model with 3 latent factors
init = sgdgmf.init(data$Y, ncomp = 3, family = poisson())
# Get the deviance residuals of a GMF model
str(residuals(init)) # returns the overall deviance residuals
str(residuals(init, partial = TRUE)) # returns the partial residuals
str(residuals(init, spectrum = TRUE)) # returns the eigenvalues of the residual var-cov matrix
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.