Michael,
I've done similar, but not the same graphing, so I may be missing what you
want. The created observations do not have subject specific random
effect, unless you append them with an existing subject specific
identifier. I am not sure exactly what you are after, but here are
several ideas that may move you forward.
1. When I have done something similar in the past, I was plotting the
fixed effects for a continuous outcome. I have used -gllamm- for logits,
but have not subsequently plotted probabilities after -gllamm- , so I am
a bit beyond where I have direct experience in the following suggestions.
In my case, I appended to my full dataset a separate dataset with
artifical subjects with the fixed effects set to my desired values, and
then used the fsample option with gllapred. The appended observations in
that case have no subject specific random effects. (I then made combined
plots of the linear predictions, the fixed effect plots, and also the raw
data, vis a vis AugPred plots in S-Plus,) I don't think this will be what
you are after with your logit model.
2. I would guess that you could set up a loop to append a dataset of the
fixed effects you wanted to remain constant (without droipping the
original dataset), and then rename the appended observations to the real
subjects ID before you generated the random effects, temporarily drop the
original data, and plot the appended observations.
3. I think you could create the random effects for existing subjects using
-gllapred u,u -, and then use -gllapred mu, mu us(um)- to generate
probabilities conditional on the random effects. This would not change
your fixed effects to the constant settings you are looking for.
The key to what you are after is to use - gllapred prob, mu us(um) - to
obtain the predicted probabilities conditional on the random effects. You
will have to work out a scheme to either add observations with the fixed
effects you want, or change existing observations to have the constant
fixed effects you are after temporarily in order to plot them.
I hope this is useful, but remember I am a bit beyond my own direct
experience and my need, while similar, was slightly different than
plotting the conditional probabilities, so I may be missing something
here.
Buzz Burhans
> On 2004-07-06, at 15.58, Winfield Scott Burhans wrote:
>
>> Michael,
>> Can't you do this by creating a dataset of observations with the fixed
>> values you want, appending it to the full dataset, and using the
>> -fsample-
>> option of gllapred?
>>
>> Buzz Burhans
>
>
> Thanks Buzz,
>
> Great idea. And it might have worked too. But to tell you the truth, I
> don't understand how.
> I might have misunderstood you but I tried something like the syntax
> below:
>
> . gllamm resp _Iday_1 _Iday_3 leng _IdayXleng_1 _IdayXleng_3 time
> _IdayXtime_1 _IdayXtime_ ///
> . , i(id) nrf(3) eqs(intercept leng time) link(logit) fam(binomial)
> adapt
>
> . estsave , gen(es_model1)
> . save data1
>
> . drop es_model1
> . replace time = 4
> . replace _IdayXtime_1 = 4 if _IdayXtime_1 > 0
> . replace _IdayXtime_3 = 4 if _IdayXtime_3 > 0
> . save data2
>
> . use data1
> . estsave , from(es_model1)
> . generate model = 1
> . append using data2
> . replace model = 2 if model == .
> . gllapred prob if model == 2 , mu fsample
>
> If I plot the probabilities, the graphs look great. And exactly as I
> thought they would (or better).
>
> However, I have trouble understanding how -gllapred- would know the
> subject specific levels of the random factors when I do like this. Are
> they really the same as in the estimation sample? Am I doing the right
> thing?
>
> I appreciate any explanations that would help me understand this. My
> paper is soon to be submitted (hopefully).
>
> Thanks again Buzz.
>
> If this works, I owe you two by now.
>
> Michael
>
>
>
>
>>> Dear list
>>>
>>> I would like to predict (and plot) conditional probabilities for a
>>> response as a function of one independent variable keeping a second
>>> variable at a constant.
>>>
>>> More specifically, I would like to plot the predicted probabilities
>>> for
>>> _leng_ by _day_ while _time_ == 4 from the model below.
>>>
>>> It is very easy to predict probabilities keeping the random effects at
>>> a given value with -gllapred- but I have yet to find a way for keeping
>>> a fixed effect in -gllamm- at a constant.
>>>
>>> I appreciate all suggestions.
>>>
>>> I think it must be possible to first predict the fixed effects from
>>> the
>>> model with _time_ at a constant (4) and then add the random effects
>>> from the intercept and the random effect of _leng_.
>>>
>>> Thanks for your time.
>>>
>>> Michael
>>>
>>>
>>> Partial display of model:
>>>
>>> . gen const = 1
>>> . eq intercept: const
>>> . eq time: time
>>> . eq leng: leng
>>>
>>> . char day[omit] 2
>>>
>>> . xi i.day*leng i.day*time
>>> . xi: gllamm resp _Iday_1 _Iday_3 leng _IdayXleng_1 _IdayXleng_3 time
>>> _IdayXtime_1 _IdayXtime_ ///
>>> . , i(id) nrf(3) eqs(intercept leng time) link(logit)
>>> fam(binomial)
>>> adapt
>>>
>>> ----------------------------------------------------------------------
>>> --
>>> ------
>>> resp | Coef. Std. Err. z P>|z| [95% Conf.
>>> Interval]
>>> -------------
>>> +----------------------------------------------------------------
>>> _Iday_1 | .5922521 .893279 0.66 0.507 -1.158543
>>> 2.343047
>>> _Iday_3 | .2531786 .9334512 0.27 0.786 -1.576352
>>> 2.082709
>>> leng | 1.571584 1.170692 1.34 0.179 -.7229305
>>> 3.866099
>>> _IdayXleng_1 | 2.473041 1.195547 2.07 0.039 .1298116
>>> 4.81627
>>> _IdayXleng_3 | .4036673 1.225166 0.33 0.742 -1.997614
>>> 2.804949
>>> time | .2418225 .2774821 0.87 0.383 -.3020324
>>> .7856774
>>> _IdayXtime_1 | -.1086444 .2195245 -0.49 0.621 -.5389045
>>> .3216156
>>> _IdayXtime_3 | .2298701 .2278498 1.01 0.313 -.2167072
>>> .6764475
>>> _cons | -5.118715 1.023391 -5.00 0.000 -7.124525
>>> -3.112905
>>> ----------------------------------------------------------------------
>>> --
>>> ------
>>>
>>> Variances and covariances of random effects
>>> ----------------------------------------------------------------------
>>> --
>>> ------
>>>
>>>
>>> ***level 2 (subject)
>>>
>>> var(1): 4.0975884 (2.5381436)
>>> cov(2,1): -1.2187546 (1.9747622) cor(2,1): -.41187287
>>>
>>> var(2): 2.1368686 (2.1924798)
>>> cov(3,1): -.37716119 (.56908407) cor(3,1): -.26415951
>>> cov(3,2): -.79399432 (.56427558) cor(3,2): -.77007299
>>>
>>> var(3): .49750012 (.24800011)
>>> ----------------------------------------------------------------------
>>> --
>>> ------
>>>
>>>
>>>
>>> ------------------------------------------------
>>> Michael Ingre , PhD student & Research Associate
>>> Department of Psychology, Stockholm University &
>>> National Institute for Psychosocial Medicine IPM
>>> Box 230, 171 77 Stockholm, Sweden
>>>
>>> *
>>> * 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/
>>
>>
> ------------------------------------------------
> Michael Ingre , PhD student & Research Associate
> Department of Psychology, Stockholm University &
> National Institute for Psychosocial Medicine IPM
> Box 230, 171 77 Stockholm, Sweden
>
> *
> * 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/