sim.gmf.data | R Documentation |
Simulate synthetic non-Gaussian data from a generalized matrix factorization (GMF) model.
sim.gmf.data(n = 100, m = 20, ncomp = 5, family = gaussian(), dispersion = 1)
n |
number of observations |
m |
number of variables |
ncomp |
rank of the latent matrix factorization |
family |
a |
dispersion |
a positive dispersion parameter |
The loadings, V
, are independently sampled from a standard normal distribution.
The scores, U
, are simulated according to sinusoidal signals evaluated at different
phases, frequencies and amplitudes. These parameters are randomly sampled from independent
uniform distributions.
A list containing the following objects:
Y
: simulated response matrix
U
: simulated factor matrix
V
: simulated loading matrix
eta
: linear predictor matrix
mu
: conditional mean matrix
phi
: scalar dispersion parameter
family
: model family
ncomp
: rank of the latent matrix factorization
param
: a list containing time, phase, frequency and amplitude vectors used to generate U
library(sgdGMF)
# Set the data dimensions
n = 100; m = 20; d = 5
# Generate data using Poisson, Binomial and Gamma models
data_pois = sim.gmf.data(n = n, m = m, ncomp = d, family = poisson())
data_bin = sim.gmf.data(n = n, m = m, ncomp = d, family = binomial())
data_gam = sim.gmf.data(n = n, m = m, ncomp = d, family = Gamma(link = "log"), dispersion = 0.25)
# Compare the results
oldpar = par(no.readonly = TRUE)
par(mfrow = c(3,3), mar = c(1,1,3,1))
image(data_pois$Y, axes = FALSE, main = expression(Y[Pois]))
image(data_pois$mu, axes = FALSE, main = expression(mu[Pois]))
image(data_pois$U, axes = FALSE, main = expression(U[Pois]))
image(data_bin$Y, axes = FALSE, main = expression(Y[Bin]))
image(data_bin$mu, axes = FALSE, main = expression(mu[Bin]))
image(data_bin$U, axes = FALSE, main = expression(U[Bin]))
image(data_gam$Y, axes = FALSE, main = expression(Y[Gam]))
image(data_gam$mu, axes = FALSE, main = expression(mu[Gam]))
image(data_gam$U, axes = FALSE, main = expression(U[Gam]))
par(oldpar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.