Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Statsby - collecting betas


From   "Wallace, John" <[email protected]>
To   <[email protected]>
Subject   st: RE: Statsby - collecting betas
Date   Mon, 13 Dec 2004 11:46:10 -0800

Nick Cox has provided me with some guidance on my matrix education, but
I'm still in need of advice from those more experienced than I.  Could
anyone help?

Thanks

John Wallace | Research Associate | Test Method Development
AFFYMETRIX, INC. | 3380 Central Expressway | Santa Clara, CA 95051 |
Tel:  408-731-5574 | Fax:  408-481-0435

-----Original Message-----
From: Nick Cox [mailto:[email protected]] 
Sent: Monday, December 13, 2004 11:27 AM
To: Wallace, John
Subject: RE: RE: Statsby - collecting betas

Not while I am about to go home. Could you 
take this thread back into public view please, 
for that and other reasons? 

Nick 
[email protected] 

> -----Original Message-----
> From: Wallace, John [mailto:[email protected]]
> Sent: 13 December 2004 19:18
> To: Nick Cox
> Subject: RE: RE: Statsby - collecting betas
> 
> 
> Thanks for this!  The -levels- command itself is useful!  I had
> previously been initializing a new numeric variable for looping in
> similar situations.  The results weren't quite what I was expecting
> however - the correct number of rows and columns were 
> present, but each was filled with the same coefficients (there were 
> 102 rows of identical information).  
> Looking into the documentation [U]matrix expressions 17.7, I see that
> the \ operator is a row join, which presumably is how  the do-file
> accumulates the vectors into a matrix.  It looks as though the vector
> isn't updating with each pass through the loop though.  Any ideas?
> 
> -JW
> 
> -----Original Message-----
> From: Nick Cox [mailto:[email protected]] 
> Sent: Sunday, December 12, 2004 10:04 AM
> To: Wallace, John
> Subject: RE: RE: Statsby - collecting betas
> 
> Ha! My formal exposure to math[s] ended at age 17, 
> so I can trump you there. 
> 
> Start with 
> 
> levels unit, local(units) 
> qui foreach u of local units { 
> 	anova logcpint benchdwellmin hyb benchdwellmin*nMES 
> 		nMES /nMES|die / nMES|die|atom /
> ,continuous(benchdwellmin) 
> 		partial regress anova
> 	matrix results = nullmat(results) \ e(b)
> } 
> 
> This depends on all covariates being present for each 
> unit. 
> 
> Nick 
> [email protected] 
> 
> > -----Original Message-----
> > From: Wallace, John [mailto:[email protected]]
> > Sent: 10 December 2004 21:57
> > To: Nick Cox
> > Subject: RE: RE: Statsby - collecting betas
> > 
> > 
> > Hi Nick
> > I've been puzzling through them manuals and have decided that matrix
> > manipulations aren't as simple as I had hoped.  Could you 
> give me some
> > pointers on how to implement your suggestion?  I've 
> > determined that the
> > coefficients I'm interested in capturing are stored in a matrix-like
> > device called e(b) (although it doesn't come up as an entry in the
> > -matrix list- results?)
> > I had envisioned defining a new 100 x 3 matrix and 
> populating the rows
> > with the 3 coefficients I'm interested in from e(b) (namely 
> > r1c1, r1c2,
> > and r1c7) as I loop through the list of 100 units.  I'd then 
> > write those
> > to a new stata dataset for later analysis.
> > 
> > Unfortunately I wasted my higher education maths opportunities in
> > calculus instead of stats or number theory, so matrix 
> > manipulation is a
> > new concept to me.
> > 
> > -JW
> > 
> > -----Original Message-----
> > n.j.cox wrote:
> > 
> > A wild guess is that you can't do what you 
> > want this way. -anova- basically does 
> > all sorts of idiosyncratic things, and 
> > the estimates it leaves behind can't 
> > be related that easily to predictors. 
> > The more you think about interaction
> > terms etc., the less surprising that is. 
> > 
> > I think you need to do this directly. 
> > Loop over your -by()- variable and pick up 
> > a vector each time, adding it to a matrix
> > born null. 
> > 
> > Alternatively, a couple of -anova- extras
> > are documented via -whelp undocumented-. 
> > 
> > Nick 
> > [email protected] 
> > 
> > Wallace, John
> > 
> > > I have a statsby regression that I'm performing over a list 
> > > of 100 cases ("Units").  I'd like to collect the regression 
> > > coefficients from the various terms to analyze, so I'm using 
> > > the following command:
> > > 
> > > .statsby "anova logcpint benchdwellmin hyb benchdwellmin*nMES 
> > > nMES /nMES|die / nMES|die|atom / ,continuous(benchdwellmin) 
> > > partial regress anova" _b, by(unit) saving(betas.dta)
> > > 
> > > The problem is, when I run this I get an error:
> > > regressor c1 not found
> > > error in statistic: _b[c1]
> > > r(111);
> > > 
> > > This appears to happen immediately following the first Unit 
> > > analysis.  The problem is, when I have a look at the 
> > > coefficient matrix directly, there appears to be no problem:
> > > . matrix list e(b)
> > >             c1          c2          c3          c4          
> > > c5          c6          c7 ...        
> > > r1   7.8317621  -.00012466   .16011793           0  
> > > -.01768075           0  -.00007796           
> > > 
> > > _b[c1] is clearly defined, but statsby seems to have trouble 
> > > snagging it.  Am I interpreting the situation correctly?  Is 
> > > there a problem with the statsby statement?

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