spl1D {LMMsolver}R Documentation

Fit P-splines

Description

Fit multi dimensional P-splines using sparse implementation.

Usage

spl1D(
  x,
  nseg,
  pord = 2,
  degree = 3,
  scaleX = TRUE,
  xlim = range(x),
  cond = NULL,
  level = NULL
)

spl2D(
  x1,
  x2,
  nseg,
  pord = 2,
  degree = 3,
  scaleX = TRUE,
  x1lim = range(x1),
  x2lim = range(x2),
  cond = NULL,
  level = NULL
)

spl3D(
  x1,
  x2,
  x3,
  nseg,
  pord = 2,
  degree = 3,
  scaleX = TRUE,
  x1lim = range(x1),
  x2lim = range(x2),
  x3lim = range(x3)
)

Arguments

x, x1, x2, x3

The variables in the data containing the values of the x covariates.

nseg

The number of segments

pord

The order of penalty, default pord = 2

degree

The degree of B-spline basis, default degree = 3

scaleX

Should the fixed effects be scaled.

xlim, x1lim, x2lim, x3lim

A numerical vector of length 2 containing the domain of the corresponding x covariate where the knots should be placed. Default set to NULL, when the covariate range will be used.

cond

Conditional factor: splines are defined conditional on the level. Default NULL.

level

The level of the conditional factor. Default NULL.

Value

A list with the following elements:

Functions

See Also

LMMsolve

Examples

## Fit model on john.alpha data from agridat package.
data(john.alpha, package = "agridat")

## Fit a model with a 1-dimensional spline at the plot level.
LMM1_spline <- LMMsolve(fixed = yield ~ rep + gen,
                       spline = ~spl1D(x = plot, nseg = 20),
                       data = john.alpha)

summary(LMM1_spline)

## Fit model on US precipitation data from spam package.
data(USprecip, package = "spam")

## Only use observed data
USprecip <- as.data.frame(USprecip)
USprecip <- USprecip[USprecip$infill == 1, ]

## Fit a model with a 2-dimensional P-spline.
LMM2_spline <- LMMsolve(fixed = anomaly ~ 1,
                       spline = ~spl2D(x1 = lon, x2 = lat, nseg = c(41, 41)),
                       data = USprecip)

summary(LMM2_spline)


[Package LMMsolver version 1.0.7 Index]