predict.BiProbitPartialb {BiProbitPartial}R Documentation

predict method for class 'BiProbitPartialb'

Description

Note this produces a Bayesian posterior predictive distribution. This accounts for estimation uncertainty. If you desire a simple prediction that does not account for estimation uncertainty then the frequentist philosophy should be used. If nchains is greater than 1 then the chains are combined.

Usage

## S3 method for class 'BiProbitPartialb'
predict(object, newdata, k1, k2,
  mRule = c(0.5, 0.5), jRule = NULL, ...)

Arguments

object

a object of class BiProbitPartialb

newdata

a matrix of column dimension k1 + k2 where the first k1 columns correspond to the predictors of the first equations and the second k2 columns correspond to predictors of the second equation. If intercepts were used they need to be explicitly input.

k1

a numeric declaring the number of covariates (including intercept) in the first equation

k2

a numeric declaring the number of covariates (including intercept) in the second equation

mRule

a vector of length 1 or 2. This is the marginal decision rule for classifying the outcomes for stages 1 and 2. Stage 1 is classified as 1 if the probability of stage 1 being 1 is greater than or equal to mRule[1]. Likewise for stage 2. If length of mRule is 1 then that value is recycled. The values of mRule must be between 0 and 1. The default value is mRule = c(0.5,0.5).

jRule

an optional numerical value between 0 and 1. If specified then the observable outcome (both stages being 1) is 1 if the joint probability of both stages being 1 is greater than jRule. If jRule is unspecified or set to NULL then the observable outcome is the product of the marginal outcomes. The default value is jRule = NULL. Note, if jRule is specified then the observable outcome might not equal the product of stages 1 and 2.

...

unused

Value

method predict.bBiProbitPArtial returns a data.frame with columns

linPredict1

Predicted mean of the first stage latent outcome. This is tyically not interesting for a Bayesian analysis.

linPredict2

Predicted mean of the second stage latent outcome. This is tyically not interesting for a Bayesian analysis.

p1.

Probability the outcome of the first stage is 1

p.1

Probability the outcome of the second stage is 1

p00

Probability the outcome of both stages is 0

p01

Probability the outcome of the first stage is 0 and the second stage is 1

p10

Probability the outcome of stage 1 is 1 and stage 2 is 0

p11

Probability the outcome of both stages are 1

yHat1

Classification of the outcome for stage 1. This value is 1 if p1 >= mRule[1] and 0 else

yHat2

Classification of the outcome for stage 2. This value is 1 if p2 >= mRule[2] and 0 else

ZHat

Classification of the observable outcome. If jRule is specified then this value is 1 if p12 >= jRule and 0 else. If jRule is unspecified then this value is the element-wise product of yHat1 and yHat2.

Examples

##
# Perform a prediction with the same covariates the model is estimated with
##

data('Mroz87',package = 'sampleSelection')
Mroz87$Z = Mroz87$lfp*(Mroz87$wage >= 5)

# Run the frequentist version first to get starting values
f1 = BiProbitPartial(Z ~ educ + age + kids5 + kids618 + nwifeinc | educ + exper + city, 
    data = Mroz87, philosophy = "frequentist")

b1 = BiProbitPartial(Z ~ educ + age + kids5 + kids618 + nwifeinc | educ + exper + city, 
    data = Mroz87, philosophy = "bayesian", 
    control = list(beta = f1$par[1:(length(f1$par)-1)], rho = tail(f1$par,1)))

library(Formula)
eqn = Formula::Formula( ~ educ + age + kids5 + kids618 + nwifeinc | educ + exper + city)
matrix1 = model.matrix(eqn, lhs = 0, rhs=1, data= Mroz87)
matrix2 = model.matrix(eqn, lhs = 0, rhs=2, data= Mroz87)
newdat = cbind(matrix1,matrix2) 
preds1 = predict(b1,newdat,k1 = dim(matrix1)[2],k2 = dim(matrix2)[2])
head(preds1)
preds2 = predict(b1,newdat,k1 = dim(matrix1)[2],k2 = dim(matrix2)[2], jRule = .25)

# Compare predicted outcome with realized outcome
head(cbind(Mroz87$Z,preds1$ZHat,preds2$ZHat),20)


[Package BiProbitPartial version 1.0.3 Index]