Statalist The Stata Listserver


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

st: get predictions using mata


From   dferry <[email protected]>
To   [email protected]
Subject   st: get predictions using mata
Date   Wed, 30 Aug 2006 11:41:16 -0400

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:

--start--
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)
	return(y)
}
--end--

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
r(3200);

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:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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