`S3`

method to compute the sample covariance and cross-covariance
functions for a set of functional data.

1 2 3 4 5 6 7 |

`X` |
is the (eventually first) functional dataset, i.e. either an object
of class |

`Y` |
is the (optional) second functional dataset to be used to compute the
cross-covariance function, either |

Given a univariate random function X, defined
over the grid *I = [a,b]*, the covariance
function is defined as:

*C(s,t) = Cov( X(s), X(t) ), \qquad s,t \in I.*

Given another random function, Y, defined over the same grid as X, the cross- covariance function of X and Y is:

*C^{X,Y}( s,t ) = Cov( X(s), Y(t) ), \qquad s, t \in I.*

For a generic L-dimensional random function X, i.e. an L-dimensional multivariate functional datum, the covariance function is defined as the set of blocks:

*C_{i,j}(s,t) = Cov( X_i(s), X_j(t)), i,j = 1, ...,L, s,t \in I,*

while the cross-covariance function is defined by the blocks:

*C^{X,Y}_{i,j}(s,t) = Cov( X_i(s), Y_j(t))*

The method `cov_fun`

provides the sample estimator of the covariance or
cross-covariance functions for univariate or multivariate functional datasets.

The class of `X`

(`fData`

or `mfData`

) is used to dispatch the
correct implementation of the method.

The following cases are given:

if

`X`

is of class`fData`

and`Y`

is`NULL`

, then the covariance function of`X`

is returned;if

`X`

is of class`fData`

and`Y`

is of class`fData`

, the cross-covariance function of the two datasets is returned;if

`X`

is of class`mfData`

and`Y`

is`NULL`

, the upper-triangular blocks of the covariance function of`X`

are returned (in form of list and by row, i.e. in the squence 1_1, 1_2, ..., 1_L, 2_2, ... - have a look at the labels of the list with`str`

);if

`X`

is of class`mfData`

and`Y`

is of class`fData`

, the cross-covariances of`X`

's components and`Y`

are returned (in form of list);if

`X`

is of class`mfData`

and`Y`

is of class`mfData`

, the upper-triangular blocks of the cross-covariance of`X`

's and`Y`

's components are returned (in form of list and by row, i.e. in the squence 1_1, 1_2, ..., 1_L, 2_2, ... - have a look at the labels of the list with`str`

));

In any case, the return type is either an instance of the `S3`

class `Cov`

or a list of instances of such class (for the case of multivariate
functional data).

`fData`

, `mfData`

, `plot.Cov`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | ```
# Generating a univariate functional dataset
N = 1e2
P = 1e2
t0 = 0
t1 = 1
time_grid = seq( t0, t1, length.out = P )
Cov = exp_cov_function( time_grid, alpha = 0.3, beta = 0.4 )
D1 = generate_gauss_fdata( N, centerline = sin( 2 * pi * time_grid ), Cov = Cov )
D2 = generate_gauss_fdata( N, centerline = sin( 2 * pi * time_grid ), Cov = Cov )
fD1 = fData( time_grid, D1 )
fD2 = fData( time_grid, D2 )
# Computing the covariance function of fD1
C = cov_fun( fD1 )
str( C )
# Computing the cross-covariance function of fD1 and fD2
CC = cov_fun( fD1, fD2 )
str( CC )
# Generating a multivariate functional dataset
L = 3
C1 = exp_cov_function( time_grid, alpha = 0.1, beta = 0.2 )
C2 = exp_cov_function( time_grid, alpha = 0.2, beta = 0.5 )
C3 = exp_cov_function( time_grid, alpha = 0.3, beta = 1 )
centerline = matrix( c( sin( 2 * pi * time_grid ),
sqrt( time_grid ),
10 * ( time_grid - 0.5 ) * time_grid ),
nrow = 3, byrow = TRUE )
D3 = generate_gauss_mfdata( N, L, centerline,
correlations = c( 0.5, 0.5, 0.5 ),
listCov = list( C1, C2, C3 ) )
# adding names for better readability of BC3's labels
names( D3 ) = c( 'comp1', 'comp2', 'comp3' )
mfD3 = mfData( time_grid, D3 )
D1 = generate_gauss_fdata( N, centerline = sin( 2 * pi * time_grid ),
Cov = Cov )
fD1 = fData( time_grid, D1 )
# Computing the block covariance function of mfD3
BC3 = cov_fun( mfD3 )
str( BC3 )
# computing cross-covariance between mfData and fData objects
CC = cov_fun( mfD3, fD1 )
str( CC )
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.