Statalist The Stata Listserver

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

RE: RE: st: Regression: All possible subsets

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: RE: st: Regression: All possible subsets
Date   Sun, 26 Nov 2006 19:52:11 -0000


This thread seems to have been dragging on for a while, 
as you tend to provide about one more piece of information in 
each post! 

I don't know how you intend to use -allpossible- in 
conjunction with -postfile-. They are not obviously 
compatible. They could be made compatible if you 
got into a clone of -allpossible- and rewrote it. 
I am not sure if that qualifies as "easy" in your terms. 
It is quite [British sense] easy in principle. 

Also, as explained in its help, -allpossible- 
depends on this being true: 

"At least one of eclass() or rclass() must be specified.  
eclass() must include one or more names of e-class
results, as would be displayed by -estimates list- 
after fitting an individual model.  -rclass()-
must include the name of a program that would execute 
without arguments after a model command
and one or more names of r-class results it produces."

So the help already answered your question. As -regress- is e-class, 
you must write a program that would produce as an r-class
result Mallow's C. 

Now I don't know what Mallow's C is. Perhaps you mean what I 
know as C_p, named for Colin Mallows (not Mallow) and Cuthbert Daniel, 
although the latter is often not credited. Now C_p is for regression 
going to tell you much the same as AIC, as I understand it. 
So on these guesses you just need to get at the result of -estat ic-. 

As I recall your problem, you have 6 possible predictors. 
So your call would look something like this: 

allpossible regress mpg  headroom trunk weight length turn displacement, 
	eclass(rss r2) rclass(myaic AIC) 

where the missing program would like something like this: 

program myaic, rclass 
	version 9 
	estat ic 
	tempname foo
	mat `foo' = r(S) 
	return scalar AIC = `foo'[1,5] 

Another way of tackling this is to start with -selectvars- from SSC. 

sysuse auto, clear

selectvars headroom trunk weight length turn displacement 

local vars `"`r(varlist)'"' 

di as txt "Predictors{col 50}R-square    AIC" 
di as txt "{hline 64}" 
foreach v of local vars { 
	qui regress mpg `v' 
	di as txt "`v'"   "{col 50}" as res %8.5f e(r2) _c
	qui estat ic 
	matrix S = r(S) 
	di as res %8.3f S[1,5]

ru fraser 

will illustrate some technique. This is also adaptable 
to work with -postfile- and other -e()- results. 

[email protected] 

Raphael Fraser
> I was hoping to use -allpossible- and -postfile- to create a dataset
> of e(rss), e(rmse), df_m, Mallow's C, etc. Is there an easy way around
> this?

Nick Cox 

> > As others have indicated, I did not write -tryem-.

Raphael Fraser 

> > > tryem has no help file. I threw some variables at it and it froze.
> > > Nick?? Are you there?

Robert A Yaffee

> > > >   I think that Nick Cox have an allpossible ado file
> > > > that performed all possible subsets regression.

*   For searches and help try:

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