View source: R/ols_restricted_model.R
ols_restricted_model | R Documentation |
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.
ols_restricted_model(
df = NULL,
ur_formula_obj = NULL,
r_formula_obj = NULL,
confid_level = 0.95
)
df |
A data frame with columns for observed response and predictors |
ur_formula_obj |
The unrestricted formula object following the rules of |
r_formula_obj |
The restricted formula object following the rules of |
confid_level |
A numeric decimal that sets the confidence level for computing the critical values. The default is .95. |
Returns a named list with a data frame of computed F/LM statistics along with OLS coefficient estimates for each model.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.