knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(AFR) library(olsrr) library(stats)
As regressors are chosen for a linear regression model, AFR package recommends to check for:
Function opt_size assess whether time-series data has enough observations for the chosen model.
model<-lm(real_gdp~imp+exp+usdkzt+eurkzt, macroKZ) opt_size(model)
Based on the output of the function, modify the model, i.e. remove or add regressor(s).
From the initially built linear regression model regsel_f function allows to choose the best regressors by Akaike Information criterion (AIC) and Adjusted R-squared (Adj R2) parameters. These parameters are set by default, but other parameters can be added too.
To dive into details, check_betas function demonstrates all models with regressors' betas based on which regsel_f function gives the result. A user can export the output of all models into Excel document for more representative format by using function write_xlsx of writexl package.
check_betas(model)
As regsel_f gave the best regression model, it can be analysed by diagnostic tests for the compliance with Gauss-Markov theorem for a multiple regression model.
Graphically, the regression model can be visualized for decomposition and forecasting. Function dec_plot demonstrates a contribution of each regressor in a form of stacked bar plot.
dec_plot(model, macroKZ)
Function reg_plot shows actual and forecast data. Forecasting can be performed by Arima or trending.
reg_plot(model, macroKZ)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.