Last data update: 2014.03.03

R: An Additive term for fitting Penalised Lags within a GAMLSS...
laR Documentation

An Additive term for fitting Penalised Lags within a GAMLSS model

Description

The function la() can be used for fitting penalised lags for explanatory variables.

Usage

la(x, control = la.control(...), ...)
la.control(lags = 10, from.lag = 0, df = NULL, lambda = NULL, 
          start.lambda = 10, order = 1, plot = FALSE, 
         method = c("ML", "GAIC"), k = 2, ...)
gamlss.la(x, y, w, xeval = NULL, ...)

Arguments

x

the name of the explanatory variable

y

internally evaluated (iterative working variable)

w

internally evaluated (iterative weights)

xeval

internally evaluated no need for specification here

control

a list of a number of control parameters for the fitting function penLags()

lags

the number of lags

from.lag

from which lag value to start, the default is zero which means include the original x in the basis

df

use this if you want to fix the degrees of freedom

lambda

use this if you would like to fix the smoothing parameter

start.lambda

initial starting value for lambda

order

the order of the penalty

plot

whether you would like a plot of the data

method

method of fitting if lambda or df are not specified

k

the penally used if method "GAIC" is used

...

for further arguments

Details

The idea of penalised lags is that we use a large amount of lags but we penalised their fitted coefficients and therefore we use few degrees of freedom. The penally and method of fitting are the same as in the pb() function of gamlss. This function does not do the fitting this is achieved by the function gamlss.la() which uses the function penLags for the fitting

Value

a vector of zeros is returned, endowed with a number of attributes. The vector itself is used in the construction of the model matrix (contributing nothing), while the attributes are needed for the back-fitting algorithms of the additive fit.

Note

Note that an appropriate prior weight is needed in the gamlss fit

Author(s)

Mikis Stasinopoulos d.stasinopoulos@londonmet.ac.uk, Bob Rigby r.rigby@londonmet.ac.uk, Vlasios Voudouris <v.voudouris@londonmet.ac.uk>, Majid Djennad, and Paul Eilers.

References

Benjamin M. A., Rigby R. A. and Stasinopoulos D.M. (2003) Generalised Autoregressive Moving Average Models. J. Am. Statist. Ass., 98, 214-223.

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

penLags

Examples

##  the data
 dax <- EuStockMarkets[,"DAX"]
 plot(dax)
## using a penalised autorgressive model
   w <- wlag(dax, lag=20)
  m1 <- gamlss(dax~ la(dax, lags=20, order=1, from.lag=1), weights=w) 
  lines(fitted(m1)~as.numeric(time(dax)), col=2)
 wp(m1, ylim.all=1) # not very good model
## Not run: 
## Try modelling the variance
  m2 <- gamlss(dax~ la(dax, lags=20, order=1, from.lag=1),
              sigma.fo=~la(dax^2, lags=10, order=1, from.lag=1), weights=w)
 wp(m2, ylim.all=1)# maybe the tails
  m3 <- gamlss(dax~ la(dax, lags=20, order=1, from.lag=1),
              sigma.fo=~la(dax^2, lags=10, order=1, from.lag=1), 
              weights=w,  family=TF)
  wp(m3, ylim.all=1) # better model 
  plot(m3, ts=TRUE)  # autocorrelation OK
## using FTSE to precict DAX           
ftse <- EuStockMarkets[,"FTSE"]
# fitting using penLags
  l1 <- penLags(dax, ftse, lags=30, plot=TRUE)
# similar model within gamlss  
   w <- wlag(ftse, lag=30)
  g1 <- gamlss(dax~ la(ftse, lags=30, order=1), weights=w)
lines(fitted(m1)~as.numeric(time(dax)))
  op <- par(mfrow=c(2,1))
# plotting the fitted coeficints of the AR terms  
plot(coef(l1, "AR"), type="h")
plot(coef(g1$mu.coefSmo[[1]])[-1], type="h")
par(op)
g2 <- gamlss(dax~ la(ftse, lags=30, order=1)+la(dax, lags=20, order=1, from.lag=1) , weights=w)
g3 <- gamlss(dax~ la(ftse, lags=30, order=1)+la(dax, lags=20, order=1, from.lag=1) ,
                sigma.fo=~la(dax^2, lags=10, order=1, from.lag=1), weights=w)

## End(Not run)

Results