Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: question from a new user


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: question from a new user
Date   Fri, 10 Feb 2006 11:05:56 -0500

At 10:20 AM 2/10/2006, Rudy Fichtenbaum wrote:
I am a relatively new user of Stata having used SAS for many years. I know that when you run a regression in Stata it produces a whole series of results that are stored under e( ) e.g. R squared, N, RSS etc. The problem I am having is I can't figure out how to access those stored results. I want to use the stored results to calculate an LM statistic. I can do this manually using the results and the display command but there must be a way of programing Stata to do this task.

Here is what I want to do. I run a restricted regression and then obtain the residuals. Next I regress the residuals on the independent variables from the unrestricted model. N times the R square from this equation is an LM statistic.

Rudy
Welcome to Stata Rudy. First off though, kill the little vcf attachments when you post since they screw up some people's email! Here is a simple example. Basically, you just find out how the quantities you want are stored and then use them in your calculations.

. webuse auto
(1978 Automobile Data)

. quietly reg weight length

. ereturn list

scalars:
e(N) = 74
e(df_m) = 1
e(df_r) = 72
e(F) = 613.2727965692631
e(r2) = .8949323534212077
e(rmse) = 253.6640262138552
e(mss) = 39461306.8283367
e(rss) = 4632871.550041688
e(r2_a) = .8934730805520578
e(ll) = -513.6524782518598
e(ll_0) = -597.0190609278627

macros:
e(title) : "Linear regression"
e(depvar) : "weight"
e(cmd) : "regress"
e(properties) : "b V"
e(predict) : "regres_p"
e(model) : "ols"
e(estat_cmd) : "regress_estat"

matrices:
e(b) : 1 x 2
e(V) : 2 x 2

functions:
e(sample)

. display e(N) * e(r2)
66.224994



-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index