refit.sgdgmf: Refine the final estimate of a GMF model

refit.sgdgmfR Documentation

Refine the final estimate of a GMF model

Description

Refine the estimated latent scores of a GMF model via IRWLS

Usage

## S3 method for class 'sgdgmf'
refit(
  object,
  ...,
  normalize = TRUE,
  verbose = FALSE,
  parallel = FALSE,
  nthreads = 1
)

Arguments

object

an object of class sgdgmf

...

further arguments passed to or from other methods

normalize

if TRUE, normalize U and V to uncorrelated Gaussian U and upper triangular V with positive diagonal

verbose

if TRUE, print the optimization status

parallel

if TRUE, use parallel computing using the foreach package

nthreads

number of cores to be used in the "glm" method

Value

An sgdgmf object containing the re-fitted model.

See Also

sgdgmf.fit

Examples

# 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 using SGD
gmf_old = sgdgmf.fit(data$Y, ncomp = 3, family = poisson(), method = "sgd")

# Refine the score matrix estimate
gmf_new = refit(gmf_old)

# Get the fitted values in the link and response scales
mu_hat_old = fitted(gmf_old, type = "response")
mu_hat_new = fitted(gmf_new, type = "response")

# Compare the results
oldpar = par(no.readonly = TRUE)
par(mfrow = c(2,2), mar = c(1,1,3,1))
image(data$Y, axes = FALSE, main = expression(Y))
image(data$mu, axes = FALSE, main = expression(mu))
image(mu_hat_old, axes = FALSE, main = expression(hat(mu)[old]))
image(mu_hat_new, axes = FALSE, main = expression(hat(mu)[new]))
par(oldpar)


sgdGMF documentation built on June 8, 2025, 12:05 p.m.