I ran my twopart model and I have tried following the but the margins and the AME commands to get the marginal effects on all the variables, but I am running into a really weird issue with the data frame for some reason.
> margin(tpmodel1)
Error in `[.data.frame`(newdata, , term) : undefined columns selected
But when looking at the guide for the twopm package, it says that all I need to do is just AME(tpmodel1)
or margin(tpmodel1)
to get all the marginal effects and it is still giving that error. so then i did
> margin(tpmodel1, newdata = NULL, term = NULL, se=TRUE)
Error in `[.data.frame`(newdata, , term) : undefined columns selected
And
> margin(tpmodel1, newdata = dfasthma, term = NULL, se=TRUE)
Error in margin(tpmodel1, newdata = dfasthma, term = NULL, se = TRUE) :
some of independent variables of the two-part model are not available in the newdata set
of which doesnt make sense cause The data set i created for the variables I am using is dfasthma.
the code from the package:
margin(object, newdata = NULL, term = NULL, value = NULL,
se = TRUE, se.method = c("delta","bootstrap"), CI = TRUE, CI.boots = FALSE,
level = 0.95,eps = 1e-7,na.action = na.pass, iter = 50)
The image attached is a guide to the margin command from the package