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

RE: st: Mata in an rclass program to bootstrap

From   "Nick Cox" <>
To   <>
Subject   RE: st: Mata in an rclass program to bootstrap
Date   Sun, 19 Jul 2009 16:43:11 +0100

Let's be clear: The string scalar is used to pass the scalar name. Once
Mata has the name, it can easily access the value. 

For Marteen read Maarten. 


Nelson, Carl


Thank you very much for your help.
I was unaware of argument passing through string scalar when passing a
matrix with st_matrix.
This is very helpful information.

Maarten buis []

--- Nelson, Carl wrote:

> Is there a proper way to embed mata in a program to bootstrap
> that will not create this error?

Here is a silly example. More general advise can be found
here: -help m1_ado-

*-------------- begin example ------------
mata: mata clear
sysuse auto, clear

void foo(string scalar b) {
        bb =st_matrix(b)
        bb = 2:*bb
        st_matrix("b", bb)

program drop _all
program define silly, rclass
        reg mpg foreign
        matrix b = e(b)
        mata: foo("b")
        return scalar b1 = el(b,1,1)
        return scalar b2 = el(b,1,2)
bootstrap b1=r(b1) b2=r(b2), reps(100): silly
*-------------- end example -----------------

*   For searches and help try:

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