Learn R Programming

greybox (version 0.6.4)

lmDynamic: 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

Usage

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

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.

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.

...

Other parameters passed to alm().

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:

  • coefficients - the mean (over time) parameters of the model,

  • vcov - the combined covariance matrix of the model,

  • fitted - the fitted values,

  • residuals - the residuals of the model,

  • distribution - the distribution used in the estimation,

  • logLik - the mean (over time) log-likelihood of the model,

  • IC - dynamic values of the information criterion (pIC),

  • ICType - the type of information criterion used,

  • df.residual - mean number of degrees of freedom of the residuals of the model,

  • df - mean number of degrees of freedom of the model,

  • importance - dynamic importance of the parameters,

  • call - call used in the function,

  • rank - rank of the combined model,

  • data - the data used in the model,

  • mu - the location value of the distribution,

  • scale - the scale parameter if alm() was used,

  • coefficientsDynamic - table with parameters of the model, varying over the time,

  • df.residualDynamic - dynamic df.residual,

  • dfDynamic - dynamic df.

  • weights - the dynamic weights for each model under consideration.

Details

The algorithm uses alm() to fit different models and then combines the models based on the selected point IC. This is a dynamic counterpart of lmCombine function.

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

References

  • Burnham Kenneth P. and Anderson David R. (2002). Model Selection and Multimodel Inference. A Practical Information-Theoretic Approach. Springer-Verlag New York. DOI: [10.1007/b97636](http://dx.doi.org/10.1007/b97636).

See Also

stepwise, lmCombine

Examples

Run this code
# NOT RUN {
### 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))

# }

Run the code above in your browser using DataLab