Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: get predictions using mata

Subject   st: get predictions using mata
Date   Wed, 30 Aug 2006 17:01:31 -0400

Danielle ,
I  am not a mata specialist but for the second question,
I think you should use st_matrix.

Danielle wrote:

 Dear Statalisters,                                                              
 I am using -arima- with a panel dataset (possible if you specify the            
 "condition" option). But, the postestimation commands don't work, so I am       
 attempting to compute predictions and MSE myself, using mata, which I           
 am just beginning to learn.                                                     
 I wrote the following little function to simulate getting predictions:          
 real matrix test(real rowvector b, real matrix X)                               
              real matrix y                                                      
              for(i=1; i<=cols(X); i++) {                                        
                          real scalar yi                                         
                          yi = b * X[i, .]'                                      
              y = (y \ yi)                                                       
 When I run:                                                                     
 b = (1, 2, 3, 4)                                                                
 X = (1, 2, 3, 4 \ 5, 6, 7, 8 \ 9, 10, 11, 12 \ 13, 14, 15, 16)                  
 test(b, X)                                                                      
 I get the following error msg:                                                  
 : test(b, X)                                                                    
                   test():  3200  conformability error                           
                  <istmt>:     -  function returned error                        
 I suspect that part of the problem is the "i" subscripting. In any              
 case, can someone please offer advice on how to fix this? Or, even better,      
 has anyone already written something to generate predictions?                   
 Also, after I run -arima-, and get the coefficient matrix e(b), how do          
 I get this to be a mata matrix?                                                 
 Thank you,                                                                      
 Danielle Ferry                                                                  

*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index