fit_bsm: Fit a Bayesian semiparametric model

Description Usage Arguments Details Value See Also

View source: R/fit-ridge.R

Description

Fit a Bayesian semiparametric model that includes subject-specific curves.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
fit_bsm(
  fixed,
  data,
  spline,
  random = NULL,
  size = 1000,
  burn = 0,
  ridge = FALSE,
  init = NULL,
  prior = NULL,
  prec = NULL
)

Arguments

fixed

A formula y ~ x1 + x2 ... specifying the response and fixed effects. This routine looks up the variable from the data, before looking at the environment where the formula is defined.

data

A data frame with at least three columns (x, y and sub). If a pop column is also given, separate mean curves are fitted to each population.

spline

A list of formulae of splines s(x, by =, ...). This routine looks up the variable from the data, before looking at the environment where the formula is defined. See [s()] for more details.

random

A formula ~ u1 specifying the random effect term. Only one random effect is allowed at the moment. In the future, this argument might take a list of fomulae (so each formula corresponds to a random effect), or implement something like nlme::lme or lme4::lmer.

size

The number of samples to be drawn from the posterior.

burn

The number of samples to burn before recording. Default to one-tenth of size.

ridge

Use ridge regression or linear mixed effect models?

init

List of matrices of the coefficients, containing sub and pop. The columnns of the matrices correspond to each population/subject.

prior

List of hyperparameters of the covariance priors.

Details

This model is fitted in a Bayesian framework, that is, this routine gives the samples drawing from the posterior distribution associated to each regression coefficients. The population (mean) curves are penalised with a difference matrix of order deg + 1. The knots are equally spaced between range(data$x).

The intercepts for all splines, other than the subject-specific splines, are removed by default. This is to ensure that the intercept term in the spline is not spanning the same space as the (potential) main effect terms (and consequently having an unidentifiable model). For subject-specific splines, since all the coefficients are penalised, including an intercept will not result in an unidentifiable model.

Therefore, the intercept should be added manually either by setting 'intercept = TRUE' or adding it as fixed effects.

Value

A list with posterior means, samples and information of the basis functions.

See Also

[s()] for spline specification.


weiyaw/flexss documentation built on June 16, 2021, 7:48 a.m.