lmDynamic | R Documentation |
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.
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, ...)
data |
Data frame containing dependent variable in the first column and the others in the rest. |
ic |
Information criterion to use. |
bruteforce |
If |
silent |
If |
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 |
parallel |
If |
lowess |
Logical defining, whether LOWESS should be used to smooth the
dynamic weights. By default it is |
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 |
... |
Other parameters passed to |
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")
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,
timeElapsed - the time elapsed for the estimation of the model.
Ivan Svetunkov, ivan@svetunkov.com
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).
McQuarrie, A. D. (1999). A small-sample correction for the Schwarz SIC model selection criterion. Statistics & Probability Letters, 44(1), 79–86. [10.1016/S0167-7152(98)00294-6](https://doi.org/10.1016/S0167-7152(98)00294-6).
stepwise, lmCombine
### 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.