get_encoding {cfda}R 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 ∑_{i=1}^m α_{x,i}φ_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

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)



[Package cfda version 0.9.9 Index]