get_encoding: Extract the computed encoding

View source: R/plotEncoding.R

get_encodingR Documentation

Extract the computed encoding

Description

Extract the encoding as an fd object or as a matrix

Usage

get_encoding(x, harm = 1, fdObject = FALSE, nx = NULL)

Arguments

x

Output of compute_optimal_encoding

harm

harmonic to use for the encoding

fdObject

If TRUE returns a fd object else a matrix

nx

(Only if fdObject = TRUE) Number of points to evaluate the encoding

Details

The encoding is a_{x} \approx \sum_{i=1}^m \alpha_{x,i}\phi_i.

Value

a fd object or a list of two elements y, a matrix with nx rows containing the encoding of the state and x, the vector with time values.

Author(s)

Cristian Preda

See Also

Other encoding functions: compute_optimal_encoding(), plot.fmca(), plotComponent(), plotEigenvalues(), predict.fmca(), 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)
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)

# extract the encoding using 1 harmonic
encodFd <- get_encoding(encoding, fdObject = TRUE)
encodMat <- get_encoding(encoding, nx = 200)



modal-inria/cfda documentation built on Oct. 19, 2023, 10:03 a.m.