GetDoF.HierBasis: Extract Degrees of Freedom

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

View source: R/hier_basis.R

Description

Extract Degrees of Freedom

Usage

1

Arguments

object

An object of class HierBasis

Value

dof

A vector of degrees of freedom for the sequence of lambda values used for the fitted HierBasis model.

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

HierBasis, predict.HierBasis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
require(Matrix)

set.seed(1)

# Generate the points x.
n <- 300
x <- (1:300)/300

# A simple quadratic function.
y1 <- 5 * (x - 0.5)^2
y1dat <- y1 + rnorm(n, sd = 0.1)

poly.fit <- HierBasis(x, y1dat)
dof <- GetDoF.HierBasis(poly.fit)


ind <- which.min(abs(dof - 3))[1]
plot(x, y1dat, type = "p", ylab = "y1")
lines(x, y1, lwd = 2)
lines(x, poly.fit$fitted.values[, ind], col = "red", lwd = 2)

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