# NOT RUN {
## generate a simulated data set
set.seed( 123 )
# number of observations
nObs <- 10
# generate explanatory variables
xMat <- cbind(
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 <- cbind( c( 0.8, 1.2, -1.0, 1.4, -0.8 ),
c( -0.6, 1.0, 0.6, -1.2, -1.6 ),
c( 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 ) )
# generate dependent variables
yMatLin <- xMat %*% beta
yMat <- ( yMatLin + rmvnorm( nObs, sigma = sigma ) ) > 0
colnames( yMat ) <- paste( "y", 1:3, sep = "" )
# log likelihood values
myData <- as.data.frame( cbind( xMat, yMat ) )
logLikVal <- mvProbitLogLik( cbind( y1, y2, y3 ) ~ x1 + x2 + x3 + x4,
coef = c( beta ), sigma = sigma, data = myData )
print( logLikVal )
# }
Run the code above in your browser using DataLab