Functional Data Class
fdClass.Rd
The fdClass
class represents an element of functional data.
Data objects are constructed using matrices, where columns represent grid points (user-defined or NULL) and rows represent observations.
Users can assign both smoothing and sparsity parameters.
If the smoothing parameter is set to zero, no smoothing is applied. Otherwise, users can specify a fixed smoothing value or provide a vector of values, which will be optimized using generalized cross-validation (GCV).
Arguments
- data
A matrix representing the data, with rows indicating observations and columns representing grid points.
- argval
A vector of grid points, it assigns grid points to the columns, with a length equal to the number of columns in the data. If
NULL
, grid points are automatically assigned from 0 to 1.- Smoothing_parameter
: Smoothing parameter for columns. It can be:
A fixed number representing the smoothing parameter.
A vector of numerical values, which will undergo generalized cross-validation (GCV) to determine the optimal value.
Set to 0 for no smoothing.
If
NULL
, it analyzes a sequence of2^seq(-30, 5, length.out = 10)
and attempts to tune it.
- Sparsity_parameter
A fixed number representing the level of sparsity for columns, or a vector of numerical values that will undergo cross-validation (CV) to determine the optimal value.
For no sparsity, set it to 0.
If
NULL
, the sparsity parameter will be tuned automatically.
Examples
# Example for Functional Data (fd)
fd_data <- matrix(rnorm(100), nrow = 10, ncol = 10) # 10 rows, 10 columns
fd_object <- fdClass(data = fd_data,
argval = seq(0, 1, length.out = 10), # Grid points for columns
Smoothing_parameter = 0.5, # Custom smoothing parameter
Sparsity_parameter = 2) # Custom sparsity parameter
# Display the created fd object
print(fd_object)
#> Functional Data (fdClass) Object
#> -----------------------------------
#> Dimensions: 10 x 10
#> Smoothing Parameter: 0.5
#> Sparsity Parameter: 2
#> GridPoints_v: 0 0.1111111 0.2222222 ... 0.8888889 1
#> -----------------------------------
#> First few rows and columns of the data:
#> V1 V2 V3 V4 V5
#> [1,] -0.9487057 1.3364468 -0.03705146 -1.1376128 0.2253395
#> [2,] 0.4768438 -0.8603562 0.81005379 -1.4372467 -0.7299152
#> [3,] -0.7952016 0.6665378 -0.49935541 -0.4941435 -1.2224871
#> [4,] 0.2343269 -1.4215347 0.94803159 0.8408018 0.4068052
#> [5,] -1.2224511 1.1700562 -0.17424596 0.7915341 -0.7510122
print(attr(fd_object, "GridPoints_v")) # Display grid points for columns
#> [1] 0.0000000 0.1111111 0.2222222 0.3333333 0.4444444 0.5555556 0.6666667
#> [8] 0.7777778 0.8888889 1.0000000
print(attr(fd_object, "Smoothing_parameter")) # Display smoothing parameter
#> [1] 0.5