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

From |
Matthew Weinberg <[email protected]> |

To |
[email protected] |

Subject |
st: basic mata structure question |

Date |
Mon, 17 Sep 2007 15:03:25 -0400 |

I'm trying to use structures for the first time and am having a little trouble. I want the function markups to take three arguments (s,p,b) and return three arguments (margins, marks, and costs). I'm getting back one My code is: mata struct mups{ /*define the structure*/ real matrix margins real matrix marks real matrix costs } struct mups function markups(s,p,b) /*define the function*/ { struct mups scalar ms /*declare structure variable*/ n=rows(s) S=J(n,n,0) for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ S[i,j]=-b*s[i]*s[j] } } for(i=1;i<=n;i++){ S[i,i]=-b*s[i]*s[i]+b*s[i] } Omega=I(n)*S ms.margins=invsym(Omega)*s ms.costs=p-ms.margins ms.marks=(p-ms.costs):/p return(ms) } end When I evaluate my function, I get back what something like 0x27c65c instead of the three vectors margins, costs, and marks. I'd really appreciate it if somebody could tell me what I'm doing wrong. Thanks, Matt * * 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/

**Follow-Ups**:**Re: st: basic mata structure question***From:*"Ben Jann" <[email protected]>

- Prev by Date:
**st: A drawing in Stata Journal** - Next by Date:
**st: basic quesion about using structures in mata** - Previous by thread:
**st: A drawing in Stata Journal** - Next by thread:
**Re: st: basic mata structure question** - Index(es):

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