Statalist


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

st: RE: GLLAMM


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: GLLAMM
Date   Tue, 16 Feb 2010 18:01:12 -0000

I don't have an answer to any question you're asking here. I do see several lines of the form 

gen lvita=  log(vita+0.001)

which look as if you want a log transformation of various predictors but are inhibited by zeros. I often see people who appear to imagine that adding a small number first is a very conservative change, but the opposite is the case: zeros are mapped to substantial negative numbers and this transformation may create outliers. Thus for example x = 0 1 2 get mapped by log(0.001 + x) as follows 

. mata : log(0.001 :+ (0..2))
                  1              2              3
    +----------------------------------------------+
  1 |  -6.907755279    .0009995003    .6936470556  |
    +----------------------------------------------+

Examples like this show that the side-effect of adding 0.001 first is only small if your largest value of x is much more than exp(7). 

Nick 
n.j.cox@durham.ac.uk 

arosella

I'm trying to fit a GLLAMM to data from a case control study. I'd want to estimate the direct effect of some fixed-covariates (her only gender) as well as random effects of a latent variable (Protective diet) comprised of four observed variables (vitamins intake). Moreover  I'd want to estimate the indirect effect of the covariates via latent variable and an other random effect (non latent variable) on the thr outcome (see STATA code below). I get no error message from stata (that is I suppose that the syntax is right) but there are problems with the convergence (adaptative quadrature): some times stata says me that cannot calculate the LL and some times it take a lot of time until LL become flat. The problem may be of biological origin (no variability) but I don't believe that. Rarely a GLLAMM converges although I'm sure the code i right. Someone has encountered a similar problem fitting GLLAMM?
Thank you in advance. 
 //======== beginning of sample code =========
// Data management
rename salud y
// Let the indicators of the performance be perf1 - perf3
gen lvita=  log(vita+0.001)
gen lvitb6= log(vitb6+0.001)
gen lvitc=  log(vitc+0.001)
gen lvite=  log(vite+0.001)
gen resp1 = y
gen resp2 = lvita
gen resp3 = lvitc
gen resp4 = lvitb6
gen resp5=  lvite

// reshape to gllamm
gen i = _n
reshape long resp, i(i) j(j 1-5)
tab j, gen( v )
gen var=1
replace var=2 if j>1
ren v1 caco
ren v2 vit1a
ren v3 vit2b6
ren v4 vit3c
ren v5 vit4e
gen int0=sexo*caco
gen int1=sexo*vit1a
gen int2=sexo*vit2b6
gen int3=sexo*vit3c
gen int4=sexo*vit4e
// measurement equations
eq id1: caco vit1a vit2b6 vit3c vit4e 
eq id2: gras

// exogenous variables affecting the latent variables: x1 - x8
*eq r1 : sexo edadcat
// Model
gllamm resp caco vit1a vit2b6 vit3c vit4e int* gras, ///
          nocons i(ident) eq(id1 id2) family(bin gauss) link(logit ident) ///
          nrf(2) lv(var) fv(var) nip(20) trace adapt
======== end of sample code =========


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index