# NOT RUN {
## 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 )
# }
Run the code above in your browser using DataLab