| probeSmooths | R Documentation |
data.frame in long format, computes and compares, for
sets of smoothing parameters, smooths of the response, possibly along with
growth rates calculated from the smooths.Takes an observed response and, for each individual, uses
byIndv4Times_SplinesGRs to smooth its values employing the smoothing
parameters specified by (i) spline.types, (ii) the tuning
parameters, being the degrees of freedom values in df or the
smoothing penalties in lambdas, and (iii) the
smoothing.methods. The values of these, and other, smoothing
arguments are set using the helper function
args4smoothing.
Provided get.rates is TRUE or includes raw and/or
smoothed and depending on the setting
of trait.types, the Absolute Growth Rates (AGR) and/or the
Relative Growth Rates (RGR) are calculated for each individual from the
unsmoothed, observed response and from the smooths of the
response, using either differences or first derivatives, as
specified by rates.method.
Generally, profile plots for the traits (a response, an AGR or an RGR)
specified in traits.types are produced if which.plots is
profiles; if which.plots specifies one or more deviations
plots, then those deviations plots will also be produced, these being
based on the unsmoothed data from which the smoothed data has been
subtracted. The layout of the plots is controlled via combinations of
one or more of the smoothing-parameter factors Type,
TunePar, TuneVal, Tuning (the combination
of TunePar and TuneVal) and Method, as well as
other factors associated with the data.
The factors that are to be used for the profile plots
are supplied via the argument profile.plot.args
using the helper function args4profile_plot and for the
and deviations boxplots using the helper function
args4devnboxes_plot. These helper functions set
plots.by, facet.x, and facet.y. For the plots of
the medians of the deviations, the factors are supplied via
the argument meddevn.plot.args using the helper function
args4meddevn_plot to set plots.by, facet.x,
facet.y and plots.group. Here, the basic principle is that
the number of levels combinations of the smoothing-parameter
factors included in the set of plots and
facets arguments to one of these helper functions must be the same
as those covered by the combinations of the values supplied to
spline.types, df, lambdas and smoothing.methods
and incorporated into the smooths.frame, such as is
returned by probeSmooths. This ensures that smooths
from different parameter sets are not pooled together in a single plot.
It is also possible to include factors that are not
smoothing-parameter factors in the plots amd
facets arguments.
The following profiles plots can be produced using
args4profile_plot: (i) separate plots of the
smoothed traits for each combination of the smoothing parameters
(include Type, Tuning and Method in plots.by);
(ii) as for (i), with the corresponding plot for the unsmoothed trait
preceeding the plots for the smoothed trait (also set include.raw to
alone); (iii) profiles plots that compare a smoothed trait for all
combinations of the values of the smoothing parameters, arranging the plots
side-by-side or one above the other (include Type, Tuning and
Method in facet.x and/or facet.y - to include the
unsmoothed trait set include.raw to one of facet.x or
facet.y; (iv) as for (iii), except that separate plots are
produced for each combination of the levels of the factors
in plot.by and each plot compares the smoothed traits for the
smoothing-parameter factors included in facet.x
and/or facet.y (set both plots.by and one or more of
facet.x and facet.y).
Deviation plots that can be produced are the absolute and relative deviations
boxplots and plots of medians deviations (see which.plots).
The handling of missing values is controlled via na.x.action and
na.y.action supplied to the helper function args4smoothing.
The probeSmooths arguments are grouped according to function in the following order:
Data description arguments: data, response, response.smoothed, individuals, times, keep.columns, trait.types, get.rates, rates.method, ntimes2span.
Smoothing arguments: smoothing.args (see args4smoothing).
General plot control: x.title, y.titles, facet.labeller, which.plots.
Profile plots (pf) features: profile.plot.args (see args4profile_plot)
Median-deviations (med) plots features: meddevn.plot.args (see args4meddevn_plot)
Deviations boxplots (box) features: devnboxes.plot.args (see args4devnboxes_plot)
probeSmooths(data, response = "PSA", response.smoothed = NULL,
individuals="Snapshot.ID.Tag", times = "DAP",
keep.columns = NULL,
get.rates = TRUE,
rates.method="differences", ntimes2span = NULL,
trait.types = c("response", "AGR", "RGR"),
smoothing.args =
args4smoothing(smoothing.methods = "direct",
spline.types = "NCSS",
df = NULL, lambdas = NULL),
x.title = NULL, y.titles = NULL,
which.plots = "profiles",
profile.plot.args =
args4profile_plot(plots.by = NULL,
facet.x = ".", facet.y = ".",
include.raw = "no"),
meddevn.plot.args =
args4meddevn_plot(plots.by = NULL, plots.group = NULL,
facet.x = ".", facet.y = ".",
propn.note = TRUE,
propn.types = c(0.1, 0.5, 0.75)),
devnboxes.plot.args =
args4devnboxes_plot(plots.by = NULL,
facet.x = ".", facet.y = ".",
which.plots = "none"),
...)
data |
A |
response |
A |
response.smoothed |
A |
individuals |
A |
times |
A |
keep.columns |
A |
get.rates |
A |
rates.method |
A |
ntimes2span |
A |
trait.types |
A |
smoothing.args |
A |
x.title |
Title for the x-axis, used for all plots. If |
y.titles |
A |
which.plots |
A Boxplots of the absolute deviations are specified by
The option |
profile.plot.args |
A named |
meddevn.plot.args |
A named |
devnboxes.plot.args |
A named |
... |
allows passing of arguments to |
A smooths.frame that contains the unsmoothed and smoothed data
in long format. That is, all the values for either an unsmoothed or a
smoothed trait are in a single column. The smooths for a trait for the
different combinatons of the smoothing parameters are placed in rows one
below the other. The columns that are included in the smooths.frame
are Type, TunePar, TuneVal, Tuning and Method,
as well as those specified by individuals, times, response, and
response.smoothed. and any included in the keep.columns, plots
and facet arguments.
If trait.types includes AGR or RGR, then the included growth
rate(s) of the response and response.smoothed must be present, unless
get.rates is TRUE or includes raw and/or smoothed. In this case,
the growth rates specified by trait.types will be calculated for the responses
nominated by get.rates and the differences between the times
used in calculating the rates will be computed and added. Then, the names of the
growth rates are formed from response and response.smoothed by
appending .AGR and .RGR as appropriate; the name of the column with
the times differences will be formed by appending .diffs to the
value of times. The external.smooths will also be included.
A smooths.frame has the attributes described in
smooths.frame.
Columns in the supplied data.frame that have not been used in
probeSmooths will not be included in the returned smooths.frame.
If they might be needed subsequently, such as when extra plots are produced, they
can be included in the smooths.frame by listing them in a
character vector for the keep.columns argument.
The smooths.frame is returned invisibly.
Chris Brien
args4smoothing, , args4meddevn_plot, args4profile_plot,
traitSmooth,
smoothSpline, byIndv4Times_SplinesGRs, byIndv4Times_GRsDiff,
smooth.spline, psNormal, plotSmoothsComparison,
plotSmoothsMedianDevns, ggplot.
data(exampleData)
longi.dat <- longi.dat[1:140,] #reduce to a smaller data set
vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", linewidth=1))
yfacets <- c("Smarthouse", "Treatment.1")
probeSmooths(data = longi.dat,
response = "PSA", response.smoothed = "sPSA",
individuals = "Snapshot.ID.Tag",times = "DAP",
smoothing.args =
args4smoothing(df = c(4,7),
lambda = list(PS = c(0.316,10))),
profile.plot.args =
args4profile_plot(plots.by = NULL,
facet.x = "Tuning",
facet.y = c("Smarthouse", "Treatment.1"),
include.raw = "no",
alpha = 0.4,
colour.column = "Method",
colour.values = c("orange", "olivedrab"),
ggplotFuncs = vline))
#An example that supplies three smoothing schemes to be compared
data(tomato.dat)
probeSmooths(data = tomato.dat,
response = "PSA", response.smoothed = "sPSA",
times = "DAP",
smoothing.args =
args4smoothing(spline.types = c( "N", "NCS", "P"),
df = c( 4, 6, NA),
lambdas = c( NA, NA, 1),
smoothing.methods = c("dir", "log", "log"),
combinations = "parallel"),
which.plots = "medians.deviations",
meddevn.plot.args =
args4meddevn_plot(plots.by = NULL,
plots.group = c("Type", "Tuning", "Method"),
facet.x = ".", facet.y = ".",
propn.note = FALSE, propn.types = NULL))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.