These functions can be useful when setting up new model fitting engines that are based on the setup function bamlss.engine.setup. See the examples.

## Functions to extract parameter states.
get.par(x, what = NULL)
get.state(x, what = NULL)
set.par(x, replacement, what)

## Function for setting starting values.
set.starting.values(x, start)

Arguments

x

For function get.par() and set.par() argument x is a named numeric vector. For function get.state() argument x is an object of the smooth.construct list that is processed by function bamlss.engine.setup, i.e., which has a "state" object. For function set.starting.values() argument x is the x list, as returned from function bamlss.frame.

what

The name of the parameter(s) that should be extracted or replaced.

replacement

The value(s) that should be used for replacement.

start

The named numeric vector of starting values. The name convention is based on function parameters.

See also

Examples

## Create a bamlss.frame. d <- GAMart() bf <- bamlss.frame(num ~ s(x1) + s(x2) + te(lon,lat), data = d, family = "gaussian") names(bf$x$mu$smooth.construct)
#> [1] "s(x1)" "s(x2)" "te(lon,lat)"
## Use the setup function for ## adding state elements. bf$x <- bamlss.engine.setup(bf$x, df = c("s(x1)" = 1, "s(x2)" = 3)) names(bf$x$mu$smooth.construct)
#> [1] "s(x1)" "s(x2)" "te(lon,lat)" "model.matrix"
## Extract regression coefficients. get.state(bf$x$mu$smooth.construct[["te(lon,lat)"]], "b")
#> b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 #> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> b21 b22 b23 b24 #> 0 0 0 0
## Extract smoothing variances. get.state(bf$x$mu$smooth.construct[["te(lon,lat)"]], "tau2")
#> tau21 tau22 #> 0.04087266 0.10000000
## More examples. state <- bf$x$mu$smooth.construct[["te(lon,lat)"]]$state get.par(state$parameters, "b")
#> b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 #> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> b21 b22 b23 b24 #> 0 0 0 0
get.par(state$parameters, "tau2")
#> tau21 tau22 #> 0.04087266 0.10000000
state$parameters <- set.par(state$parameters, c(0.1, 0.5), "tau2") get.par(state$parameters, "tau2")
#> tau21 tau22 #> 0.1 0.5
## Setting starting values. start <- c("mu.s.s(x1).b" = 1:9, "mu.s.s(x1).tau2" = 0.1) bf$x <- set.starting.values(bf$x, start = start) get.state(bf$x$mu$smooth.construct[["s(x1)"]], "b")
#> b1 b2 b3 b4 b5 b6 b7 b8 b9 #> 1 2 3 4 5 6 7 8 9
get.state(bf$x$mu$smooth.construct[["s(x1)"]], "tau2")
#> tau21 #> 0.1