Description Usage Arguments Value Examples
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.
1 2 3 |
object |
a object of class |
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 |
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 |
... |
unused |
method predict.bBiProbitPArtial
returns a data.frame with columns
Predicted mean of the first stage latent outcome. This is tyically not interesting for a Bayesian analysis.
Predicted mean of the second stage latent outcome. This is tyically not interesting for a Bayesian analysis.
Probability the outcome of the first stage is 1
Probability the outcome of the second stage is 1
Probability the outcome of both stages is 0
Probability the outcome of the first stage is 0 and the second stage is 1
Probability the outcome of stage 1 is 1 and stage 2 is 0
Probability the outcome of both stages are 1
Classification of the outcome for stage 1. This value
is 1 if p1 >= mRule[1]
and 0 else
Classification of the outcome for stage 2. This value
is 1 if p2 >= mRule[2]
and 0 else
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.
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 | ##
# 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.