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

From |
Matthew Weinberg <mweinber@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: basic quesion about using structures in mata |

Date |
Mon, 17 Sep 2007 15:17:19 -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/

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

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