predict.fmca {cfda}R Documentation

Predict the principal components for new trajectories

Description

Predict the principal components for new trajectories

Usage

## S3 method for class 'fmca'
predict(
  object,
  newdata = NULL,
  method = c("precompute", "parallel"),
  verbose = TRUE,
  nCores = max(1, ceiling(detectCores()/2)),
  ...
)

Arguments

object

output of compute_optimal_encoding function.

newdata

data.frame containing id, id of the trajectory, time, time at which a change occurs and state, associated state. All individuals must begin at the same time T0 and end at the same time Tmax (use cut_data).

method

computation method: "parallel" or "precompute": precompute all integrals (efficient when the number of unique time values is low)

verbose

if TRUE print some information

nCores

number of cores used for parallelization (only if method == "parallel"). Default is half the cores.

...

parameters for integrate function (see details).

Value

principal components for the individuals

Author(s)

Quentin Grimonprez

See Also

Other encoding functions: compute_optimal_encoding(), get_encoding(), plot.fmca(), plotComponent(), plotEigenvalues(), print.fmca(), summary.fmca()

Examples

# Simulate the Jukes-Cantor model of nucleotide replacement
K <- 4
Tmax <- 6
PJK <- matrix(1 / 3, nrow = K, ncol = K) - diag(rep(1 / 3, K))
lambda_PJK <- c(1, 1, 1, 1)
d_JK <- generate_Markov(
  n = 10, K = K, P = PJK, lambda = lambda_PJK, Tmax = Tmax,
  labels = c("A", "C", "G", "T")
)
d_JK2 <- cut_data(d_JK, Tmax)

# create basis object
m <- 6
b <- create.bspline.basis(c(0, Tmax), nbasis = m, norder = 4)

# compute encoding
encoding <- compute_optimal_encoding(d_JK2, b, computeCI = FALSE, nCores = 1)

# predict principal components
d_JK_predict <- generate_Markov(
  n = 5, K = K, P = PJK, lambda = lambda_PJK, Tmax = Tmax,
  labels = c("A", "C", "G", "T")
)
d_JK_predict2 <- cut_data(d_JK, Tmax)

pc <- predict(encoding, d_JK_predict2, nCores = 1)



[Package cfda version 0.11.0 Index]