probeSmoothing {growthPheno} | R Documentation |
Compares, for a set of specified values of df and different smoothing methods,
a response and the smooths of it, possibly along with growth rates calculated
from the smooths
Description
Takes a response
and, for each individual
, uses
splitSplines
to smooth its values for each individual
using the degrees of freedom values in df
.
Provided get.rates
is TRUE
,
both the Absolute Growth Rates (AGR) and the Relative Growth Rates (RGR)
are calculated for each smooth, either using differences or first
derivatives. A combination of the unsmoothed and smoothed values,
as well as the AGR and RGR, can be plotted for each value in
smoothing methods
in combination with df
. Note that the
arguments that modify the plots apply to all
plots that are produced. The handling of missing values is controlled
via na.x.action
and na.y.action
Note: this function is soft deprecated and may be removed in
future versions.
Use probeSmooths
.
Usage
probeSmoothing(data, response = "Area", response.smoothed = NULL,
x = NULL, xname="xDays",
times.factor = "Days", individuals="Snapshot.ID.Tag",
na.x.action="exclude", na.y.action = "exclude",
df, smoothing.methods = "direct", correctBoundaries = FALSE,
get.rates = TRUE, rates.method="differences",
facet.x = "Treatment.1", facet.y = "Smarthouse",
labeller = NULL, x.title = NULL,
colour = "black", colour.column=NULL,
colour.values=NULL, alpha = 0.1,
trait.types = c("response", "AGR", "RGR"),
propn.types = c(0.1, 0.5, 0.75), propn.note = TRUE,
which.plots = "smoothedonly",
deviations.plots = "none", alpha.med.devn = 0.5,
ggplotFuncs = NULL, ggplotFuncsMedDevn = NULL,
...)
Arguments
data |
A data.frame containing the data.
|
response |
A character specifying the response variable to be
supplied to smooth.spline and that is to be plotted
on the y-axis.
|
response.smoothed |
A character specifying the name of the column
containing the values of the smoothed response variable, corresponding
to response . If response.smoothed is NULL , then
response.smoothed is set to the response to which
.smooth is added.
|
x |
A character giving the variable to be plotted on the
x-axis; it may incorporate an expression. If x is NULL then
xname is used.
|
xname |
A character giving the name of the
numeric that contains the values of the predictor
variable to be supplied to smooth.spline and
from which x is derived.
|
times.factor |
A character giving the name of the column in
data containing the factor for times at which the data was
collected. Its levels will be used in calculating growth rates and
should be numeric values stored as characters.
|
individuals |
A character giving the name of the
factor that defines the subsets of the data
for which each subset corresponds to the response values for
an individual (e.g. plant, pot, cart, plot or unit).
|
na.x.action |
A character string that specifies the action to
be taken when values of x are NA . The possible
values are fail , exclude or omit .
For exclude and omit , predictions and derivatives
will only be obtained for nonmissing values of x .
The difference between these two codes is that for exclude the returned
data.frame will have as many rows as data , the
missing values have been incorporated.
|
na.y.action |
A character string that specifies the action to
be taken when values of y , or the response , are
NA . The possible values are fail , exclude ,
omit , allx , trimx , ltrimx or
rtrimx . For all options, except fail , missing
values in y will be removed before smoothing.
For exclude and omit , predictions
and derivatives will be obtained only for nonmissing values of
x that do not have missing y values. Again, the
difference between these two is that, only for exclude
will the missing values be incorporated into the
returned data.frame . For allx , predictions and
derivatives will be obtained for all nonmissing x .
For trimx , they will be obtained for all nonmissing
x between the first and last nonmissing y values
that have been ordered for x ; for ltrimx and
utrimx either the lower or upper missing y
values, respectively, are trimmed.
|
df |
A numeric specifying the set of degrees of freedom to
be probed.
|
smoothing.methods |
A character giving the smoothing method
to use. The two possibilites are (i) "direct" , for directly
smoothing the observed response , and (ii) "logarithmic" , for
smoothing the log -transformed response and then
back-transforming by taking the exponentional of the fitted values.
|
correctBoundaries |
A logical indicating whether the fitted spline
values are to have the method of Huang (2001) applied
to them to correct for estimation bias at the end-points. Note that
spline.type must be NCSS and lambda and deriv
must be NULL for correctBoundaries to be set to TRUE .
|
get.rates |
A logical specifying whether or not the growth
rates (AGR and RGR) are to be computed and stored.
|
rates.method |
A character specifying the method to use in
calculating the growth rates. The two possibilities are
"differences" and "derivates" .
|
facet.x |
A data.frame giving the variable to be used to
form subsets to be plotted in separate columns of plots.
Use "." if a split into columns is not wanted. For
which.plots set to methodscompare or
dfcompare , facet.x is ignored.
|
facet.y |
A data.frame giving the variable to be used to
form subsets to be plotted in separate rows of plots.
Use "." if a split into columns is not wanted.
|
labeller |
A ggplot function for labelling the
facets of a plot produced using the ggplot function.
For more information see ggplot .
|
x.title |
Title for the x-axis. If NULL then set to times.factor .
|
colour |
A character specifying a single colour to use in
drawing the lines for the profiles. If colouring according to the
values of a variable is required then use colour.column .
|
colour.column |
A character giving the name of a column
in data over whose values the colours of the lines are to be
varied. The colours can be specified using colour.values .
|
colour.values |
A character vector specifying the values of
the colours to use in drawing the lines for the profiles.
If this is a named vector, then the values will be matched based
on the names. If unnamed, values will be matched in order
(usually alphabetical) with the limits of the scale.
|
alpha |
A numeric specifying the degrees of transparency to
be used in plotting. It is a ratio in which the denominator
specifies the number of points (or lines) that must be overplotted
to give a solid cover.
|
trait.types |
A character giving the trait.types that
are to be produced, and potentially plotted. One of more of
response , AGR and RGR . If all , all three
traits are produced.
|
propn.types |
A numeric giving the proportion of the median
values of each of the trait.types that are to be plotted in
the compare.medians plots of the deviations of the observed
values from the smoothed values. If set
to NULL , the plots of the proportions of the median values of
the traits are omitted.
|
propn.note |
A logical indicating whether a note giving the
proportion of the median values plotted in the compare.medians
plots.
|
which.plots |
A character giving the plots that are to be
produced. If none , no plots are produced. If smoothedonly ,
plots of the smoothed traits are plotted. If bothseparately ,
plots of the unsmoothed trait followed by the smoothed traits are
produced for each trait. If methodscompare , a combined plot of
the smoothed traits for each smoothing.methods is produced,
for each value of df . If methods+rawcompare , the unsmoothed
trait is added to the combined plot. if dfcompare , a combined
plot of the smoothed trait for each df is produced, for each
smoothing.methods . If df+rawcompare , the unsmoothed
trait is added to the combined plot.
|
deviations.plots |
A character is either none or any
combination of absolute.boxplots , relative.boxplots and
compare.medians . If none , no plots are produced.
Boxplots of the absolute and relative deviations are specified by
absolute.boxplots and relative.boxplots . The absolute
deviations are the values of a trait minus their smoothed values
(observed - smoothed); the relative deviations are the absolute
deviations divided by the smoothed values of the trait. The option
compare.medians results in a plot that compares the medians
of the deviations over the times.factor for each combination
of the smoothing.methods and the df . The argument
trait.types controls the traits for which boxplots are produced.
|
alpha.med.devn |
A numeric specifying the degrees of
transparency to be used in plotting a median deviations plot.
It is a ratio in which the denominator specifies the number of
points (or lines) that must be overplotted to give a solid cover.
|
ggplotFuncs |
A list , each element of which contains the
results of evaluating a ggplot function.
It is created by calling the list function with
a ggplot function call for each element.
These functions are applied to all three plots produced.
|
ggplotFuncsMedDevn |
A list , each element of which contains the
results of evaluating a ggplot function.
It is created by calling the list function with
a ggplot function call for each element. Note that
these functions are applied to the compare.median deviations plots only.
|
... |
allows passing of arguments to plotLongitudinal .
|
Value
A data.frame
containing individuals
,
times.factor
, facet.x
, facet.y
, xname
,
response
, and, for each df
, the smoothed
response, the AGR and the RGR. It is returned invisibly. The names of
the new data are constructed by joining elements separated by full
stops (.
). In all cases, the last element is the value of
df
. For the smoothed response, the other elements are
response
and "smooth"
; for AGR and RGR, the other elements
are the name of the smoothed response and either "AGR"
or
"RGR"
.
Author(s)
Chris Brien
See Also
splitSplines
, splitContGRdiff
, smooth.spline
, ggplot
.
Examples
data(exampleData)
vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1),
ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2)))
probeSmoothing(data = longi.dat, response = "PSA", df = c(4,7),
xname = "xDAP", times = "DAP",
ggplotFuncs=vline)
[Package
growthPheno version 2.1.25
Index]