fitFMM | R Documentation |
fitFMM()
is used to fit FMM models. The only required argument to fit FMM models is the input data.
By default it is assumed that time points, corresponding to a single time period, are equally spaced from 0 to 2\pi
.
fitFMM(
vData,
nPeriods = 1,
timePoints = NULL,
nback = 1,
maxiter = nback,
betaOmegaRestrictions = 1:nback,
stopFunction = alwaysFalse,
omegaMin = 1e-04,
omegaMax = 0.9999,
lengthAlphaGrid = 48,
lengthOmegaGrid = 24,
omegaGrid = NULL,
numReps = 1,
showProgress = FALSE,
showTime = FALSE,
parallelize = FALSE,
restrExactSolution = FALSE
)
vData |
A numeric vector containing the data to be fitted a FMM model. |
nPeriods |
A numeric value specifying the number of periods at which |
timePoints |
A numeric vector containing the time points at which each data of one single period is observed. The default value is |
nback |
Number of FMM components to be fitted. Its default value is 1. |
maxiter |
Maximum number of iterations for the backfitting algorithm. By default, it is set at |
betaOmegaRestrictions |
An integer vector of length |
stopFunction |
Function to check the convergence criterion for the backfitting algorithm (see Details). |
omegaMin |
Lower bound for omega parameter and |
omegaMax |
Upper bound for omega parameter and |
lengthAlphaGrid |
Precision of the grid of alpha in the search of the best model. If it is increased, more possible values of alpha will be considered, resulting in an increasing in the computation time too.
By default, it is set to 48 possible values of alpha, equally spaced between 0 and |
lengthOmegaGrid |
Precision of the grid of omega in the search of the best model. If it is increased, more possible values of omega will be considered, resulting in an increasing in the computation time too. By default it is set to 24 possible values of omega. |
omegaGrid |
Set of initial omega values in the search of the best model. By default, |
numReps |
Number of times (alpha, omega) parameters are refined. Deprecated for non restricted models. |
showProgress |
|
showTime |
|
parallelize |
|
restrExactSolution |
|
Data will be collected over nPeriods
periods. When nPeriods > 1
the fitting is carried out by averaging the data collected
at each time point across all considered periods. The model is fitting to summarized data.
timePoints
is a n
-length numeric vector where n
is the number of different time points per period.
The stopFunction
argument can either be the functions alwaysFalse
or R2
included in the package or user-defined functions that have the same arguments. The included functions serve for the following:
alwaysFalse()
, its default value, which returns FALSE
to force maxiter
iterations; and
R2(vData,pred,prevPred,difMax = 0.001)
, a function that computes the difference between the explained variability in two consecutive iterations returning TRUE
when the convergence criterion is reached.
To calculate the explained variability difference, the data and the fitted values from the current and previous iteration are passed as arguments vData
, pred
and prevPred
, respectively. The convergence
criterion is fulfilled when the explained variability difference is less than the argument difMax
(by default 0.001).
An S4 object of class 'FMM'
with information about the fitted model. The object contains the following slots:
The time points as specified by the input argument. It is a numeric vector containing the time points at which each data of one single period is observed.
The data as specified by the input argument. It is a numeric vector containing the data to be fitted a FMM model. Data could be collected over multiple periods.
When the data has more than one period, a numeric vector containing data
averaging the data at each time point across all considered periods.
A numeric value containing the number of periods in data as specified by the input argument.
A numeric vector of the fitted values by the FMM model.
A numeric value of the estimated intercept parameter M
.
A numeric value or vector of the estimated FMM wave amplitude parameter(s) A
.
A numeric value or vector of the estimated FMM wave phase translation parameter(s) \alpha
.
A numeric value or vector of the estimated FMM wave skewness parameter(s) \beta
.
A numeric value or vector of the estimated FMM wave kurtosis parameter(s) \omega
.
A numeric value of the sum of the residual squares values.
A numeric vector specifying the explained variance by each of the fitted FMM components.
A numeric value specifying the number of iterations of the fitting algorithm.
Rueda C, Larriba Y, Peddada SD (2019). Frequency Modulated Moebius Model Accurately Predicts Rhythmic Signals in Biological and Physical Sciences. Scientific reports, 9 (1), 18701. https://www.nature.com/articles/s41598-019-54569-1
# A monocomponent FMM model is fitted.
FMM_data <- generateFMM(2, 3, 1.5, 2.3, 0.1,
from = 0, to = 2*pi, length.out = 100,
outvalues = TRUE, sigmaNoise = 0.3, plot = FALSE)
fit <- fitFMM(FMM_data$y, lengthAlphaGrid = 10, lengthOmegaGrid = 10)
summary(fit)
# Two component FMM model with beta and omega restricted
restFMM2w_data <- generateFMM(M = 3, A = c(7, 4), alpha = c(0.5, 5), beta = c(rep(3, 2)),
omega = rep(0.05, 2), from = 0, to = 2*pi, length.out = 100,
sigmaNoise = 0.3, plot = FALSE)
fit2w.rest <- fitFMM(restFMM2w_data$y, nback = 2, maxiter = 1, numReps = 1,
lengthAlphaGrid = 15, lengthOmegaGrid = 10,
betaOmegaRestrictions = c(1, 1))
plotFMM(fit2w.rest, components = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.