Title: | Econometrics Model Building |
---|---|
Description: | An intuitive and user-friendly package designed to aid undergraduate students in understanding and applying econometric methods in their studies, Tailored specifically for Econometrics and Regression Modeling courses, it provides a practical toolkit for modeling and analyzing econometric data with detailed inference capabilities. |
Authors: | Mutua Kilai [aut, cre]
|
Maintainer: | Mutua Kilai <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2025-02-28 06:33:57 UTC |
Source: | https://github.com/cran/EcoMetrics |
Plots ACF of a univariate time series
ACF_PLOT(x, lag.max = NULL)
ACF_PLOT(x, lag.max = NULL)
x |
numeric vector |
lag.max |
maximum lag to calculate the acf |
a plot of the acf vs lag
Mutua Kilai
data(keconomy) attach(keconomy) ACF_PLOT(UR)
data(keconomy) attach(keconomy) ACF_PLOT(UR)
Checks model for independence of residuals
autocorrelation_assumption(model)
autocorrelation_assumption(model)
model |
A lm object |
returns the p-value for the test
Mutua Kilai
model <- lm(pi ~ hs + ps, data = eduperform) autocorrelation_assumption(model)
model <- lm(pi ~ hs + ps, data = eduperform) autocorrelation_assumption(model)
Select Optimal Model based on BIC
best_arima(data, max_p = 5, max_d = 2, max_q = 5)
best_arima(data, max_p = 5, max_d = 2, max_q = 5)
data |
A univariate ts object |
max_p |
Maximum AR order |
max_d |
Maximum differencing order |
max_q |
Maximum MA order |
A list containing the optimal model results and the BIC value
data(keconomy) attach(keconomy) best_arima(UR, max_p = 5, max_d = 2, max_q = 5)
data(keconomy) attach(keconomy) best_arima(UR, max_p = 5, max_d = 2, max_q = 5)
Checking Overall Model Significance
check_model_sig(data, y, x)
check_model_sig(data, y, x)
data |
A data frame containing the variables to use |
y |
The dependent variable |
x |
A set of independent variables |
p-value with a statement on whether the model is significant or not
Mutua Kilai
check_model_sig(data = eduperform, "pi", c("hs", "ps"))
check_model_sig(data = eduperform, "pi", c("hs", "ps"))
Check Series for Weak Stationarity
check_stationarity(x)
check_stationarity(x)
x |
A numeric vector or time series object |
p-value of the test
Mutua Kilai
data(keconomy) attach(keconomy) check_stationarity(UR)
data(keconomy) attach(keconomy) check_stationarity(UR)
Student performance dataset is a dataset designed to examine the factors influencing academic student performance.
eduperform
eduperform
eduperform
A data frame with 10000 rows and 6 columns:
hours studied
previous score
extracurricula activities
sleep hours
sample question paper practiced
performance Index
...
Fit ARIMA models to univariate data
fit_arima(data, p, d, q)
fit_arima(data, p, d, q)
data |
a univariate class object or a vector |
p |
AR order |
d |
differencing order |
q |
MA order |
A tibble containing the estimate, SE and p-value
data(keconomy) attach(keconomy) fit_arima(UR, p=2,d=0,q=3)
data(keconomy) attach(keconomy) fit_arima(UR, p=2,d=0,q=3)
Get variance of the model coefficients
get_coefficients_variance(data, y, x)
get_coefficients_variance(data, y, x)
data |
A data frame containing the variables to use |
y |
The dependent variable |
x |
A set of independent variables |
Tibble containing the variances
Mutua Kilai
get_coefficients_variance(data = eduperform, "pi", c("hs", "ps"))
get_coefficients_variance(data = eduperform, "pi", c("hs", "ps"))
Confidence Intervals of Model Parameters
get_confint(data, y, x, level = 0.95)
get_confint(data, y, x, level = 0.95)
data |
A data frame containing the variables to use |
y |
The dependent variable |
x |
A set of independent variables |
level |
level of significance can be 0.95, 0.90 etc. default is 0.95 |
tibble containing the lower and upper confidence intervals
Mutua Kilai
get_confint(data = eduperform, "pi", c("hs", "ps"))
get_confint(data = eduperform, "pi", c("hs", "ps"))
Obtaining only significant predictors from a model
get_significant_predictors(data, y, x, alpha = 0.05)
get_significant_predictors(data, y, x, alpha = 0.05)
data |
A data frame containing the variables to use |
y |
The dependent variable |
x |
A set of independent variables |
alpha |
desired alpha level. default is 0.05 |
A tibble containing the significant predictors
Mutua Kilai
get_significant_predictors(data = eduperform, "pi", c("hs", "ps"))
get_significant_predictors(data = eduperform, "pi", c("hs", "ps"))
Checking heteroscedasticity assumption
heteroscedasticity_assumption(model)
heteroscedasticity_assumption(model)
model |
A lm model object |
The p-value of the test statistic.
Mutua Kilai
model <- lm(pi ~ hs + ps, data = eduperform) heteroscedasticity_assumption(model)
model <- lm(pi ~ hs + ps, data = eduperform) heteroscedasticity_assumption(model)
Annual Time Series data for Kenyan Economy showing the unemployment rate and GDP Growth Rate.
keconomy
keconomy
keconomy
A data frame with 25 rows and 3 columns:
Year; from 1999 to 2023
Unemployment Rate
GDP Growth Rate
Multicollinearity Assumption
multicollinearity_assumption(model)
multicollinearity_assumption(model)
model |
A lm object |
A tibble containing the VIF and Tolerance values
Mutua Kilai
model <- lm(pi ~ hs + ps, data = eduperform) multicollinearity_assumption(model)
model <- lm(pi ~ hs + ps, data = eduperform) multicollinearity_assumption(model)
Checking normality of residuals
normality_assumption(model)
normality_assumption(model)
model |
A lm model object |
The p-value of the test statistic.
Mutua Kilai
model <- lm(pi ~ hs + ps, data = eduperform) normality_assumption(model)
model <- lm(pi ~ hs + ps, data = eduperform) normality_assumption(model)
Fitting a simple or multiple linear regression
ols_model(data, y, x)
ols_model(data, y, x)
data |
A data frame containing the variables to use |
y |
The dependent variable |
x |
Set of independent variables |
A tibble of the coefficients, standard errors, t-statistics and p-value
Mutua Kilai
ols_model(data = eduperform, "pi", c("hs", "ps"))
ols_model(data = eduperform, "pi", c("hs", "ps"))
F-statistic attributes
ols_model_sig(data, y, x)
ols_model_sig(data, y, x)
data |
A data frame containing the variables to use |
y |
The dependent variable |
x |
Set of independent variables |
A tibble containing the number of observations, F-Statistic, degrees of freedom and p-value
Mutua Kilai
ols_model_sig(data = eduperform, "pi", c("hs", "ps"))
ols_model_sig(data = eduperform, "pi", c("hs", "ps"))
Model Summary Statistics
ols_model_stats(data, y, x)
ols_model_stats(data, y, x)
data |
A data frame containing the variables to use |
y |
The dependent variable |
x |
The independent variables |
A tibble containing model summary stats: R-Squared, Adjusted R-Squared, AIC and BIC
Mutua Kilai
ols_model_stats(data = eduperform, "pi", c("hs", "ps"))
ols_model_stats(data = eduperform, "pi", c("hs", "ps"))
Plots PACF of a univariate time series
PACF_PLOT(x, lag.max = NULL)
PACF_PLOT(x, lag.max = NULL)
x |
a numeric vector |
lag.max |
maximum lag to calculate pacf |
a plot of the pacf vs lag
Mutua Kilai
data(keconomy) attach(keconomy) PACF_PLOT(UR)
data(keconomy) attach(keconomy) PACF_PLOT(UR)
Prediction from new observations
predict_dep_var(model, new_data, level = 0.95)
predict_dep_var(model, new_data, level = 0.95)
model |
an lm object |
new_data |
data frame containing the new set of predictors |
level |
confidence level, default 0.95 |
A tibble containing the predicted value and the upper and lower CI
Mutua Kilai
model <- lm(pi ~ hs + ps, data = eduperform) newdata <- data.frame(hs =c(2,3,4),ps = c(23,24,12)) predict_dep_var(model, new_data = newdata, level = 0.95)
model <- lm(pi ~ hs + ps, data = eduperform) newdata <- data.frame(hs =c(2,3,4),ps = c(23,24,12)) predict_dep_var(model, new_data = newdata, level = 0.95)
Choosing Best Model Based on AIC, BIC and Adjusted R Squared
select_optimal_model(models, criterion = "AIC")
select_optimal_model(models, criterion = "AIC")
models |
a list of models |
criterion |
The criterion to select optimal model. Default AIC |
list of the results and best model
Mutua Kilai
data(eduperform) model1 <- lm(pi ~ hs, data = eduperform) model2 <- lm(pi ~ hs + ps, data = eduperform) model3 <- lm(pi ~ hs + ps + sh, data = eduperform) models <- list(model1, model2, model3) select_optimal_model(models, criterion= "AIC")
data(eduperform) model1 <- lm(pi ~ hs, data = eduperform) model2 <- lm(pi ~ hs + ps, data = eduperform) model3 <- lm(pi ~ hs + ps + sh, data = eduperform) models <- list(model1, model2, model3) select_optimal_model(models, criterion= "AIC")