Hi Saurav! On Sun, Jul 12, 2009 at 6:06 PM, Pathak, Saurav<s.patha...@imperial.ac.uk> wrote: > I am new to R, I have to do a 2 step Heckman model, my selection equation is > below which I was successful in running but I am unable to proceed further, > > > > I have so far used the following command > > glm(formula = s ~ age + gender + gemedu + gemhinc + es_gdppc + > imf_pop + estbbo_m, family = binomial(link = "probit")) > > My question is > 1. How do i discard the non significant selection variables (one out of the > seven variables above is non-significant) and calculate the Inverse Mills > Ratio of the significant variables > > 2. I need the inverse mills ratio from the above to run the outcome equation > model using OLS with the Inverse mills ratio calculated on the basis of the > above probit as the control in my outcome equation, hence I need to get the > IMR (Is there another direct way?) > > 3. How can this be done in R using my concept or otherwise does there exist > another way of doing what I wish to achieve > > > > On trying > > regmod <- heckit(s ~ age + gender + gemedu + gemhinc + es_gdppc + > > imf_pop + estbbo_m, ln_oy5_1 ~ age+ gender+fearfail+gemedu, > adpopdata,method="2step") > > > > I get > > Error: could not find function "heckit" > > > > Error: could not find function "invMillsRatio" > > > > Am I missing out something, do i have to install something apart from R > also, so far I have used > > > > install.packages( "sampleSelection", repos="http://R-Forge.R-project.org" ) > > install.packages("Rcmdr", dependencies=TRUE) > > > > Even then I am unable to run heckit, please help
You have to install (only once) and *load* the package before you can use it: R> library( "sampleSelection" ) I suggest that you do NOT use function "heckit" but function "selection", because the latter allows you to estimate the model both by the 2-step and the 1-step (ML) method (depending on argument "method"). Our paper about the sampleSelection package published in the JSS could be also helpful for you: http://www.jstatsoft.org/v27/i07/ Arne -- Arne Henningsen http://www.arne-henningsen.name ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.