I want to use SampleSelection package to calculate whether to get an interview and whether to get a job. Both functions can be calculated separately, there will be problems like this when using SampleSelection package
heckman <- selection(selection = q21_0 ~q2_0+q3_0+q4_0+q8+q19_1_1+q20_1_1+I(q19_1_1^2)+I(q20_1_1^2)+q22_4, outcome = q23_0 ~q2_0+q3_0+q4_0+q8q21_1_1+I(q21_1_1^2)+q22_4,
data = subset(X0312_need_data_only,q9_0==1), method = "2step")
Error: Can't combine `..1` <character> and `..2` <double>.Run `rlang::last_error()` to see where the error occurred.
and when I want to use this package manually and in the Calculate inverse Mills ratio by hand part, I get wrong.
seleqn1 <- glm(q21_0 ~q2_0+q3_0+q4_0+q8+q19_1_1+q20_1_1+I(q19_1_1^2)+I(q20_1_1^2)+q22_4, family=binomial(link="probit"), data=subset(X0312_need_data_only,q9_0==1))
# Calculate inverse Mills ratio by hand ##X0312_need_data_only$IMR <- dnorm(seleqn1$linear.predictors)/pnorm(seleqn1$linear.predictors)
Error: Assigned data dnorm(seleqn1$linear.predictors)/pnorm(seleqn1$linear.predictors) must be compatible with existing data. x Existing data has 9844 rows. x Assigned data has 6990 rows. i Only vectors of size 1 are recycled. Run rlang::last_error() to see where the error occurred.