LLikelihoodDE: Log likelihood of market in disequilibrium model

Description Usage Arguments Value Examples

View source: R/Disequilibrium.R

Description

Log likelihood of market in disequilibrium model

Usage

1
2
LLikelihoodDE(theta, Y, X, transformR3toPD = TRUE, summed = TRUE,
  MaskRho = FALSE)

Arguments

theta

A vector of parameter values to obtain the gradient at. The order of parameters is coefficients of equation 1, coefficients of equation 2, variance of equation 1, correlation of equations 1 and 2, and variance of equation 2.

Y

A vector of observed responses.

X

A list of two elements. The first element is a N x k[1] design matrix for equation 1 and the second element is a N x k[2] design matrix for equation 2.

transformR3toPD

A logical to determine if the covariance matrix is transformed to an unrestricted 3 dimension real space (transformR3toPD = TRUE) or not (transformR3toPD = FALSE).

summed

A logical to determine if the negative log likelihood values are summed over observations.

MaskRho

A logical or numeric to determine if the correlation is masked. A value of FALSE means the correlation is not fixed. A value between -1 and 1 will fix the correlation to that value.

Value

A scalar value of the negative log likelihood if summed = TRUE, else a N length vector of negative log likelihood observations.

Examples

 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
set.seed(1775)
library(MASS)
beta01 = c(1,1)
beta02 = c(-1,-1)
N = 10000
SigmaEps = diag(2)
SigmaX = diag(2)
MuX = c(0,0)
par0 = c(beta01, beta02, SigmaX[1, 1], SigmaX[1, 2], SigmaX[2, 2])

Xgen = mvrnorm(N,MuX,SigmaX)
X1 = cbind(1,Xgen[,1])
X2 = cbind(1,Xgen[,2])
X = list(X1 = X1,X2 = X2)
eps = mvrnorm(N,c(0,0),SigmaEps)
eps1 = eps[,1]
eps2 = eps[,2]
Y1 = X1 %*% beta01 + eps1
Y2 = X2 %*% beta02 + eps2
Y = pmin(Y1,Y2)

p1 = 2
p2 = 2
theta = c(beta01, beta02, log(SigmaX[1, 1]), atanh(SigmaX[1, 2]), log(SigmaX[2, 2]))

lhood = LLikelihoodDE(theta, Y, X, summed = TRUE)
head(LLikelihoodDE)

Disequilibrium documentation built on July 2, 2020, 3:27 a.m.