Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Misha Spisok <misha.spisok@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: mata conformability error, but matrices are conformable |

Date |
Fri, 7 May 2010 18:57:37 -0700 |

Hello, Statalist! I am getting the following error due to some code I have written (given below with complete, but short, working example to reproduce the error): *: 3200 conformability error makexb(): - function returned error <istmt>: - function returned error I would expect this to mean that, within my -mata- code, I am trying to multiply non-conformable matrices. But, when doing the steps in my code interactively in -mata-, it doesn't seem to be the case. I suspect the problem lies elsewhere, but I can't figure out where. One guess is how I'm attempting to retrieve things from Stata in Mata is the problem. I used, -set trace on-, but that didn't help (me) any. (I developed my code after modifying some code in a presentation by Prof. Baum and checking out [M]. As is, the code is a stepping stone, but I can't get to this first step.) My goal, at this point, is, given a dependent variable, y, and some independent variables, x1, x2, ..., xK, to create a new variable Xb which is the prediction of a linear regression of y on x1, x2, ..., xK. I know there's an easy way to do this with -predict-, but this is just a step. (baby steps!) My program: ----------------- program calcp, rclass version 10.1 syntax varlist [if] [in] marksample touse tokenize `varlist' global lhs "`1'" mac shift global rhs "`*'" regress `lhs' `rhs' if `touse' mata: makexb("`rhs'", "`touse'") end version 10.1 mata: void makexb(string scalar rhs, string scalar touse) { X = st_data(., tokens("`rhs'")) b = st_matrix("e(b)") Xb = X*b' st_addvar("float", "Xb") } end ------------------- So, after saving this as an .ado file, I can do the following. sysuse auto, clear local xlist mpg-length calcp price `xlist' But, as noted above, I get this error: *: 3200 conformability error makexb(): - function returned error <istmt>: - function returned error r(3200); end of do-file r(3200); An aside is, Why does the regression not include a constant? Is it because Stata is limiting itself to regressing `lhs' on `rhs' as given? Thanks! Misha * * 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/

**Follow-Ups**:**Re: st: mata conformability error, but matrices are conformable***From:*Maarten buis <maartenbuis@yahoo.co.uk>

- Prev by Date:
**st: Need Kullback–Leiber divergence measure** - Next by Date:
**st: estimating a correlation matrix after using MI** - Previous by thread:
**st: Need Kullback–Leiber divergence measure** - Next by thread:
**Re: st: mata conformability error, but matrices are conformable** - Index(es):