Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: [Mata] passing a function to mata

From   Antoine Terracol <>
Subject   st: [Mata] passing a function to mata
Date   Thu, 25 Aug 2005 17:32:33 +0200

Dear _all

I'm trying to write mata code to evaluate integrals |f(x)g(x) (where g(x)is the standard normal pdf) by Gauss-Hermite quadrature (I know this has been done before in Stata, but I'm trying to learn mata, so I thought I might give it a try).

I was able to code for the nodes and weight vectors, but I can't figure out how to tell mata which fuction f(x) I wish to evaluate.

I want to be able to specify the f(x) function, say x^2, when calling the mata program

Here is a sketch of the code :

void gaussher(scalar node, funct){

[compute nodes (x) and weight (w) vectors]


[return stuff]

If I type -gaussher(12 , x:^2)-

mata complains that "x not found"

but if I type -gaussher(12 , "x:^2")-

mata complains that "nonnumeric found where numeric required"

Could anyone point me to the correct way of passing such arguments to a mata program ?


Ce message a été vérifié par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a été trouvé.

* For searches and help try:

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