Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: Creating row of binary variables for MVNP

From   "Plum, Alexander" <>
To   "" <>
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')


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

Phone:   +49 391 67 18692
Fax:         +49 391 67 11218

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index