frfast | R Documentation |
This function is used to fit nonparametric models by using local polynomial kernel smoothers or splines. These models can include or not factor-by-curve interactions. Additionally, a parametric model (allometric model) can be estimated (or not).
frfast( formula, data, na.action = "na.omit", 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 |
An object of class |
data |
An optional data frame, matrix or list required by
the formula. If not found in data, the variables are taken from
|
na.action |
A function which indicates what should happen when the data contain 'NA's. The default is 'na.omit'. |
model |
Type model used: |
smooth |
Type smoother used: |
h0 |
The kernel bandwidth smoothing parameter for the global effect (see references for more details at the estimation). Large values of the bandwidth lead to smoothed estimates; smaller values of the bandwidth lead lo undersmoothed estimates. By default, cross validation is used to obtain the bandwidth. |
h |
The kernel bandwidth smoothing parameter for the partial effects. |
nh |
Integer number of equally-spaced bandwidth in which the
|
weights |
Prior weights on the data. |
kernel |
A character string specifying the desired kernel.
Defaults to |
p |
Polynomial degree to be used in the kernel-based regression. Its value must be the value of derivative + 1. The default value is 3, returning the estimation, first and second derivative. |
kbin |
Number of binning nodes over which the function is to be estimated. |
nboot |
Number of bootstrap repeats. Defaults to 500 bootstrap repeats.
The wild bootstrap is used when |
rankl |
Number or vector specifying the minimum value for the
interval at which to search the |
ranku |
Number or vector specifying the maximum value for the
interval at which to search the |
seed |
Seed to be used in the bootstrap procedure. |
cluster |
A logical value. If |
ncores |
An integer value specifying the number of cores to be used
in the parallelized procedure. If |
... |
Other options. |
The models fitted by 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.
According with the model
argument, if model = "np"
the
estimated regression model will be of the type
Y = m(X) + e
being m an smooth and unknown function and e
the regression error with zero mean. If model = "allo"
, users could estimate
the classical allometric model (Huxley, 1924) with a regression curve
m(X) = a X^b
being a and b the parameters of the model.
An object is returned with the following elements:
x |
Vector of values of the grid points at which model is to be estimate. |
p |
Matrix of values of the grid points at which to compute the estimate, their first and second derivative. |
pl |
Lower values of 95% confidence interval for the estimate, their first and second derivative. |
pu |
Upper values of 95% confidence interval for the estimate, their first and second derivative. |
diff |
Differences between the estimation values of a couple of levels (i. e. level 2 - level 1). The same procedure for their first and second derivative. |
diffl |
Lower values of 95% confidence interval for the differences between the estimation values of a couple of levels. It is performed for their first and second derivative. |
diffu |
Upper values of 95% confidence interval for the differences between the estimation values of a couple of levels. It is performed for their first and second derivative. |
nboot |
Number of bootstrap repeats. |
n |
Sample size. |
dp |
Degree of polynomial to be used. |
h0 |
The kernel bandwidth smoothing parameter for the global effect. |
h |
The kernel bandwidth smoothing parameter for the partial effects. |
fmod |
Factor's level for each data. |
xdata |
Original x values. |
ydata |
Original y values. |
w |
Weights on the data. |
kbin |
Number of binning nodes over which the function is to be estimated. |
nf |
Number of levels. |
max |
Value of covariate |
maxu |
Upper value of 95% confidence interval for the
value |
maxl |
Lower value of 95% confidence interval for the
value |
diffmax |
Differences between the estimation of |
diffmaxu |
Upper value of 95% confidence interval for the value
|
diffmaxl |
Lower value of 95% confidence interval for the value
|
repboot |
Matrix of values of the grid points at which to compute the estimate, their first and second derivative for each bootstrap repeat. |
rankl |
Maximum value for the interval at which to search the
|
ranku |
Minimum value for the interval at which to search the
|
nmodel |
Type model used: |
label |
Labels of the variables in the model. |
numlabel |
Number of labels. |
kernel |
A character specifying the derised kernel. |
a |
Estimated coefficient in the case of fitting an allometric model. |
al |
Lower value of 95% confidence interval for the value of |
au |
Upper value of 95% confidence interval for the value of |
b |
Estimated coefficient in the case of fitting an allometric model. |
bl |
Lower value of 95% confidence interval for the value of |
bu |
Upper value of 95% confidence interval for the value of |
name |
Name of the variables in the model. |
formula |
A sympbolic description of the model to be fitted. |
nh |
Integer number of equally-spaced bandwidth on which the
|
r2 |
Coefficient of determination (in the case of the allometric model). |
smooth |
Type smoother used. |
cluster |
Is the procedure parallelized? (for splines smoothers). |
ncores |
Number of cores used in the parallelized procedure? (for splines smoothers). |
Marta Sestelo, Nora M. Villanueva and Javier Roca-Pardinas.
Huxley, J. S. (1924). Constant differential growth-ratios and their significance. Nature, 114:895–896.
Sestelo, M. (2013). Development and computational implementation of estimation and inference methods in flexible regression models. Applications in Biology, Engineering and Environment. PhD Thesis, Department of Statistics and O.R. University of Vigo.
Sestelo, M., Villanueva, N.M., Meira-Machado, L., Roca-Pardinas, J. (2017). npregfast: An R Package for Nonparametric Estimation and Inference in Life Sciences. Journal of Statistical Software, 82(12), 1-27.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.