[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RE: st: Stata 11 Announcement (statalist-digest V4 #3467)

From (Vince Wiggins, StataCorp)
Subject   Re: RE: st: Stata 11 Announcement (statalist-digest V4 #3467)
Date   Sat, 27 Jun 2009 11:07:02 -0500

About the new factor-variables features in Stata 11 Allan Reese
<> writes,

> The # notation makes sense, but it may be subtle for many users and
> leaves the possibility to confuse fitting variables as continuous or
> discrete.  If I understand Bill's example sex#group is parsed as
> simply because # was used.  Hence do you *have* to use
> the new c. in ...

The short answer is yes, the c. is required to designate a
variable in an interaction as continuous.  The short reason is
that most people will create more interactions with factor
variables than with continuous variables.  Some people will do
the opposite and wish that we had jumped the other way.  Those
people may be able to console themselves with the fact that it
requires very little typing to designate a set of variables as

To create a regression of mpg on foreign and several continuous
covariates, where we want to estimate the effect of each
covariate separately for foreign and domestic cars, we might be
tempted to type,

    . regress mpg i.foreign price weight trunk turn headroom 
              foreign#c.price foreign#c.weight foreign#c.trunk 
	      foreign#c.turn foreign#c.headroom

Or, if we knew a bit more about factor-variable notation,

    . regress mpg foreign##(c.price c.weight c.trunk c.turn c.headroom)

The latter takes advantage of the factorial operator ## and
parenthesis binding.

Because the new factor variable syntax is an algebra, however,
we don't even need to repeat the c.'s.  We can also type,

    . regress mpg foreign##c.(price weight trunk turn headroom)

-- Vince

*   For searches and help try:

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