mean.mfData: Cross-sectional mean of of a mfData object.

Description Usage Arguments Value See Also Examples

View source: R/fData.R

Description

This S3 method implements the cross-sectional mean of a multivariate functional dataset stored in a mfData object, i.e. the mean computed point-by-point along the grid over which the dataset is defined.

Usage

1
2
## S3 method for class 'mfData'
mean(x, ...)

Arguments

x

the multivariate functional dataset whose cross-sectional mean must be computed, in form of mfData object.

...

possible additional parameters. This argument is kept for compatibility with the S3 definition of mean, but it is not actually used.

Value

The function returns a mfData object with one observation defined on the same grid as the argument x's representing the desired cross-sectional mean.

See Also

mfData

Examples

 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
N = 1e2
L = 3
P = 1e2
grid = seq( 0, 1, length.out = P )

# Generating a gaussian functional sample with desired mean
target_mean = sin( 2 * pi * grid )
C = exp_cov_function( grid, alpha = 0.2, beta = 0.2 )
# Independent components
correlations = c( 0, 0, 0 )
mfD = mfData( grid,
              generate_gauss_mfdata( N, L,
                                     correlations = correlations,
                                     centerline = matrix( target_mean,
                                                          nrow = 3,
                                                          ncol = P,
                                                          byrow = TRUE ),
                                     listCov = list( C, C, C ) )
)

# Graphical representation of the mean
oldpar <- par(mfrow = c(1, 1))
par(mfrow = c(1, L))

for(iL in 1:L)
{
  plot(mfD$fDList[[iL]])
  plot(
    mean(mfD)$fDList[[iL]],
    col = 'black',
    lwd = 2,
    lty = 2,
    add = TRUE
  )
}

par(oldpar)

roahd documentation built on Nov. 4, 2021, 1:07 a.m.