Statalist The Stata Listserver


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

st: question from a new user


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: question from a new user
Date   Fri, 10 Feb 2006 19:56:14 -0500

Rudy wanted to not only retrieve N and R^2 from a regression, he wanted to run a regression and save the residuals.

webuse auto

program define rudy, rclass
version 9.1
syntax varlist
tempvar eps
predict double `eps',resid
regress `eps' `varlist'
ereturn list
local lm = e(N)*e(r2)
display _n "LM : `lm'"
return local lm `lm'
return local vars `varlist'
end

regress price mpg headroom
rudy mpg headroom trunk weight


LM : 9.130851324966942

. return list

macros:
r(vars) : "mpg headroom trunk weight"
r(lm) : "9.130851324966942"


Obviously the Chi^2 p-value could be calculated here and returned as well.


Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html


*
* 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