predict.iva {ivaBSS}R Documentation

Predict Method for Object of Class iva

Description

Predict the new source estimates best on fitted object of "iva" class.

Usage

## S3 method for class 'iva'
predict(object, newdata, which.dataset = NA, ...)

Arguments

object

An object of class "iva", usually the result of a call to NewtonIVA or fastIVA.

newdata

A numeric data array containing new observed mixtures. Either with dimension [P, N, D] (if which.dataset = NA) or [P, N], where P is the number of sources, N is the number of observations and D is the number of datasets.

which.dataset

Positive integer to determine which dataset is returned. If not set, returns all datasets.

...

further arguments are not used.

Details

The function calculates the source estimates for new observed mixtures based on the model fitted originally. The estimates are zero mean and scaled to unit variance.

Value

Numeric array containing the estimated sources with dimension [P, N] if which.dataset is provided and with dimension [P, N, D] if which.dataset is not provided.

Author(s)

Mika Sipilä

See Also

NewtonIVA, fastIVA

Examples

if (require("LaplacesDemon")) {
  # Generate sources from multivariate Laplace distribution
  P <- 4; N <- 1000; D <- 4;
  S <- array(NA, c(P, N, D))
  sigmas <- list()

  for (i in 1:P) {
    U <- array(rnorm(D * D), c(D, D))
    sigmas[[i]] <- crossprod(U)
    S[i, , ] <- rmvl(N, rep(0, D), sigmas[[i]])
  }

  # Generate mixing matrices from standard normal distribution
  A <- array(rnorm(P * P * D), c(P, P, D))

  # Generate mixtures
  X <- array(NaN, c(P, N, D))
  for (d in 1:D) {
    X[, , d] <- A[, , d] %*% S[, , d]
  }

  # Estimate sources and unmixing matrices
  res_G <- NewtonIVA(X, source_density = "gaussian")

  # Generate new observarions
  N_new <- 10
  S_new <- array(NA, c(P, N_new, D))
  for (i in 1:P) {
    S_new[i, , ] <- rmvl(N_new, rep(0, D), sigmas[[i]])
  }
  X_new <- array(NaN, c(P, N_new, D))
  for (d in 1:D) {
    X_new[, , d] <- A[, , d] %*% S_new[, , d]
  }

  # Get source estimates for the new observations
  pred <- predict(res_G, X_new)

  # Get source estimates for only the second dataset
  pred2 <- predict(res_G, X_new[, , 2], which.dataset = 2)
}

[Package ivaBSS version 1.0.0 Index]