Learn R Programming

gamlss (version 4.2-4)

ra: Specify Simple Random Effect In A GAMLSS Formula

Description

This is an experimental smoother for use with factors in gamlss(). It allows the fitted values for a factor predictor to be shrunk towards the overall mean, where the amount of shrinking depends either on lambda, or on the equivalent degrees of freedom (df). This function is slightly more general, but considerably slower than the random function .

Usage

ra(xfactor, xvector = NULL, df = NULL, lambda = NULL, order = 0, 
   estimate = FALSE, expl = NULL, data1 = NULL)

Arguments

xfactor
a factor defining the subjects grouping in a one factor random effect model term e.g. xfactor=Subjects
xvector
a variable if interaction with the xfactor is required xvector (experimental)
df
required equivalent degrees of freedom e.g. df=10
lambda
the smoothing parameter which is the reciprocal (i.e. inverse) of the variance of the random effect
order
the order of the difference in the matrix D, order=1 is for simple random effects, order=2 is for random walk order 1 and order=3 is for random walk order 2
estimate
whether to estimate the lambda parameter within the backfitting iterations (very unreliable). Set by default to estimate=FALSE. [The lambda parameter can be more accurately estimated by selecting the corresponding smoothing
expl
this allows an explanatory variable at the subject level to be fitted e.g. expl=~x1+x2
data1
the data frame for the subject level variables data1

Value

  • xfactor is returned with class "smooth", with an attribute named "call" which is to be evaluated in the backfitting additive.fit() called by gamlss()

Warning

This is experimental and likely to change soon

References

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554. Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use the GAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (see also http://www.gamlss.org/). Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, http://www.jstatsoft.org/v23/i07.

See Also

random, gamlss

Examples

Run this code
data(aids)
attach(aids)
# fitting a loess curve with span=0.4 plus the a quarterly  effect 
aids1<-gamlss(y~lo(~x,span=0.4)+qrt,data=aids,family=PO) # 
# now we string the quarterly  effect using random 
aids2<-gamlss(y~lo(~x,span=0.4)+ra(qrt,df=2),data=aids,family=PO) # 
plot(x,y)
lines(x,fitted(aids1),col="red")
lines(x,fitted(aids2),col="purple")
rm(aids1,aids2)
detach(aids)

Run the code above in your browser using DataLab