dfpower {sitar}R Documentation

Tabulate BIC of SITAR models by degrees of freedom, fixed effects and xy power transformations

Description

dfpower fits a series of sitar models tabulated by combinations of a) specified degrees of freedom for the spline curve, b) specified fixed effects a, b, c, d, c) specified power transformations of x, and d) specified power transformations of y, returning a four-way array of function values (e.g. BIC) applied to each model. The function provides a convenient way to optimise the model.

Usage

dfpower(
  object,
  df,
  fixed,
  xpowers,
  ypowers,
  FUN = BICadj,
  maxIter = 50,
  drop = TRUE,
  verbose = FALSE
)

Arguments

object

fitted sitar model to be updated.

df

vector of integer spline degrees of freedom to be fitted (defaults to df in object).

fixed

character vector of fixed effects to be included (defaults to fixed in object, typically 'a + b + c').

xpowers

vector of powers to apply to x (defaults to the power of x in object).

ypowers

vector of powers to apply to y (defaults to the power of y in object).

FUN

function to be tabulated (default BICadj).

maxIter

maximum number of iterations per fit (default nlmeControl()$maxIter).

drop

logical which if TRUE (default) drops redundant dimensions and labels from the returned array.

verbose

logical controlling monitoring, which gives numIter for each model.

Details

xpowers and ypowers treat power 0 as log. The formula for x in object must be of the form x^power or fun(x), e.g. x, x^0.5 or log(x). More complex formulae e.g. log(x + 1) will fail. In this case fit the model with the variable x1 = x + 1 instead.

FUN can be any function returning a single numerical value, e.g. BICadj, BIC, AIC, varexp or sigma.

Other fixed effects in object for covariates in a.formula, b.formula, c.formula or d.formula are propagated through all the models. This also applies to the control argument if set in object.

The run-time can be shortened by reducing maxIter, as models often converge quickly or not at all.

Value

Four-way array of returned values, ranked with the largest dimensions first, and by default with single-level dimensions dropped.

Values are returned with changed sign if the model fit generates a warning, or as NA if there is an error.

Author(s)

Tim Cole tim.cole@ucl.ac.uk

See Also

aperm transposes the returned array; addmargins adds margins.

Examples

data(heights)
m1 <- sitar(x = age, y = height, id = id, data = heights, df = 4)


dfpower(m1, df = 4:6, fixed = c('a', 'a+b', 'a+c', 'a+b+c'),
  xpowers = 0:1, ypowers = 0:1, maxIter = 8)


[Package sitar version 1.4.0 Index]