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

Re: st: RE: using _rmcoll


From   Matt Dobra <[email protected]>
To   [email protected]
Subject   Re: st: RE: using _rmcoll
Date   Thu, 08 Jan 2004 18:49:55 -0500

Nick,

Thanks!  I had a problem because I forgot the left and right apostrophes, and now i've figured out where I went awry.  While this works, I must admit I'm a bit confused.  I guess I never thought there was a difference between r(varlist) and "`r(varlist)'", and I'm still not sure why adding the quotes changes what is displayed. 

Matt

p.s.   I tokenize for the pure joy of tokenizing!

Actually, I tokenize so I can later randomly choose variables to include in an estimation.  My code was working fine, except when I had collinear variables.  However, stata treats collinearity differently between ml procedures and regression procedures.  If I want to randomly choose variables to include in an ml procedure, say probit, my program produced different types of errors when I randomly chose collinear variables than in, say, OLS. 

If, for example, x1=x2, and I type:
. reg y x1 x2
The output table says x2 was dropped and if I type:
. di _b[x2]
it tells me:
0

Conversely, if I type:
. probit y x1 x2
Before anything is done, stata drops x2 and if I type:
. di _b[x2]
it tells me I made an error of the 111 variety:
[x2] not found

Both of these create different problems, so I want to simply remove collinear variables before I start. 

Nick Cox wrote:
I am not clear why you have a problem. 

program define myprog
	syntax varlist
	_rmcoll `varlist'
	local varlist `r(varlist)' 
	... 
end

seems to work OK. 

Nick 
[email protected] 

P.S. why do you want to -tokenize-? 

  
-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Matthew L
Dobra
Sent: 08 January 2004 18:15
To: [email protected]
Subject: st: using _rmcoll


Dear Statalisters,

Consider this simple program:

program define myprog
syntax varlist
_rmcoll `varlist'
local varlist r(varlist)
tokenize `varlist'
...
do things
...
end

The simple idea is to take the varlist input, remove any collinear 
variables, replace the initial varlist with the 
noncollinear varlist, and
then tokenize the noncollinear varlist to proceed with the 
things to be
done.  This works fine, so long as I don't have  a lot of 
variables in
varlist.  If I do, then r(varlist) gets cut off at 244 
characters.  Is
there a way to do what I want when the varlist is long?  

Thanks,

Matt Dobra

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