DE: Market in Disequilibrium Model

Description Usage Arguments Details Value References Examples

View source: R/Disequilibrium.R

Description

DE estimates a market in disequilibrium model.

The market in disequilibrium model is defined as follows. Let i denote the ith observation which takes values from 1 to N, X[1] be a covariate matrix of dimension N x k[1], X[2] be a covariate matrix of dimension N x k[2], X[1i] be the ith row of X[1], X[2i] be the ith row of X[2], β[1] be a coefficient vector of length k[1] and β[2] be a coefficient vector of length k[2]. Define the latent response for stage one to be

y[1i]* = X[1i] β[1] + ε[1i]

and stage two to be

y[2i]* = X[2i] β[2] + ε[2i].

Define the observed outcome to be y[i]=min(y[1i]*,y[2i]*). The pair (ε[1i],ε[2i]) is distributed independently and identically multivariate normal with means E(ε[1i]) = E(ε[2i]) = 0, variances Var(ε[1i]) = σ[11], Var(ε[2i]) = σ[22], and covariance Cov(ε[1i],ε[2i]) = σ[12].

The model is estimated by (frequentist) maximum likelihood. The default maximum likelihood algorithm is based off the Limited-memory Broyden Fletcher Goldfarb Shanno (L-BFGS) algorithm. See optimr for details.

Usage

1
DE(formula, data, subset = NULL, par = NULL, control = list())

Arguments

formula

An object of class Formula: a symbolic description of the model to be fitted. The details of model specification are given under 'Details'.

data

A required data frame containing the variables provided in formula.

subset

An optional numeric vector specifying a subset of observations to be used in the fitting process.

par

A vector of initial values for the parameters for which optimal values are to be found. The order of the parameters is the coefficients of equation 1, the coefficients of equation 2, the variance for equation 1, the covariance of equations 1 and 2, and the variance of equation 2. The default is 0 for all parameters, except the variance parameters, which are set to 1.

control

A list of control parameters. See 'Details'.

Details

Models for DE are specified symbolically. A typical model has the form response ~ terms1 | terms2 where response is the name of the numeric response variable and terms1 and terms2 are each a series of variables that specifies the linear predictor(s) of the respective model. For example, if the first equation has two independent variables, X1 and X2, then terms1 = X1 + X2.

A formula has an implied intercept term for both equations. To remove the intercept from equation 1 use either response ~ terms1 - 1 | terms2 or response ~ 0 + terms1 | terms2. The intercept may be removed from equation 2 analgously.

The control argument is a list that can supply any of the following components:

method

A method to be used in the function optimr. The default is "L-BFGS-B". See optimr for further details.

lower, upper

Bounds on the variables for methods such as "L-BFGS-B" that can handle box (or bounds) constraints. The default is -Inf and Inf, respectively.

hessian

A logical control that if TRUE forces the computation of an approximation to the Hessian at the final set of parameters. See optimr for further details. The default is FALSE.

na.action

A function indicating what happens when data contains NAs. The default is na.omit. The only other possible value is na.fail.

transformR3toPD

A logical. If TRUE, the covariance matrix will be manually converted to a positive definite matrix for optimization. The default is TRUE.

Equation1Name

A string name for the first equation. The default is "_1".

Equation2Name

A string name for the second equation. The default is "_2".

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. The default is FALSE. A free correlation parameter can be numerically unstable, use with caution.

Value

An object of class 'DE' is returned as a list with the following components:

par

The set of parameter maximum likelihood estimates.

value

The negative of the log likelihood evaluated at par.

counts

A two-element integer vector giving the number of calls to fn and gr respectively. This excludes those calls needed to compute the Hessian, if requested, and any calls to fn to compute a finite-difference approximation to the gradient.

convergence

An integer code. '0' indicates successful completion.

message

A character string giving any additional information returned by the optimizer, or NULL.

Sigma

The estimated covariance matrix. This is a subset of par.

Xbeta1

The predicted outcome for each observation in equation 1 using the parameters estimated in par.

Xbeta2

The predicted outcome for each observation in equation 2 using the parameters estimated in par.

Y

A vector of the response (quantity) values.

X

A list of the design matricies for the two equations.

hessian

A numerical approximation to the Hessian matrix of the likelihood function at the estimated parameter values. The Hessian is returned even if it is not requested.

vcov

The variance covariance matrix of the estimates in par.

MaskRho

The value of MaskRho used.

The object of class 'DE' has the following attributes:

originalNamesX1

The original names of the covariates for equation 1 specified in formula.

originalNamesX2

The original names of the covariates for equation 2 specified in formula.

namesX1

The names of the covariates for equation 1 to be used in the summary.DE function. This is equivalent to paste0(originalNamesX1, Equation1Name).

namesX2

The names of the covariates for equation 2 to be used in the summary.DE function. This is equivalent to paste0(originalNamesX2, Equation2Name).

namesSigma

The names of the variance-covariance matrix parameters to be used in the summary.DE function.

Equation1Name

The user-specified name of equation 1.

Equation2Name

The user-specified name of equation 2.

betaN1

The number of coefficient and slope parameters to be estimated in equation 1.

betaN2

The number of coefficient and slope parameters to be estimated in equation 2.

References

Gourieroux, C. (2000). Econometrics of Qualitative Dependent Variables (Themes in Modern Econometrics) (P. Klassen, Trans.). Cambridge: Cambridge University Press. http://doi.org/10.1017/CBO9780511805608

Maddala, G. (1983). Limited-Dependent and Qualitative Variables in Econometrics (Econometric Society Monographs). Cambridge: Cambridge University Press. http://doi.org/10.1017/CBO9780511810176

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
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)
df = data.frame(Y = Y, X1 = Xgen[,1], X2 = Xgen[,2])

results = DE(formula = Y ~ X1 | X2, data = df)

str(results)

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