Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/mvProbitMargEff.R
mvProbitExp
calculates expected outcomes
from multivariate probit models.
mvProbitMargEff
calculates marginal effects of the explanatory variables
on expected outcomes from multivariate probit models.
The margEff
method for objects of class "mvProbit"
is a wrapper function
that (for the convenience of the user)
extracts the relevant information from the estimation results
and then calls mvProbitMargEff
.
1 2 3 4 5 6 7 8 9 10 11 12 13  mvProbitExp( formula, coef, sigma = NULL, data,
cond = FALSE, algorithm = "GHK", nGHK = 1000, random.seed = 123, ... )
mvProbitMargEff( formula, coef, sigma = NULL, vcov = NULL, data,
cond = FALSE, algorithm = "GHK", nGHK = 1000,
eps = 1e06, dummyVars = NA, addMean = FALSE,
returnJacobian = FALSE, random.seed = 123,
... )
## S3 method for class 'mvProbit'
margEff( object, data = eval( object$call$data ),
cond = FALSE, othDepVar = NULL, dummyVars = object$dummyVars,
atMean = FALSE, calcVCov = FALSE, ... )

formula 
a onesided or twosided 
coef 
a numeric vector of the model coefficients;
if argument 
sigma 
optional argument for specifying
the covariance/correlation matrix of the residuals
(must be symmetric and have ones on its diagonal);
if this argument is not specified,
the correlation coefficients must be specified by argument 
vcov 
an optional symmetric matrix specifying the variancecovariance matrix of all coefficients (model coefficients and correlation coefficients); if this argument is specified, the approximate variance covariance matrices of the marginal effects are calculated and returned as an attribute (see below). 
data 
a 
cond 
logical value indicating
whether (marginal effects on) conditional expectations (if 
algorithm 
algorithm for computing integrals
of the multivariate normal distribution,
either function 
nGHK 
numeric value specifying the number of simulation draws of the GHK algorithm for computing integrals of the multivariate normal distribution. 
eps 
numeric, the difference between the two values of each (numerical) explanatory variable that is used for the numerical differentiation. 
dummyVars 
optional vector containing the names (character strings)
of explanatory variables
that should be treated as dummy variables (see section ‘Details’).
If 
addMean 
logical.
If 
returnJacobian 
logical.
If 
random.seed 
an integer used to seed R's random number generator;
this is to ensure replicability
when computing (cumulative) probabilities of the multivariate normal distribution
which is required to calculate the conditional expectations;

object 
an object of class 
othDepVar 
optional scalar or vector for specifying
the values of the (other) dependent variables
when calculating the marginal effects on the conditional expectations.
If this argument is a scalar (zero or one),
it is assumed that all (other) dependent variables have this value
at all observations.
If this argument is a vector (filled with zeros or ones)
with length equal to the number of dependent variables,
it is assumed that the vector of dependent variables has these values
at all observations.
If this argument is 
atMean 
logical.
If 
calcVCov 
logical.
If 
... 
additional arguments to 
When calculating (marginal effects on) unconditional expectations,
the lefthand side of argument formula
is ignored.
When calculating (marginal effects on) conditional expectations
and argument formula
is a onesided formula
(i.e. only the righthand side is specified)
or argument othDepOne
is TRUE
,
(the marginal effects on) the conditional expectations
are calculated based on the assumption
that all other dependent variables are one.
The computation of the marginal effects
of dummy variables
(i.e. variables specified in argument dummyVars
)
ignores argument eps
and evaluates the effect of increasing these variables from zero to one.
The marginal effects of (continuous) variables
(i.e. variables not specified in argument dummyVars
)
are calculated by evaluating the effect
of increasing these variables from their actual values minus 0.5 * eps
to their actual values plus 0.5 * eps
(divided by eps
).
If the model has n dependent variables (equations)
and k explanatory variables in each equation,
the order of the model coefficients in argument coef
must be as follows:
b_{1,1}, ..., b_{1,k},
b_{2,1}, ..., b_{2,k}, ...,
b_{n,1}, ..., b_{n,k},
where b_{i,j} is the coefficient
of the jth explanatory variable in the ith equation.
If argument sigma
is not specified,
argument coef
must additionally include following elements:
R_{1,2}, R_{1,3}, R_{1,4}, ..., R_{1,n},
R_{2,3}, R_{2,4}, ..., R_{2,n}, ...,
R_{n1,n},
where R_{i,j} is the correlation coefficient corresponding to
the ith and jth equation.
If argument vcov
of function mvProbitMargEff
is specified
or argument calcVCov
of the margEff
method is TRUE
,
the approximate variance covariance matrices of the marginal effects
are calculated at each observation by using the ‘delta method’,
where the jacobian matrix of the marginal effects
with respect to the coefficients is obtained by numerical differentiation.
The ‘state’ (or ‘seed’) of R's random number generator
is saved at the beginning of the call to these functions
and restored at the end
so that these functions do not affect the generation
of random numbers outside this function
although the random seed is set to argument random.seed
and the calculation of the (cumulative) multivariate normal distribution
uses random numbers.
mvProbitExp
returns a data frame
containing the expectations of the dependent variables.
mvProbitMargEff
and the margEff
method return a data frame
containing the marginal effects of the explanatory variables
on the expectations of the dependent variables.
If argument vcov
of function mvProbitMargEff
is specified
or argument calcVCov
of the margEff
method is TRUE
,
the returned data frame has an attribute vcov
,
which is a threedimensional array,
where the first dimension corresponds to the observation
and the latter two dimensions span the approximate variance covariance matrix
of the marginal effects calculated for each observation.
If argument returnJacobian
of function mvProbitMargEff
or method margEff
is set to TRUE
,
the returned data frame has an attribute jacobian
,
which is a threedimensional array
that contains the Jacobian matrices of the marginal effects
with respect to the coefficients at each observation,
where the first dimension corresponds to the observations,
the second dimension corresponds to the marginal effects,
and the third dimension corresponds to the coefficients.
Arne Henningsen
Greene, W.H. (1996): Marginal Effects in the Bivariate Probit Model, NYU Working Paper No. EC9611. Available at http://ssrn.com/abstract=1293106.
mvProbit
,
mvProbitLogLik
,
probit
,
glm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58  ## generate a simulated data set
set.seed( 123 )
# number of observations
nObs < 10
# generate explanatory variables
xData < data.frame(
const = rep( 1, nObs ),
x1 = as.numeric( rnorm( nObs ) > 0 ),
x2 = as.numeric( rnorm( nObs ) > 0 ),
x3 = rnorm( nObs ),
x4 = rnorm( nObs ) )
# model coefficients
beta < c( 0.8, 1.2, 1.0, 1.4, 0.8,
0.6, 1.0, 0.6, 1.2, 1.6,
0.5, 0.6, 0.7, 1.1, 1.2 )
# covariance matrix of error terms
library( miscTools )
sigma < symMatrix( c( 1, 0.2, 0.4, 1, 0.1, 1 ) )
# unconditional expectations of dependent variables
yExp < mvProbitExp( ~ x1 + x2 + x3 + x4, coef = c( beta ),
sigma = sigma, data = xData )
print( yExp )
# marginal effects on unconditional expectations of dependent variables
margEffUnc < mvProbitMargEff( ~ x1 + x2 + x3 + x4, coef = c( beta ),
sigma = sigma, data = xData )
print( margEffUnc )
# conditional expectations of dependent variables
# (assuming that all other dependent variables are one)
yExpCond < mvProbitExp( ~ x1 + x2 + x3 + x4, coef = beta,
sigma = sigma, data = xData, cond = TRUE )
print( yExpCond )
# marginal effects on conditional expectations of dependent variables
# (assuming that all other dependent variables are one)
margEffCond < mvProbitMargEff( ~ x1 + x2 + x3 + x4, coef = beta,
sigma = sigma, data = xData, cond = TRUE )
print( margEffCond )
# conditional expectations of dependent variables
# (assuming that all other dependent variables are zero)
xData$y1 < 0
xData$y2 < 0
xData$y3 < 0
yExpCond0 < mvProbitExp( cbind( y1, y2, y3 ) ~ x1 + x2 + x3 + x4,
coef = beta, sigma = sigma, data = xData, cond = TRUE )
print( yExpCond0 )
# marginal effects on conditional expectations of dependent variables
# (assuming that all other dependent variables are zero)
margEffCond0 < mvProbitMargEff( cbind( y1, y2, y3 ) ~ x1 + x2 + x3 + x4,
coef = beta, sigma = sigma, data = xData, cond = TRUE )
print( margEffCond0 )

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.