Learn R Programming

Disequilibrium (version 1.1)

predict.DE: Predict method for class 'DE'

Description

Predict method for class 'DE'

Usage

# S3 method for DE
predict(object, newdata = NULL, ...)

Arguments

object

An object of class DE.

newdata

An optional data frame with column names matching the dependent variables specified in the formula of the DE function. If not provided, the data from the DE function will be used.

...

Unused

Value

A data frame is returned. The columns are:

Y_1

Linear prediction of the outcome variable in equation 1.

Y_2

Linear prediction of the outcome variable in equation 2.

Min(Y_1,Y_2)

The minimum of Y_1 and Y_2.

Prob(Y_2>Y_1)

The probability that the outcome variable in equation 2 is greater than the outcome variable in equation 1. This is the probability that Y_1 is the observed quantity. This probability does not account for estimation uncertainty. Also note that all predictions are unconditional on the observed quantity.

Examples

Run this code
# NOT RUN {
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)

head(predict(results))

# }

Run the code above in your browser using DataLab