plotFMM: Plot fitted FMM models

Description Usage Arguments Details Value Examples

View source: R/plotFMM.R

Description

plotFMM() is used to plot fitted FMM models. The function can either plot the fitted model against the data or each of the components of the model separately. Optionally 'ggplot2' can be used as graphic library.

Usage

1
2
plotFMM(objFMM, components = FALSE, plotAlongPeriods = FALSE,
		    use_ggplot2 = FALSE, legendInComponentsPlot = TRUE, textExtra = "")

Arguments

objFMM

Object of class 'FMM'.

components

A logical value indicating if the centered wave components of the model should be separately plotted (case where it is TRUE). If FALSE, the default, the fitted FMM model along with the observed data is plotted.

plotAlongPeriods

A logical value indicating if more than one period should be plotted in the plots by default. Its default value is FALSE.

use_ggplot2

A logical value. If FALSE, the default, R base graphics are used. If TRUE, 'ggplot2' library is used as graphics engine.

legendInComponentsPlot

A logical value indicating whether the legend should be plotted in the components plot. By defaults it is TRUE.

textExtra

A character vector for extra text to be added to the titles of the plots.

Details

plotFMM() can generate two types of plots: the basic plot compares the fitted model against the original data while the components plot represents separately the centered waves of the model (if the argument components is TRUE).

The function is also capable of plotting multiple periods if the data has more than one, as is the case in many applications such as chronobiology. In this case, the argument plotAlongPeriods should be TRUE. In the case of components plots the value taken by the latter argument is ignored as they are plotted along just one period.

While, by default, plots are created using base R graphics, 'ggplot2' can also be used for more aesthetic and customizable plots. Optional arguments legendInComponentsPlot and textExtra serve to control, respectively, whether a legend to the components plot should be added and adding extra text to the plot's title.

Value

None if base R graphics are used, a named ggplot2 list if 'ggplot2' is used.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Simulates an scenario in which an FMM model is suitable,
res <- generateFMM(2,3,1.5,2.3,0.1,outvalues = TRUE,sigmaNoise = 0.3, plot=FALSE)
# then a FMM model is fitted to the data.
fit <- fitFMM(res$y, lengthAlphaGrid = 10,lengthOmegaGrid = 5)
plotFMM(fit)

# Components plot of FMM Model fitted to neuronal data with various optional aesthetics
data("neuronalSpike")
fittedFMM2<-fitFMM(neuronalSpike, nback=2,
                   lengthAlphaGrid = 24,lengthOmegaGrid = 10, numReps = 1)

plotFMM(fittedFMM2, components = TRUE)
plotFMM(fittedFMM2, components = TRUE,
	       legendInComponentsPlot = FALSE,
	       textExtra = "Neuronal Data")

# Plot of fitted model to more than one period.
data("mouseGeneExp")
fittedFMM2<-fitFMM(mouseGeneExp, nPeriods = 2,
                   lengthAlphaGrid = 10,lengthOmegaGrid = 5)
plotFMM(fittedFMM2, plotAlongPeriods = TRUE)

FMM documentation built on March 2, 2021, 1:06 a.m.