lmDynamic {greybox}R Documentation

Combine regressions based on point information criteria

Description

Function combines parameters of linear regressions of the first variable on all the other provided data using pAIC weights. This is an extension of the lmCombine function, which relies upon the idea that the combination weights might change over time.

Usage

lmDynamic(data, ic = c("AICc", "AIC", "BIC", "BICc"), bruteforce = FALSE,
  silent = TRUE, formula = NULL, subset = NULL,
  distribution = c("dnorm", "dlaplace", "ds", "dgnorm", "dlogis", "dt",
  "dalaplace", "dlnorm", "dllaplace", "dls", "dlgnorm", "dbcnorm", "dfnorm",
  "dinvgauss", "dgamma", "dpois", "dnbinom", "dlogitnorm", "plogis", "pnorm"),
  parallel = FALSE, lowess = TRUE, f = NULL, ...)

Arguments

data

Data frame containing dependent variable in the first column and the others in the rest.

ic

Information criterion to use.

bruteforce

If TRUE, then all the possible models are generated and combined. Otherwise the best model is found and then models around that one are produced and then combined.

silent

If FALSE, then nothing is silent, everything is printed out. TRUE means that nothing is produced.

formula

If provided, then the selection will be done from the listed variables in the formula after all the necessary transformations.

subset

an optional vector specifying a subset of observations to be used in the fitting process.

distribution

Distribution to pass to alm(). See alm for details.

parallel

If TRUE, then the model fitting is done in parallel. WARNING! Packages foreach and either doMC (Linux and Mac only) or doParallel are needed in order to run the function in parallel.

lowess

Logical defining, whether LOWESS should be used to smooth the dynamic weights. By default it is TRUE.

f

the smoother span for LOWESS. This gives the proportion of points in the plot which influence the smooth at each value. Larger values give more smoothness. If NULL the parameter will be optimised by minimising ic.

...

Other parameters passed to alm().

Details

The algorithm uses alm() to fit different models and then combines the models based on the selected point IC. The combination weights are calculated for each observation based on the point IC and then smoothed via LOWESS if the respective parameter (lowess) is set to TRUE.

Some details and examples of application are also given in the vignette "Greybox": vignette("greybox","greybox")

Value

Function returns model - the final model of the class "greyboxD", which includes time varying parameters and dynamic importance of each variable. The list of variables:

Author(s)

Ivan Svetunkov, ivan@svetunkov.ru

References

See Also

stepwise, lmCombine

Examples


### Simple example
xreg <- cbind(rnorm(100,10,3),rnorm(100,50,5))
xreg <- cbind(100+0.5*xreg[,1]-0.75*xreg[,2]+rnorm(100,0,3),xreg,rnorm(100,300,10))
colnames(xreg) <- c("y","x1","x2","Noise")
inSample <- xreg[1:80,]
outSample <- xreg[-c(1:80),]
# Combine all the possible models
ourModel <- lmDynamic(inSample,bruteforce=TRUE)
predict(ourModel,outSample)
plot(predict(ourModel,outSample))


[Package greybox version 2.0.0 Index]