[R] Plot prediction for Heckman 2-step (sampleSelection) models after predict.selection

Syed Rashid Munir @mun|r1 @end|ng |rom b|ngh@mton@edu
Mon May 13 21:10:09 CEST 2019


Hi everyone,

I'm fairly new to R and I've run into a problem that I can't find a 
solution for.

I'm trying to plot the predicted values of a dependent variable based on 
specific values of one independent variable after running a Heckit 
(Heckman 2-step) model from the sampleSelection package.

The general model looks like this:

|Mod1 <- Heckit(selection = binaryindicator ~ x1 + z, outcome = y ~ x1, 
df, method) |

where, the data structure is as follows:

|z x1 y binaryindicator 0.5 4 300 1 0.1 8 400 1 0.2 10 500 1 0.2 18 NA 0 
0.4 20 50 1 0.3 30 1000 1 |

After pouring over documentation for sampleSelection, I can only extract 
predictions from the predict.selection function and get the 
corresponding residuals. However, this method doesn't let me specify 
predictions for one variable (say x1) and resulting predictions are from 
the entire model.

Therefore, I am looking for a way (canned function or manual) to plot 
the prediction on y from x1 with confidence intervals. All attempts to 
do so (using plot, cplot, ggpredict, effects_plot) have failed. All of 
the above functions work with linear models, but not a selection model.

I'd ideally want to also specify which equation (outcome or selection) I 
want the prediction from, but that has also eluded me, as I can't get 
any predictions to begin with. Is there a way to achieve this? In Stata, 
this can be done with the margins command, but the equivalent margins 
package in R doesn't work for sampleSelection models (for me so far). 
Any and all help would be much appreciated!


Regards,
Rashid
Poli Sci Student, SUNY Binghamton

	[[alternative HTML version deleted]]



More information about the R-help mailing list