Takes a fitted frfast object and produces predictions
(with their 95% confidence intervals) from a fitted model with
interactions or without interactions.
Usage
# S3 method for frfast
predict(object = model, newdata, fac = NULL, der = NULL, seed = NULL, ...)Arguments
- object
A fitted
frfastobject as produced byfrfast().- newdata
A data frame containing the values of the model covariates at which predictions are required. If newdata is provided, then it should contain all the variables needed for prediction: a warning is generated if not.
- fac
Factor's level to take into account. By default is
NULL.- der
Number which determines any inference process. By default
derisNULL. If this term is0, the function returns the initial estimate. If it is1or2, it is designed for the first or second derivative, respectively.- seed
Seed to be used in the bootstrap procedure.
- ...
Other options.
Value
predict.frfast computes and returns a list containing
predictions of the estimates, first and second derivative,
with their 95% confidence intervals.
Examples
library(npregfast)
data(barnacle)
# Nonparametric regression without interactions
fit <- frfast(DW ~ RC, data = barnacle, nboot = 100)
nd <- data.frame(RC = c(10, 14, 18))
predict(fit, newdata = nd)
#> $Estimation
#> Pred Lwr Upr
#> [1,] 0.2170758 0.2127310 0.2246697
#> [2,] 0.5761761 0.5683398 0.5836086
#> [3,] 1.2611420 1.2445001 1.2785451
#>
#> $First_deriv
#> Pred Lwr Upr
#> [1,] 0.06050908 0.05847311 0.06255974
#> [2,] 0.12648909 0.12199960 0.13158479
#> [3,] 0.20630283 0.19366221 0.21788740
#>
#> $Second_deriv
#> Pred Lwr Upr
#> [1,] 0.005990312 0.005517764 0.006306726
#> [2,] 0.009904393 0.008934122 0.010635841
#> [3,] 0.002984966 -0.000233695 0.006756137
#>
#> attr(,"class")
#> [1] "predict.frfast"
# Nonparametric regression with interactions
# fit2 <- frfast(DW ~ RC : F, data = barnacle, nboot = 100)
# nd2 <- data.frame(RC = c(10, 15, 20))
# predict(fit2, newdata = nd2)
# predict(fit2, newdata = nd2, der = 0, fac = "barca")