predict.addHierBasis: Model Predictions for Additive HierBasis

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/hier_basis_additive.R

Description

The generic S3 method for predictions for objects of class addHierBasis.

Usage

1
2
3
## S3 method for class 'addHierBasis'
predict(object, new.x = NULL, refit = FALSE,
  ...)

Arguments

object

A fitted object of class 'addHierBasis'.

new.x

An optional matrix of values of x at which to predict. The number of columns of new.x should be equal to the number of columns of object$x.

refit

Should predictions be given based on re-fitted least squares estimates. This is only compatible if refit == TRUE in AdditiveHierBasis.

...

Not used. Other arguments for predict function.

Details

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.

Value

fitted.values

A matrix of fitted values with nrow(new.x) rows and nlam columns

Author(s)

Asad Haris (aharis@uw.edu), Ali Shojaie and Noah Simon

References

Haris, A., Shojaie, A. and Simon, N. (2018). Nonparametric Regression with Adaptive Smoothness via a Convex Hierarchical Penalty. Available on request by authors.

See Also

AdditiveHierBasis, plot.addHierBasis

Examples

 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))

asadharis/HierBasis documentation built on Aug. 3, 2021, 4:16 p.m.