dt
basis allows for any of the standard mgcv
(or
user-defined) bases to be aplied to a transformed version of the
original terms. Smooths may be of any number of terms. Transformations
are specified by supplying a function of any or all of the original terms.
"by
" variables are not transformed.## S3 method for class 'dt.smooth.spec':
smooth.construct(object, data, knots)
s()
,
te()
, ti()
, or t2()
, with bs="dt"
object$term
(and object$by
). The by
variable is the last element.data
. Can be NULL
.smooth.construct
object from the
inner smooth (defined by xt$bs
), in addition to:
nterms = length(object$term)
. The tf
element can take one
of the following forms:
nargs
arguments, wherenargs <= nterms<="" code="">.
Ifnterms > 1
, it is assumed that this function will be applied to
the first term ofobject$term
. If all argument names of the
function are term names, then those arguments will correspond to those
terms; otherwise, they will correspond to the firstnargs
terms inobject$term
.=>
ntfuncs
, wherentfuncs<=nterms< code="">,
containing either the functions or character strings described above. If
this list is named with term names, then the transformation functions
will be applied to those terms; otherwise, they will be applied to the
firstntfuncs
terms inobject$term
.=nterms<>
"log"
: log transformation (univariate)"ecdf"
: empirical cumulative distribution function (univariate)"linear01"
: linearly rescale from 0 to 1 (univariate)"s-t"
: first term ("s") minus the second term ("t") (bivariate)"s/t"
: first term ("s") divided by the second term ("t") (bivariate)"QTransform"
: performs a time-specific ecdf transformation for
a bivariate smooth, where time is indicated by the first term, and$x$by the second term. Primarily for use withrefund::af
.function(x) {(x - max(x))/(max(x) - min(x))}
.
This function will result in incorrect predictions if the range of data for
which preditions are being made is not the same as the range of data that was
used to define the basis. The proper way to define this function:
function(x) {(x - max(x0))/(max(x0) - min(x0))}
.
By refering to x0
instead of x
, you are indicating that you
want to use the original data instead of the current data. This may seem
strange to refer to a variable that is not one of the arguments, but the
"dt"
constructor explicity places these variables in the environment
of the transformation function to make them available.object
should be creaated with an xt
argument. For
non-tensor-product smooths, this will be a list with the following elements:
tf
(required): a function or character string (or list of functions
and/or character strings) defining the coordinate transormations; see
further details below.bs
(optional): character string indicating thebs
for
the basis applied to the transformed coordinates; if empty, the appropriate
defaults are used.basistype
(optional): character string indicating type of
bivariate basis used. Options include"s"
(the default),"te"
,"ti"
, and"t2"
, which correspond tos
,te
,ti
, andt2
....
(optional): for tensor product smooths, additional arguments
to the function specified bybasistype
that are not available ins()
can be included here, e.g.d
,np
, etc.s()
to set up the basis,
and specifying the tensor product using xt$basistype
as described
above. If the basis is set up using te()
, then the variables in
object$term
will be split up, meaning all transformation functions
would have to be univariate.smooth.construct