DE.heat.FEM | R Documentation |
This function implements two methods for the density initialization procedure.
DE.heat.FEM(data, FEMbasis, lambda=NULL, heatStep=0.1, heatIter=500, init="Heat", nFolds=5, search = "tree")
data |
A matrix of dimensions #observations-by-ndim. Data are locations: each row corresponds to one point,
the first column corresponds to the |
FEMbasis |
A |
lambda |
A scalar or vector of smoothing parameters. Default is NULL. It is useful only if |
heatStep |
Real specifying the time step for the discretized heat diffusionn process. |
heatIter |
Integer specifying the number of iteriations to perform the discretized heat diffusion process. |
init |
String. This parameter specifies the initialization procedure. It can be either 'Heat' or 'CV'. |
nFolds |
An integer specifying the number of folds used in cross validation techinque. It is useful only
for the case |
search |
a flag to decide the search algorithm type (tree or naive or walking search algorithm). |
If init = 'Heat'
it returns a matrix in which each column contains the initial vector
for each lambda
. If init = 'CV'
it returns the initial vector associated to the lambda
given.
library(fdaPDE) ## Create a 2D mesh over a squared domain Xbound <- seq(-3, 3, length.out = 10) Ybound <- seq(-3, 3, length.out = 10) grid_XY <- expand.grid(Xbound, Ybound) Bounds <- grid_XY[(grid_XY$Var1 %in% c(-3, 3)) | (grid_XY$Var2 %in% c(-3, 3)), ] mesh <- create.mesh.2D(nodes = Bounds, order = 1) mesh <- refine.mesh.2D(mesh, maximum_area = 0.2) FEMbasis <- create.FEM.basis(mesh) ## Generate data n <- 50 set.seed(10) data_x <- rnorm(n) data_y <- rnorm(n) data <- cbind(data_x, data_y) plot(mesh) points(data, col="red", pch=19, cex=0.5) ## Density initialization lambda = 0.1 sol = DE.heat.FEM(data, FEMbasis, lambda, heatStep=0.1, heatIter=500, init="Heat") ## Visualization plot(FEM(coeff=sol$f_init, FEMbasis=FEMbasis))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.