Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/hier_basis_additive.R
The generic S3 method for predictions for objects of
class addHierBasis
.
1 2 3 |
object |
A fitted object of class ' |
new.x |
An optional matrix of values of |
refit |
Should predictions be given based on re-fitted least squares estimates.
This is only compatible if |
... |
Not used. Other arguments for predict function. |
This function returns a matrix of predicted values at the specified
values of x given by new.x
. Each column corresponds to a lambda value
used for fitting the original model.
If new.x == NULL
then this function simply returns
the fitted values of the estimated function at the original x values used for
model fitting. The predicted values are presented for each lambda value.
fitted.values |
A matrix of fitted values with |
Asad Haris (aharis@uw.edu), Ali Shojaie and Noah Simon
Haris, A., Shojaie, A. and Simon, N. (2018). Nonparametric Regression with Adaptive Smoothness via a Convex Hierarchical Penalty. Available on request by authors.
AdditiveHierBasis
, plot.addHierBasis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(HierBasis)
require(Matrix)
set.seed(1)
# Generate the points x.
n <- 100
p <- 30
x <- matrix(rnorm(n*p), ncol = p)
# A simple model with 3 non-zero functions.
y <- rnorm(n, sd = 0.1) + sin(x[, 1]) + x[, 2] + (x[, 3])^3
mod <- AdditiveHierBasis(x, y, nbasis = 50, max.lambda = 30,
beta.mat = NULL,
nlam = 50, alpha = 0.5,
lam.min.ratio = 1e-4, m.const = 3,
max.iter = 300, tol = 1e-4)
# Obtain predictions for new.x.
preds <- predict(mod, new.x = matrix(rnorm(n*p), ncol = p))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.