Learn R Programming

fdaPDE (version 1.1-21)

DE.heat.FEM: Density initialization

Description

This function implements two methods for the density initialization procedure.

Usage

DE.heat.FEM(data, FEMbasis, lambda=NULL, heatStep=0.1, heatIter=500, 
            init="Heat", nFolds=5, search = "tree")

Value

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.

Arguments

data

A matrix of dimensions #observations-by-ndim. Data are locations: each row corresponds to one point, the first column corresponds to the x-coordinates, the second column corresponds to the y-coordinates and, if ndim=3, the third column corresponds to the z-coordinates.

FEMbasis

A FEMbasis object describing the Finite Element basis, as created by create.FEM.basis.

lambda

A scalar or vector of smoothing parameters. Default is NULL. It is useful only if init='Heat'.

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 init = 'CV'.

search

a flag to decide the search algorithm type (tree or naive or walking search algorithm).

Examples

Run this code
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))

Run the code above in your browser using DataLab