Checking the fitted model in stata

(Comments)

One of the most important aspects of regression analysis is checking whether the model is omitting some variables or not. And the way to do that is with the Ramsey test. 

The Ho of the Ramsey test is we don't have any omitted variables. And the alternative hypothesis is there are omitted or some omitted variables. Therefore if there result is significant, it means there are some omitted variables. 

Lets see from this result 

Reset-F 2.8647 1.691 1.049
Frrp-value 0.0454 0.181 0.379

As we can see, in the first model, the Frrp-value is 0.04, which means the model rejects the null hypothesis with a confidence of 0.04 or **.

The complete mode explanation also available here

In regression analysis, we often check the assumptions of the econometrical model regressed; during this, one of the fundamental assumptions is that the model has no omitted variables (and it’s correctly specified). In 1969, Ramsey (1969) developed an omitted variable test, which uses the powers of the predicted values of the dependent variable to check if the model has an omitted variable problem.

Assume a basic fitted model given by:

Where y is the vector of containing the dependent variable with nx1 observations, X is the matrix that contains the explanatory variables, which is nxk (n are the total observations and k are the number of independent variables). The vector b represents the estimated coefficient vector.

Ramsey test fits a regression model of the type

Where z represents the powers of the fitted values of y, the Ramsey test performs a standard F test of t=0, and the default setting considers the powers as:

In Stata, this is quickly done with the command

estat ovtest

after the regression command reg.

To illustrate this, consider the following code:

use https://www.stata-press.com/data/r16/auto
regress mpg weight foreign
estat ovtest

The null hypothesis is that t=0 means that the powers of the fitted values have no relationship, which serves to explain the dependent variable y, meaning that the model has no omitted variables. The alternative hypothesis is that the model suffers from an omitted variable problem.

In the panel data structure where we have multiple time series data points and multiple observations for each time point, in this case, we fit a model like:

With i=1, 2, 3, …, n observations, and for each i, we have t=1, 2, …, T periods. And v represents the heterogenous effect which can be estimated as a parameter (in fixed effects: which can be correlated to the explanatory variables) and as a variable (in random effects, which is not correlated with the explanatory variables).

To implement the Ramsey test manually in this regression structure in Stata, we will follow Santos Silva's (2016) recommendation and start predicting the regression's fitted values (with the heterogenous effects, too!). Then we will generate the powers of the fitted values and include them in the regression in (4) with clustered standard errors. Finally, we will perform a significant test jointly for the coefficients of the powers.

use https://www.stata-press.com/data/r16/nlswork

xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure 2.race not_smsa south, fe cluster(idcode)

predict y_hat,xbu

gen y_h_2=y_hat*y_hat 
gen y_h_3=y_h_2*y_hat

gen y_h_4=y_h_3*y_hat

xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure 2.race not_smsa south y_h_2 y_h_3 y_h_4, fe cluster (idcode)

test y_h_2 y_h_3 y_h_4

Alternative you can skip the generation of the powers and apply them directly using c. and # operators in the command as it follows this other code:

use https://www.stata-press.com/data/r16/nlswork

xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure 2.race not_smsa south, fe cluster(idcode)

predict y_hat,xbu

xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure 2.race not_smsa south c.y_hat#c.y_hat c.y_hat#c.y_hat# c.y_hat c.y_hat#c.y_hat# c.y_hat# c.y_hat , fe cluster (idcode)

test c.y_hat#c.y_hat c.y_hat#c.y_hat# c.y_hat c.y_hat#c.y_hat# c.y_hat# c.y_hat

At the end of the procedure you will have this result.

Where the null hypothesis is that the model is correctly specified and has no omitted variables, however in this case, we reject the null hypothesis with a 5% level of significance, meaning that our model has omitted variables.

As an alternative but somewhat more restricted, also with more features, you can use the user-written package “resetxt” developed by Emad Abd & Sahra Khaleel (2015) which can be used after installing it with:

ssc install resetxt, replace

This package however doesn’t work with factor-variables or time series operators, so we cannot include c. or i. and d. or L. operators for example.

clear all

use https://www.stata-press.com/data/r16/nlswork

gen age_sq=ageage gen ttl_sq= ttl_exp ttl_exp

gen tenure_sq= tenure* tenure

xtreg ln_w grade age age_sq ttl_exp ttl_sq tenure tenure_sq race not_smsa south, fe cluster(idcode)

resetxt ln_w grade age age_sq ttl_exp ttl_sq tenure tenure_sq race not_smsa south, model(xtfe) id(idcode) it(year)

however, the above code might be complicated to calculate in Stata, depending on how much memory do you have to do the procedure. That’s why in this post it was implemented the manual procedure of the Ramsey test in the panel data structure.

Bibliography

Emad Abd, S. E., & Sahra Khaleel, A. M. (2015). RESETXT: Stata Module to Compute Panel Data REgression Specification Error Tests (RESET). Obtained from: Statistical Software Components S458101: https://ideas.repec.org/c/boc/bocode/s458101.html

Ramsey, J. B. (1969). Tests for specification errors in classical linear least-squares regression analysis. Journal of the Royal Statistical Society Series B 31, 350–371.

Santos Silva, J. (2016). Reset test after xtreg & xi:reg . Obtained from: The Stata Forum: https://www.statalist.org/forums/forum/general-stata-discussion/general/1327362-reset-test-after-xtreg-xi-reg?fbclid=IwAR1vdUDn592W6rhsVdyqN2vqFKQgaYvGvJb0L2idZlG8wOYsr-eb8JFRsiA

Current rating: 5

Comments

Riddles

22nd Jul- 2020, by: Editor in Chief
524 Shares 4 Comments
Generic placeholder image
20 Oct- 2019, by: Editor in Chief
524 Shares 4 Comments
Generic placeholder image
20Aug- 2019, by: Editor in Chief
524 Shares 4 Comments
10Aug- 2019, by: Editor in Chief
424 Shares 4 Comments
Generic placeholder image
10Aug- 2015, by: Editor in Chief
424 Shares 4 Comments

More News  »

How to create output gap with Python and Anaconda

Recent news
1 month, 3 weeks ago

Dignity wrapped in Charity

Recent news
3 months ago

A reflection of using kanban flow and being minimalist

Recent news

Today is the consecutive day I want to use and be consistent with the Kanban flow! It seems it's perfect to limit my parallel and easily distractedness. 

read more
3 months, 2 weeks ago

Morning issue with car and my kind of music

Recent news
3 months, 2 weeks ago

Podcast Bapak Dimas 2 - pindahan rumah

Recent news

Vlog kali ini adalah terkait pindahan rumah!

read more
3 months, 3 weeks ago

Podcast Bapak Dimas - Bapaknya Jozio dan Kaziu - ep 1

Recent news

Seperti yang saya cerita kan sebelumnya, berikut adalah catatan pribadi VLOG kita! Bapak Dimas

read more
3 months, 3 weeks ago

Happy new year 2024 and thank you 2023!

Recent news

As the new year starts, I want to revisit what has happened in 2023. 

read more
3 months, 3 weeks ago

Some notes about python and Zen of Python

Recent news

Explore Python syntax

Python is a flexible programming language used in a wide range of fields, including software development, machine learning, and data analysis. Python is one of the most popular programming languages for data professionals, so getting familiar with its fundamental syntax and semantics will be useful for your future career. In this reading, you will learn about Python’s syntax and semantics, as well as where to find resources to further your learning.

read more
5 months ago

More News »

Generic placeholder image

Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without