frfast(formula, data = data, model = "np", smooth = "kernel", h0 = -1, h = -1, nh = 30, weights = NULL, kernel = "epanech", p = 3, kbin = 100, nboot = 500, rankl = NULL, ranku = NULL, seed = NULL, cluster = TRUE, ncores = NULL, ...)formula: a sympbolic
description of the model to be fitted. The details of model
specification are given under 'Details'.formula.model = "np" nonparametric
regression model,
model = "allo" the allometric model.smooth = "kernel" for local polynomial
kernel smoothers and smooth = "splines" for splines using the
mgcv package.h is discretised, to speed up computation in the kernel-based regression.kernel = "epanech", where the Epanechnikov
density function kernel will be used. Also, several types of kernel functons
can be used: triangular and Gaussian density function,
with "triang" and "gaussian" term, respectively.model = "np" and the simple bootstrap
when model = "allo".x value which maximizes the
estimate, first or second derivative (for each level). The default
is the minimum data value.x value which maximizes the
estimate, first or second derivative (for each level). The default
is the maximum data value.TRUE (default), the
bootstrap procedure is parallelized (only for smooth = "splines").
Note that there are cases
(e.g., a low number of bootstrap repetitions) that R will gain in
performance through serial computation. R takes time to distribute tasks
across the processors also it will need time for binding them all together
later on. Therefore, if the time for distributing and gathering pieces
together is greater than the time need for single-thread computing, it does
not worth parallelize.NULL (default), the number of cores
to be used is equal to the number of cores of the machine - 1.x which maximizes the estimate,
first or second derivative.max.max.max for a
couple of levels (i. e. level 2 - level 1). The same procedure for their
first and second derivative.diffmax.diffmax.x value which maximizes the estimate, first or second derivative
(for each level). The default is the maximum data value.x value which maximizes the estimate, first or second derivative
(for each level). The default is the minimum data value.nmodel = 1 the nonparametric model,
nmodel = 2 the allometric model.a.a.b.b.h is discretised.frfast function are specified
in a compact symbolic form. The \~ operator is basic in the formation
of such models. An expression of the form y ~ model is interpreted as
a specification that the response y is modelled by a predictor
specified symbolically by model. The possible terms consist of a
variable name or a variable name and a factor name separated by : operator.
Such a term is interpreted as the interaction of the continuous variable and
the factor. However, if smooth = "splines", the formula is based on the function
formula.gam of the mgcv package.
library(npregfast)
data(barnacle)
# Nonparametric regression without interactions
fit <- frfast(DW ~ RC, data = barnacle, nboot = 100, smooth = "kernel")
fit
summary(fit)
# using splines
#fit <- frfast(DW ~ s(RC), data = barnacle, nboot = 100,
#smooth = "splines", cluster = TRUE, ncores = 2)
#fit
#summary(fit)
# Change the number of binning nodes and bootstrap replicates
fit <- frfast(DW ~ RC, data = barnacle, kbin = 200,
nboot = 100, smooth = "kernel")
# Nonparametric regression with interactions
fit2 <- frfast(DW ~ RC : F, data = barnacle, nboot = 100)
fit2
summary(fit2)
# using splines
#fit2 <- frfast(DW ~ s(RC, by = F), data = barnacle,
# nboot = 100, smooth = "splines", cluster = TRUE, ncores = 2)
#fit2
#summary(fit2)
# Allometric model
fit3 <- frfast(DW ~ RC, data = barnacle, model = "allo", nboot = 100)
summary(fit3)
# fit4 <- frfast(DW ~ RC : F, data = barnacle, model = "allo", nboot = 100)
# summary(fit4)
Run the code above in your browser using DataLab