Include a Random Effects Term in an Additive Model

DESCRIPTION:

Includes a random effects term in an additive model.

USAGE:

random(x, df, sigma) 

REQUIRED ARGUMENTS:

x
a factor

OPTIONAL ARGUMENTS:

df
the target degrees of freedom
sigma
the ratio of the noise variance to the variance of the response. sigma can be viewed as a shrinkage parameter.

VALUE:

x is returned with class "smooth", with an attribute named "call" which is to be evaluated in all.wam() by gam()

DETAILS:

This is an experimental smootherfor use with factors in gam(). It allows the fitted mean for a factor predictor to be shrunk towards the overall mean, where the amount of shrinking depends either on sigma, or on the equivalent df. Similar in spirit to smoothing splines, this fitting method can be justified on Bayesian grounds or by a random effects model.
Since factors are coded by model.matrix() into a set of contrasts, care has been taken to add an appropriate "contrast" attribute to the output of random(). This zero contrast results in a column of zeros in the model matrix, which is aliased with any column and is hence ignored.

SEE ALSO:

, .

EXAMPLES:

gam(y ~ random(f1) + random(f2, df = 3) + x) 
# fit a random effects model using gam()