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: does the


From   Wu Zhang <[email protected]>
To   STATA LIST <[email protected]>
Subject   st: does the
Date   Wed, 6 Mar 2013 21:16:44 -0800 (PST)

Hi folks,
 
   I encounter this error message : invalid syntax r(198);
My guess is that 'tabstat' with option 'save' does not work since the matrix xstat is null, but I cannot fix it; any thoughts? thanks!


  My code is as follows:

program ape_total, rclass
      version 8
      syntax varlist(numeric)
      gettoken y x : varlist  /*nice way to split y and x! from Maarten*/
      
    
     
      tabstat `x', statistics( mean p25 p50 p75 p95 ) save   /*'sum' does not work here!*/
      
      mat xstat=r(StatTotal)
      scalar n=rowsof(xstat)
      scalar m=colsof(xstat)
      regress `varlist'
      predict ehat, residual
      mat paraest=e(b)
      
      
     
      forvalues i=1(1)n {
           mat meanvalue=(xstat[i, 1...],1)*paraest'
           scalar meanvalues=meanvalue[1,1]
        forvalues j=1(1)m{     
           scalar alpha`j'=paraest[1,j]
           gen apet`i'`j'=alpha`j'*exp(meanvalues+ehat)/(1+exp(meanvalues+ehat))^2
           sum apet`i'`j'
           return scalar ape`i'`j'=r(mean)
           
     
      }
      }
     
      drop apet* ehat 
      
end

Wu


*
*   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/


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