Evaluate basis functions and compute the function defined by the corresponding basis

1 2 3 4 5 6 7 | ```
## S3 method for class 'basis'
predict(object, newdata, coef, dim = !is.data.frame(newdata), ...)
## S3 method for class 'cbind_bases'
predict(object, newdata, coef, dim = !is.data.frame(newdata),
terms = names(object), ...)
## S3 method for class 'box_bases'
predict(object, newdata, coef, dim = !is.data.frame(newdata), ...)
``` |

`object` |
a |

`newdata` |
a |

`coef` |
a vector of coefficients |

`dim` |
either a logical indicating that the dimensions shall be
obtained from the |

`terms` |
a character vector defining the elements of a |

`...` |
additional arguments |

`predict`

evaluates the basis functions and multiplies them with `coef`

.
There is no need to expand multiple variables as `predict`

uses array models
(Currie et al, 2006) to compute the corresponding predictions efficiently.

Ian D. Currie, Maria Durban, Paul H. C. Eilers, P. H. C. (2006), Generalized Linear
Array Models with Applications to Multidimensional Smoothing,
*Journal of the Royal Statistical Society, Series B: Methodology*, **68**(2),
259–280.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
### set-up a Bernstein polynomial
xv <- numeric_var("x", support = c(1, pi))
bb <- Bernstein_basis(xv, order = 3, ui = "increasing")
## and treatment contrasts for a factor at three levels
fb <- as.basis(~ g, data = factor_var("g", levels = LETTERS[1:3]))
### join them: we get one intercept and two deviation _functions_
bfb <- b(bern = bb, f = fb)
### generate data + coefficients
x <- mkgrid(bfb, n = 10)
cf <- c(1, 2, 2.5, 2.6)
cf <- c(cf, cf + 1, cf + 2)
### evaluate predictions for all combinations in x (a list!)
predict(bfb, newdata = x, coef = cf)
## same but slower
matrix(predict(bfb, newdata = expand.grid(x), coef = cf), ncol = 3)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.