Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Creating row of binary variables for MVNP


From   "Plum, Alexander" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Creating row of binary variables for MVNP
Date   Tue, 20 Nov 2012 10:16:57 +0000

Dear StataUsers,
I'm using the command mvnp, which calculates multivariate normal probabilities. When the code is used, a ordered set of binary variables must be specified. My aim is to create this set by a loop inside a program.
How it should look like:
egen double `fi' =  mvnp(`zb1' `xb2' `xb3'), chol(`C3') dr(50) prefix(z)  signs(`k1' `k2' `k3') 
How I want it to look like (those terms inside the bracket of mvnp() and signs() changed):
egen double `fi' =  mvnp(`ev3'), chol(`C3') dr($dr) prefix(z) signs(`si3')
where `ev' is a local that contains: `xb1' `xb2' `xb3'
and `si' is a local that contains: `k1' `k2' `k3'

Here is some extract from my program code:

program define program
                args todo b lnf
                ...

                forvalues r =  1/3 {
                tempvar k`r' xb`r'
                by id: gen double `k`r'' =  (2*y[`r']) - 1
                by id: gen double `xb`r'' =  `beta'[`r']
                }

                local sign1= `k1'
                local ev1= `xb1'
                forvalues s= 2/3{
                local j= `s'-1
                local sign`s'= "`sign`j'',`k`s''"
                local ev`s'=  "`ev`j'',`xb`s''" 
                }

                egen double `fi' =  mvnp(`ev3'), chol(`C3') dr($dr) prefix=
(z) signs(`sign3')


end

Thank you for your help

Alexander Plum

---
Dipl.-Vw. Alexander Plum

Research Assisstant
Chair of Public Economics
Faculty of Economics and Management
Otto-von-Guericke University Magdeburg
Building 22, Office E-216
P.O. Box 4120
D-39016 Magdeburg
Germany

Phone:   +49 391 67 18692
Fax:         +49 391 67 11218
E-Mail: [email protected]
Web:    www.vwl1.ovgu.de

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index