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

# Re: st: Re: three-level gllamm - variable as a nesting variable or a predictor?

 From Lisa Marie Yarnell <[email protected]> To [email protected] Subject Re: st: Re: three-level gllamm - variable as a nesting variable or a predictor? Date Sun, 6 Oct 2013 17:54:36 -0700

```Thanks, Joseph.  The two segments of the study are ascending and
descending halves of a drinking experience; we are studying
alcoholism.  A person in the ascent (Segment A) has different
physiological and mental symptoms than in the descent (Segment B).  So
perhaps this is like repeated measures and suggests a two-level model,
as you said?  But it is not a cross-over study per se, with two
different treatments.  It is just the two halves of a drinking
experience.

In the Stata output, when I constructed the model (again with 305
observations placed into either Segment A or Segment B, nested within
31 individuals), the Stata output showed:
number of level 1 units = 305
number of level 2 units = 62
number of level 3 units = 31

I was confused at first because there are only really 2 levels of
Level 2 (Segment A and Segment B).  I wondered why the output shows 62
units at Level 2.  But my thought was that Stata recognizes the
three-level structure that I specified, and knowing that the Level 2
units are nested in 31 Level 1 persons, it indicates 62 units at Level
2?

Can you explain why the Stata output would show 62 units at Level 2?

Frankly, the way I had specified this model, I am not sure how I would
depict this graphically--it seems mixed-up in some place.

I will think about the alternative model that you suggested:
> generate byte cons = 1
> eq idc: cons
> eq ids: segment
> gllamm drivesf gender aldh2cent braccent segment, ///
>     i(id) nrf(2) eqs(idc ids) ///

On Sun, Oct 6, 2013 at 1:33 AM, Joseph Coveney <[email protected]> wrote:
> Lisa Marie Yarnell wrote:
>
> Is it possible (or meaningful) to have a variable both as a nesting
> variable AND a predictor in a three-level model?
>
> I have a three-level model with 305 observations nested within
> segments of the study (segment A and segment B), which are nested in
> 31 persons.  id is the person id.
>
> So the form of the model is something like:
> gllamm drivesf gender aldh2cent braccent, i(segment id) family(binom)
>
> But can I also put segment as a variable in the model to see its
> direct effect on the dependent variable, contrasting segment B against
> segment A?
>
> I want to put it both as a nesting variable AND a predictor in the
> model.  Is that viable?
>
> --------------------------------------------------------------------------------
>
> From your description, it seems like a cross-over study.  If that's the case,
> then it seems that your model is misspecified.  More to the point, I wouldn't
> call your model a three-level model, but rather two-level.  Each person
> undergoes the same basic Study Segment A and Study Segment B when participating
> in the study (repeated measures).  In the model's random portion, segment should
> be a random coefficient / random slope, and not a nesting factor / separate
> level in a hierarchy--thus my comment that the model comes across as improperly
> specified.
>
> If you look at the Stata documentation for the official -melogit- command,
> you'll see the difference:  its example of a three-level model has a *unique*
> subject nested under a family.  Even with cross-classified random effects, each
> of the two factors has a property of uniqueness (for example, in the classic
> example of students nested in schools who transfer to other schools, both
> students and schools are unique).
>
> So, from your description of the circumstances, the model for -gllamm- would
> look something like:
>
> generate byte cons = 1
> eq idc: cons
> eq ids: segment
> gllamm drivesf gender aldh2cent braccent segment, ///
>     i(id) nrf(2) eqs(idc ids) ///
>
> You can find an analogous model (two-level logistic with a random slope) in the
> examples for the study of contraceptive use in the documentation for the
> official -melogit-; take a look at how the variable "urban" is handled, for
> example:
>
> melogit c_use urban age child* || district: urban, cov(unstruct)
>
> You're probably aware that a sample size of 31 persons might be considered a
> little lightweight for these kinds of methods; you might even have difficulty
> with convergence.  I don't know what drivesf is, but if it's discretized, then
> maybe you can leave it as continuous and use a fixed-effects linear model
> (-xtreg , fe-) and take advantage of the small-sample test statistics that you
> get with it for the difference between study segments.  (Time-invariant
> variables, such as sex, will drop out of the fixed-effects model, but will
> remain in the complementary -xtreg , be-.)
>
> Joseph Coveney
>
> *
> *   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/

--
Lisa M. Yarnell
Department of Psychology
University of Southern California
3620 McClintock Ave.
Mailroom SGM 501, Office 826B
Los Angeles, CA 90089-1061
Mobile, preferred: (617) 548-2893
Office: x0-0850 or (213) 740-0850
Fax: (213) 746-9082
*
*   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/
```