Package 'EcoMetrics'

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

Help Index


Plots ACF of a univariate time series

Description

Plots ACF of a univariate time series

Usage

ACF_PLOT(x, lag.max = NULL)

Arguments

x

numeric vector

lag.max

maximum lag to calculate the acf

Value

a plot of the acf vs lag

Author(s)

Mutua Kilai

Examples

data(keconomy)
attach(keconomy)
ACF_PLOT(UR)

Check model for residual independence

Description

Checks model for independence of residuals

Usage

autocorrelation_assumption(model)

Arguments

model

A lm object

Value

returns the p-value for the test

Author(s)

Mutua Kilai

Examples

model <- lm(pi ~ hs + ps, data = eduperform)
autocorrelation_assumption(model)

Select Optimal Model based on BIC

Description

Select Optimal Model based on BIC

Usage

best_arima(data, max_p = 5, max_d = 2, max_q = 5)

Arguments

data

A univariate ts object

max_p

Maximum AR order

max_d

Maximum differencing order

max_q

Maximum MA order

Value

A list containing the optimal model results and the BIC value

Examples

data(keconomy)
attach(keconomy)
best_arima(UR, max_p = 5, max_d = 2, max_q = 5)

Checking Overall Model Significance

Description

Checking Overall Model Significance

Usage

check_model_sig(data, y, x)

Arguments

data

A data frame containing the variables to use

y

The dependent variable

x

A set of independent variables

Value

p-value with a statement on whether the model is significant or not

Author(s)

Mutua Kilai

Examples

check_model_sig(data = eduperform, "pi", c("hs", "ps"))

Check Series for Weak Stationarity

Description

Check Series for Weak Stationarity

Usage

check_stationarity(x)

Arguments

x

A numeric vector or time series object

Value

p-value of the test

Author(s)

Mutua Kilai

Examples

data(keconomy)
attach(keconomy)
check_stationarity(UR)

Student Performance Data

Description

Student performance dataset is a dataset designed to examine the factors influencing academic student performance.

Usage

eduperform

Format

eduperform

A data frame with 10000 rows and 6 columns:

hs

hours studied

ps

previous score

ea

extracurricula activities

sh

sleep hours

sqpp

sample question paper practiced

pi

performance Index

...

Source

https://www.kaggle.com/datasets/nikhil7280/student-performance-multiple-linear-regression?resource=download


Fit ARIMA models to univariate data

Description

Fit ARIMA models to univariate data

Usage

fit_arima(data, p, d, q)

Arguments

data

a univariate class object or a vector

p

AR order

d

differencing order

q

MA order

Value

A tibble containing the estimate, SE and p-value

Examples

data(keconomy)
attach(keconomy)
fit_arima(UR, p=2,d=0,q=3)

Get variance of the model coefficients

Description

Get variance of the model coefficients

Usage

get_coefficients_variance(data, y, x)

Arguments

data

A data frame containing the variables to use

y

The dependent variable

x

A set of independent variables

Value

Tibble containing the variances

Author(s)

Mutua Kilai

Examples

get_coefficients_variance(data = eduperform, "pi", c("hs", "ps"))

Confidence Intervals of Model Parameters

Description

Confidence Intervals of Model Parameters

Usage

get_confint(data, y, x, level = 0.95)

Arguments

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

Value

tibble containing the lower and upper confidence intervals

Author(s)

Mutua Kilai

Examples

get_confint(data = eduperform, "pi", c("hs", "ps"))

Obtaining only significant predictors from a model

Description

Obtaining only significant predictors from a model

Usage

get_significant_predictors(data, y, x, alpha = 0.05)

Arguments

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

Value

A tibble containing the significant predictors

Author(s)

Mutua Kilai

Examples

get_significant_predictors(data = eduperform, "pi", c("hs", "ps"))

Checking heteroscedasticity assumption

Description

Checking heteroscedasticity assumption

Usage

heteroscedasticity_assumption(model)

Arguments

model

A lm model object

Value

The p-value of the test statistic.

Author(s)

Mutua Kilai

Examples

model <- lm(pi ~ hs + ps, data = eduperform)
heteroscedasticity_assumption(model)

Kenya Unemployment Rate and GDP Growth rate for 1999-2023

Description

Annual Time Series data for Kenyan Economy showing the unemployment rate and GDP Growth Rate.

Usage

keconomy

Format

keconomy

A data frame with 25 rows and 3 columns:

Year

Year; from 1999 to 2023

UR

Unemployment Rate

GR

GDP Growth Rate

Source

https://www.statista.com


Multicollinearity Assumption

Description

Multicollinearity Assumption

Usage

multicollinearity_assumption(model)

Arguments

model

A lm object

Value

A tibble containing the VIF and Tolerance values

Author(s)

Mutua Kilai

Examples

model <- lm(pi ~ hs + ps, data = eduperform)
multicollinearity_assumption(model)

Checking normality of residuals

Description

Checking normality of residuals

Usage

normality_assumption(model)

Arguments

model

A lm model object

Value

The p-value of the test statistic.

Author(s)

Mutua Kilai

Examples

model <- lm(pi ~ hs + ps, data = eduperform)
normality_assumption(model)

Fitting a simple or multiple linear regression

Description

Fitting a simple or multiple linear regression

Usage

ols_model(data, y, x)

Arguments

data

A data frame containing the variables to use

y

The dependent variable

x

Set of independent variables

Value

A tibble of the coefficients, standard errors, t-statistics and p-value

Author(s)

Mutua Kilai

Examples

ols_model(data = eduperform, "pi", c("hs", "ps"))

F-statistic attributes

Description

F-statistic attributes

Usage

ols_model_sig(data, y, x)

Arguments

data

A data frame containing the variables to use

y

The dependent variable

x

Set of independent variables

Value

A tibble containing the number of observations, F-Statistic, degrees of freedom and p-value

Author(s)

Mutua Kilai

Examples

ols_model_sig(data = eduperform, "pi", c("hs", "ps"))

Model Summary Statistics

Description

Model Summary Statistics

Usage

ols_model_stats(data, y, x)

Arguments

data

A data frame containing the variables to use

y

The dependent variable

x

The independent variables

Value

A tibble containing model summary stats: R-Squared, Adjusted R-Squared, AIC and BIC

Author(s)

Mutua Kilai

Examples

ols_model_stats(data = eduperform, "pi", c("hs", "ps"))

Plots PACF of a univariate time series

Description

Plots PACF of a univariate time series

Usage

PACF_PLOT(x, lag.max = NULL)

Arguments

x

a numeric vector

lag.max

maximum lag to calculate pacf

Value

a plot of the pacf vs lag

Author(s)

Mutua Kilai

Examples

data(keconomy)
attach(keconomy)
PACF_PLOT(UR)

Prediction from new observations

Description

Prediction from new observations

Usage

predict_dep_var(model, new_data, level = 0.95)

Arguments

model

an lm object

new_data

data frame containing the new set of predictors

level

confidence level, default 0.95

Value

A tibble containing the predicted value and the upper and lower CI

Author(s)

Mutua Kilai

Examples

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

Description

Choosing Best Model Based on AIC, BIC and Adjusted R Squared

Usage

select_optimal_model(models, criterion = "AIC")

Arguments

models

a list of models

criterion

The criterion to select optimal model. Default AIC

Value

list of the results and best model

Author(s)

Mutua Kilai

Examples

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")