The function blag()
creates a basis for lag values of x, (a matrix of lag values of x).
The function llag()
creates a list with two components i) a basis matrix and ii) weights to be used as prior weights in any regression analysis. The function wlag()
can take a "mlags" object (created by blag()
) or a vector and returns a vector with ones and zeros. This can be used as prior weights in any analysis which uses blag()
.
blag(x, lags = 1, from.lag=0, omit.na = FALSE,
value = NA, ...)
llag(x, ...)
wlag(x, lags = NULL)
For blag()
and llag()
x is the vector for creating lags. For wlag()
x is an mlags
object created by blag()
.
how many lags are required
where the lags are starting from. The default values is zero which indicates that the x
is also included as a first column. If you want x
not to included in the matrix use from.lag=1
if true the first "lag" rows of the resulting matrix are omitted
value : what values should be set in the beginning of the lags columns, by default is set to NA
additional arguments
The function blag()
returns a "mlags" object (matrix of lag values).
The function llag()
returns a list with components:
The basis of the lag matrix
The weights vector
Those three functions are design for helping a user to fit regression model using lags by generating the appropriate structures.
The function blag()
creates a basis for lag values of x. It assumed that time runs from the oldest to the newest observations. That is, the latest observations are the most recent ones. The function wlag()
take a basis matrix of lags and creates a vector of weights which can be used as a prior weights for any regression type analysis which has the matrix as explanatory variable. The function llag()
creates a list with the matrix base for lags and the appropriate weights.
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.
# NOT RUN {
library(stats)
y <- arima.sim(500, model=list(ar=c(.4,.3,.1)))
X <- blag(y, lags=5, from.lag=1, value=0)
head(X)
w<-wlag(X)
library(gamlss)
m1<-gamlss(y~X, weights=w )
summary(m1)
plot(y)
lines(fitted(m1)~as.numeric(time(y)), col="blue")
# }
Run the code above in your browser using DataLab