# Re: st: Basic Matrix Definition Question

 From "Abdel Rahmen El Lahga" To statalist@hsphsun2.harvard.edu Subject Re: st: Basic Matrix Definition Question Date Mon, 15 Oct 2007 21:59:34 +0200

```For your problem I suggest Mata and optimize as suggested by Kit Baum
but I can't say further because I'm a user of Stata 9 and not version
10 with optimize routine.
HTH means Hope This Help ( Mark Schaffer uses this expression frequently)
AbdelRahmen

2007/10/15, Thomas Jacobs <thomasjacobs@gmail.com>:
> Dear Abdel,
>
> Thanks very much.  I totally missed the mkmat command in the manual.
> Although I probably made the example too simple, I am trying to write
> a program to solve for two equations in two unknowns so I am building
> a partial derivative matrix for inverting.  I calculate each of the 4
> partials as variables and then combine them into a matrix.  I was
> stuck on the create matrix step.  Using local macros worked as well
> with a matrix command.  I assume that I would need to first create two
> column vectors from 2 of the four variables and then combine these
> with another mkmat command.
>
> Does the HTH after the byvar=x,y line in your mata example have a
> specific meaning?
>
> Sincerely,
>
> Tom
>
> On 10/15/07, Abdel Rahmen El Lahga <rahmen.lahga@gmail.com> wrote:
> > I dont understand what your are trying to do here a short ansewer is
> > gen x=1
> > gen y=2
> > mkmat x y , matrix(byvar)
> > matrix list byvar
> > In mata the logic is different
> > mata:
> > x=1
> > y=2
> > byvar=x,y
> > HTH
> > AbdelRahmen
> >
> > 2007/10/15, Thomas Jacobs <thomasjacobs@gmail.com>:
> > > I am trying to create a matrix from a couple of variables.  Let's make
> > > this simple.
> > >
> > > I can hand enter
> > >
> > > matrix byhand = (1,2)
> > >
> > > but if I do
> > >
> > > gen x =1
> > > gen y =2
> > > matrix byvar = (x,y)
> > >
> > > I get x not found even though display x gives me 1.
> > >
> > > What am I missing here and is there a workaround?  Thanks very much.
> > >
> > > Sincerely,
> > >
> > > Tom
> > >
> > > --
> > > Thomas Jacobs
> > > *
> > > *   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/
> > >
> >
> >
> > --
> > AbdelRahmen El Lahga
> > *
> > *   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/
> >
>
>
> --
> Thomas Jacobs
> *
> *   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/
>

--
AbdelRahmen El Lahga
*
*   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/
```