Description Usage Arguments Examples

Returns the additive component of the RGAM model for a given feature at given data points, i.e. f_j(X_j).

1 | ```
getf(object, x, j, index)
``` |

`object` |
Fitted |

`x` |
Data for which we want the additive component. If |

`j` |
The index of the original feature whose additive component we want. |

`index` |
Index of lambda value for which plotting is desired. Default is
the last lambda value in |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
set.seed(1)
n <- 100; p <- 20
x <- matrix(rnorm(n * p), n, p)
beta <- matrix(c(rep(2, 5), rep(0, 15)), ncol = 1)
y <- x %*% beta + rnorm(n)
fit <- rgam(x, y)
# get the additive component for the feature 6, x as matrix
f6 <- getf(fit, x, 6) # last value of lambda
plot(x[, 6], f6)
f6 <- getf(fit, x, 6, index = 20) # f1 at 20th value of lambda
plot(x[, 6], f6)
# get the additive component for the feature 6, x as vector
new_x6 <- seq(-1, 1, length.out = 30)
new_f6 <- getf(fit, new_x6, 6) # last value of lambda
plot(new_x6, new_f6)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.