smooth.construct.ms.smooth.spec | R Documentation |
The function sets up a smooth term for shape constraint estimation of P-spline model terms. Note that this currently only works using boosting and backfitting.
## S3 method for class 'ms.smooth.spec'
smooth.construct(object, data, knots, ...)
object |
Either a smooth specification object, or object of class |
data |
A data frame or list, see also see function |
knots |
See function |
... |
Arguments passed to the smooth term constructor functions. |
See function see smooth.construct
.
bamlss.frame
, bamlss.formula
,
bamlss
, smooth.construct
.
## Not run: ## Generate some data.
set.seed(123)
n <- 300
x <- runif(n, -2, 3)
y <- sin(x) + rnorm(n, sd = 0.1)
d <- data.frame("y" = y, "x" = x)
## Increasing: constr = 1.
## Decreasing: constr = 2.
b <- bamlss(y ~ s2(x,bs="ms",xt=list(constr=1)),
data = d, optimizer = opt_bfit, sampler = sam_MVNORM)
## Predict and plot.
p <- predict(b, model = "mu", FUN = c95)
plot(y ~ x)
plot2d(p ~ x, add = TRUE, col.lines = 4, lwd = 2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.