Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Categorical variable and -nestreg-


From   Richard Williams <[email protected]>
To   [email protected], "[email protected]" <[email protected]>
Subject   Re: st: Categorical variable and -nestreg-
Date   Mon, 02 Sep 2013 21:03:51 -0500

At 07:21 PM 9/2/2013, William Buchanan wrote:
Check your syntax again. The issue is probably with the interaction terms that you include using factor variable notation. Create the interactions first as new variables and try using those instead.

Beat me to it. But elaborating a bit:

Yes, nestreg does not allow factor variables. I'm not sure where that is noted in the documentation but it is clear that that is the case.

Further, because of the c. notation, there would be a problem even if condition was continuous too. I think of factor variables as being categorical. But if I am reading the docs right, if you say c.var1, var1 is also now considered a factor variable. The Stata 13 Users Guide section 11.4.3.1 says "i.group is called a factor variable, although more correctly, we should say that group is a categorical variable to which factor-variable operators have been applied. There are five factor-variable operators:...c. unary operator to treat as continuous."

So if I am reading that right, we could say "c.var1 is called a factor variable, although more correctly, we should say that var1 is a continuous variable to which factor-variable operators have been applied."

Whether I am phrasing it right or not, if you use notation like c.var1, you can get the error message "factor variables not allowed."

One other tidbit: If there are no interaction terms, Stata assumes vars are continuous unless you use i. to tell it otherwise. But if you have interaction terms, e.g. v1#v2, Stata assumes that both terms are categorical unless you add the c. notation. Which seems a bit inconsistent to me but I suppose there is some reason for it.

I am a little surprised, though, that xi: does not work. Can you show the exact syntax? The help for xi says

i.varname1*varname3 creates dummies for categorical variable varname1 and continuous variable varname3: all interactions and main effects

So, I think if you got rid of the c. parts, xi and nestreg together would work.


HTH,
Billy

Sent from my iPhone

On Sep 2, 2013, at 19:09, David de Jong <[email protected]> wrote:

> Hello all,
>
> New Stata user here. I'm trying to use -nestreg- to run a hierarchical
> (not stepwise) regression. I'm having some trouble, and I was hoping
> someone could lend a hand. This is the syntax:
>
> nestreg: regress z_target_RT_c12 (condition) ///
> (z_neutral_RT_c12 z_nonword_RT_c12 z_int_goals_c12 z_enhance_goals_c12) ///
> (c.z_int_goals_c12#condition c.z_enhance_goals_c12#condition)
>
> Condition is categorical, with 2 possible values. All other variables
> are continuous.
>
> When I run the syntax, I receive the error:
> factor variables not allowed
> r(101);
>
> I've figured out nestreg can't handle factor variables, as indicated
> by this error message. I've tried using "xi:" before "nestreg" and
> appending "i." to "condition" but I still get the "factor variables
> not allowed" error message. Is it simply the case that I cannot use
> -nestreg- for categorical variables? If so, are there other ways to
> deal with this?
>
> Thanks so much,
>
> David de Jong
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  [email protected]
WWW:    http://www.nd.edu/~rwilliam

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index