ols_restricted_model: ols_restricted_model

View source: R/ols_restricted_model.R

ols_restricted_modelR Documentation

ols_restricted_model

Description

Function computes the linear F test and the LM test for comparing restricted with unrestricted OLS models.

Given formulas for the the unrestricted and restricted OLS models, function returns a list with a dataframe of F-value/LM-value statistics, along with OLS coefficient estimates for both models.

Reference "Introductory Econometrics, A Modern Approach, Sixth Edition", Chapter 4, Section 4-5 Testing Multiple Linear Restrictions: The F Test, page 127, by Jeffrey Wooldridge.

Usage

ols_restricted_model(
  df = NULL,
  ur_formula_obj = NULL,
  r_formula_obj = NULL,
  confid_level = 0.95
)

Arguments

df

A data frame with columns for observed response and predictors

ur_formula_obj

The unrestricted formula object following the rules of stats::lm() construction. For example: y ~ log(a) + b + I(b^2).

r_formula_obj

The restricted formula object following the rules of stats::lm() construction.

confid_level

A numeric decimal that sets the confidence level for computing the critical values. The default is .95.

Value

Returns a named list with a data frame of computed F/LM statistics along with OLS coefficient estimates for each model.

Examples

library(wooldridge)
library(data.table)
library(RregressPkg)

mlb1_dt <- data.table::as.data.table(wooldridge::mlb1) |>
_[, .(salary, years, gamesyr, bavg, hrunsyr, rbisyr)]
ur_formula_obj <- stats::as.formula(log(salary) ~ years + gamesyr + bavg + hrunsyr + rbisyr)
r_formula_obj <- stats::as.formula(log(salary) ~ years + gamesyr)

restricted_salary_lst <- RregressPkg::ols_restricted_model(
  df = mlb1_dt,
  ur_formula_obj = ur_formula_obj,
  r_formula_obj = r_formula_obj,
  confid_level = 0.99
)
restricted_salary_lst$F_df$F.Value
restricted_salary_lst$F_df$Critical


deandevl/RregressPkg documentation built on Feb. 5, 2025, 12:11 p.m.