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]

st: Computing predicted probabilities in multi-level model (xtmelogit)


From   "Michael.Stuetzer" <[email protected]>
To   [email protected]
Subject   st: Computing predicted probabilities in multi-level model (xtmelogit)
Date   Fri, 22 Oct 2010 10:52:15 +0200

Dear Colleagues,

I want to visualize a moderation effect in a multi-level model and would like to ask whether or not the code (adapted from www.ats.ucla.edu/stat/stata/faq/xtmelogit_prob.htm) below is suitable to produce the predicted probabilities to do this. To be more precise: I have data at two levels. The dependent variable is at level 1 and binary. Some predictors are at level 1 (Zopport Zknowent Zownmge) and one is from level 2 (Zbipwachstum_l1t5). I'm interested in the cross-level interaction between Zownmge and Zbipwachstum_l1t5 (int_knowent_bipwachstum5). In order to compute predicted probabilities I followed the recommendations to hold the other variables at their respective mean.

However, I have a couple of questions.
1. In the code below, I use the mean of the level 2 variable over the entire dataset. However, for different regions (this is the level 2) I have different number of observations at the level 1, which has an impact on the mean. Wouldn't it be more correct to use the mean of the level 2 variable accross the (lets say) 300 regions?

2. From my experience with the prvalue command, I also hold the interaction term at the respective mean when computing the predicted probabilities. Is this also correct in multi-level modeling?

3. In this first step I compute the predicted probabilities at the mean of Zbipwachstum_l1t5, thereafter at mean + sd, and mean - sd. Do I also have to alter the level of the interaction term int_knowent_bipwachstum5 or does this interaction term is always held constant at the mean?


Thanks a lot
Michael

use...
quietly summarize Zopport
global opport=r(mean)
quietly summarize Zknowent
global knowent=r(mean)
quietly summarize Zbipwachstum_l1t5
global bipwachstum_l1t5=r(mean)-r(sd)
quietly summarize int_ownmge_bipwachstum5
global int_ownmge_bipwachstum=r(mean)

xtmelogit latent Zownmge Zknowent Zopport Zbipwachstum_l1t5 int_ownmge_bipwachstum5 || kreis:,


/* get vector of logistic coefficients */
matrix b = e(b)
matrix list b

/* keep only the elements of b that are of interest */
matrix b = b[1,2..7]
matrix list b

/* predict random effects */
predict b1, reffects

/* create vector of random effects */
quietly tab b1, matrow(b1)
matrix list b1

*
mata
/*  bring vectors b and b1 into Mata */
b  = st_matrix("b")
b1 = st_matrix("b1")

/* bring the global macro variables into Mata */
knowent    =  strtoreal(st_global("knowent"))
opport    =  strtoreal(st_global("opport"))
bipwachstum_l1t5=  strtoreal(st_global("bipwachstum_l1t5"))
bipwachstum_l1t5
int_ownmge_bipwachstum = strtoreal(st_global("int_ownmge_bipwachstum"))
end


mata
/* loop to compute probabilities for knowent and not knowent */
for (ownmge=0; ownmge<=1; ownmge++) {
x=(ownmge \ knowent \ opport \ bipwachstum_l1t1 \ int_ownmge_bipwachstum \ 1)
 xb = b*x
 xbr = xb:+b1
 expxbr = exp(xbr)
 p = expxbr:/(1:+expxbr)
 mean(p)
}
end

*****



--


Dipl.-Vw. Michael Stützer
Thüringer Gründer Studie/
Lehrstuhl für Mikroökonomik
Friedrich-Schiller-Universität Jena
Carl-Zeiß-Str. 3
D-07743 Jena

Tel.: +49 03641 943207
Fax.: +49 03641 943202

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


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