predict.iva | R Documentation |
Predict the new source estimates best on fitted object of "iva"
class.
## S3 method for class 'iva' predict(object, newdata, which.dataset = NA, ...)
object |
An object of class |
newdata |
A numeric data array containing new observed mixtures. Either with dimension |
which.dataset |
Positive integer to determine which dataset is returned. If not set, returns all datasets. |
... |
further arguments are not used. |
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.
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.
Mika Sipilä
NewtonIVA
, fastIVA
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) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.