Learn R Programming

funcharts (version 1.8.0)

plus_mfd: Add multivariate functional data

Description

Adds two objects of class mfd (elementwise on their coefficient arrays). The two objects must share the same basis system and number of variables. If one object contains a single replication (i.e., one observation) and the other contains multiple, the single replication is replicated across observations before addition.

Usage

plus_mfd(mfdobj1, mfdobj2)

# S3 method for mfd +(mfdobj1, mfdobj2)

Value

An object of class mfd with coefficients equal to the (possibly replicated) sum of the inputs. The fdnames are taken from the input providing the observation indexing after replication (if any), otherwise from mfdobj1.

Arguments

mfdobj1, mfdobj2

Objects of class mfd. If mfdobj2 is missing, unary plus is applied.

Details

If mfdobj2 is missing, the function returns mfdobj1 unchanged (i.e., unary plus).

Let the coefficient arrays have dimensions \((nbasis, nobs, nvar)\). The following checks/rules are enforced:

  • Both inputs must be mfd objects; otherwise an error is thrown.

  • The basis systems must be identical (checked via identical()).

  • The number of variables must match.

  • For the number of observations: if both \(nobs_1\) and \(nobs_2\) are greater than one, they must be equal; otherwise, the object with \(nobs = 1\) is replicated to match the other.

See Also

nobs, nbasis, nvar, mfd

Examples

Run this code
# Assuming mfdobj_a and mfdobj_b are 'mfd' objects on the same basis:
# mfdobj_a + mfdobj_b
# plus_mfd(mfdobj_a, mfdobj_b)

Run the code above in your browser using DataLab