Statalist The Stata Listserver


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

st: creating a new user function in Stata


From   "Carlos Madeira" <[email protected]>
To   [email protected]
Subject   st: creating a new user function in Stata
Date   Fri, 09 Feb 2007 23:54:07 +0000

Hi all,

I had a problem writing a user-written function in Stata and was wondering if you could give me a help about how to write it. My goal is to create a program that generates a variable with cdf values of a bivariate-beta function in a similar way that the function ibeta(a1,b1,x1) would do.

I know how to calculate the cdf of my bivariate beta, but to avoid the tedious task of writing a long expression every time I use it in my code I thought it better to write a new function. I don't have a good clue however of how to do this.

program cdf_biv_beta(a1,b1,a2,b2, w, x1, x2)

cdf_biv_beta = ibeta(a1,b1,x1)(1+w(x1-a1/(a1+b1))(x2-a2/(a2+b2))ibeta(a2,b2,x2) + (....)

end


(where x1 or x2 are variables that denote the values for integrating the cdf, and a1,b1, a2, b2, w are variables that denote "the parameters" of my bivariate cdf, if for example I write a code saying a1=exp(xb) )

Then cdf_biv_beta would give a new variable with the cdf values obtained from the above function at the points given by variables (x1,x2).

Can someone give me some advice about how to do this? I don't exactly know where to define the "input variables" of the function and the "output" variable.

Carlos Madeira

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

*
* 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/




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