Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error r(509): matrix operators that return matrices not allowed in this context from xtgee

    Hello,

    I estimated a population-averaged model with this code and would like to store the beta coefficient estimate from the intervention variable, but I receive this error even though I get output from the model:

    Code:
    xtgeebcv depvar intervention, cluster(id) family(gaussian) link(identity) corr(exchangeable) stderr(kc)
    I am experiencing the same problem I think as this Statalist post: http://statalist.1588530.n2.nabble.c...td5635820.html.

    The difference, however, is that I am trying to store it in a scalar like so. Yet the error pops up: matrix operators that return matrices not allowed in this context r(509);

    Code:
    tempname M
    matrix `M' = r(table)
    return scalar b = _b[intervention]
    How can I successfully store the intervention estimate in my scalar? Does it matter if I use ereturn or return? In either case, I find that I still get the error.

  • #2
    You do not give a context for what you are doing. If you are not writing a program (using the program define command) but a simply running commands in a do-file, then it seems likely that
    Code:
    scalar b = _b[intervention]
    is sufficient - the matrix M has no relevance to creating the scalar. Here is an example using the sample data for xtgeebcv.

    Code:
    . use mkvtrial.dta
    
    . quietly tabulate stratum, generate(stratum)
    
    . xtgeebcv know arm stratum2 stratum3 ethnicgp, family(binomial) link(logit) ///
    >             outcome(know) cluster(community) stderr(kc)  nolog
     
    Note: Family is binomial and link is logit
    Using exchangeable working correlation
    with scale parameter divided by K - p
    
    GEE population-averaged model                   Number of obs     =      4,100
    Group variable:                  community      Number of groups  =         20
    Link:                                logit      Obs per group:
    Family:                           binomial                    min =        169
    Correlation:                  exchangeable                    avg =      205.0
                                                                  max =        257
                                                    Wald chi2(4)      =      43.75
    Scale parameter:                         1      Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
            know |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             arm |   .8270697   .1482322     5.58   0.000     .5365398    1.117599
        stratum2 |   .0503953    .179305     0.28   0.779    -.3010361    .4018266
        stratum3 |   .1252695   .1924411     0.65   0.515    -.2519082    .5024471
        ethnicgp |  -.3040093   .0879244    -3.46   0.001    -.4763379   -.1316807
           _cons |  -.0108448    .164238    -0.07   0.947    -.3327454    .3110558
    ------------------------------------------------------------------------------
     
    Kauermann-Carroll bias-corrected standard errors
    t-statistic with K - p degrees of freedom
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             arm |   .8270697   .1665778     4.97   0.000     .4720175    1.182122
        stratum2 |   .0503953   .2148433     0.23   0.818    -.4075324     .508323
        stratum3 |   .1252695   .2094122     0.60   0.559    -.3210821     .571621
        ethnicgp |  -.3040093   .1029562    -2.95   0.010    -.5234552   -.0845634
           _cons |  -.0108448   .1979338    -0.05   0.957    -.4327307    .4110411
    ------------------------------------------------------------------------------
    
    . scalar b = _b[arm]
    
    . display b
    .82706966

    Comment


    • #3
      This problem has been subsumed - with much greater detail provided - in the discussion at

      https://www.statalist.org/forums/for...st-be-positive

      Comment

      Working...
      X