1
$\begingroup$

The model that I created in R is:

fit <- lm(hired ~ educ + exper + sex, data=data)

what I am unsure of is how to fit to model to predict probability of interest where p = pr(hiring = 1).

Edit: This is the computer output for what I have computed so far. I am unsure if this is even a step in the right direction to find the answer to this question.

What I am trying to do is, Fit a logistic regression model to predict the probability of being hired using years of education, years of experience and sex of job applicants.

 > test<-glm(hired ~ educ + exper + sex, data=data, family=binomial(link="logit"))
 > summary(test)

 Call:
 glm(formula = hired ~ educ + exper + sex, family = binomial(link = "logit"), 
     data = data)

 Deviance Residuals: 
     Min       1Q   Median       3Q      Max  
 -1.4380  -0.4573  -0.1009   0.1294   2.1804  

 Coefficients:
             Estimate Std. Error z value Pr(>|z|)  
 (Intercept) -14.2483     6.0805  -2.343   0.0191 *
 educ          1.1549     0.6023   1.917   0.0552 .
 exper         0.9098     0.4293   2.119   0.0341 *
 sex           5.6037     2.6028   2.153   0.0313 *
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

 (Dispersion parameter for binomial family taken to be 1)

     Null deviance: 35.165  on 27  degrees of freedom
 Residual deviance: 14.735  on 24  degrees of freedom
 AIC: 22.735

 Number of Fisher Scoring iterations: 7
$\endgroup$
7
  • $\begingroup$ Because your model says nothing whatsoever about the probability of the response variable hired, it won't be able to do what you are asking of it (even presuming that "hiring" and "hired" are the same variable). Do you think you could tell us something about the data and what you're really trying to find out? $\endgroup$
    – whuber
    Nov 10, 2012 at 23:23
  • $\begingroup$ I looked into the glm function in R and this is what I was able to come up with: > test<-glm(hired ~ educ + exper + sex, data=data, family=binomial()) $\endgroup$
    – John
    Nov 10, 2012 at 23:34
  • 1
    $\begingroup$ Your comments change the question appreciably, Clay. Please edit the question to reflect this new information (because many readers might not pay attention to what's in the comments and will respond only to what's in the question itself, which is fair but can be very confusing for all concerned). Once again: please explain--in your own words, not computer output--what the data are and what you are trying to learn from them. $\endgroup$
    – whuber
    Nov 10, 2012 at 23:44
  • 1
    $\begingroup$ What kind of response is the hired variable? How does it relate to hiring probability? $\endgroup$
    – January
    Nov 11, 2012 at 8:44
  • 1
    $\begingroup$ 0 or 1 depending on if the individual had a job (1) or the did not (0) $\endgroup$
    – John
    Nov 18, 2012 at 23:52

1 Answer 1

0
$\begingroup$

I will assume that the "probability of interest" is the probability you get from the estimated logistic regression model. To use that as a probability of course is assuming that the model is a reasonably good approximation$^\dagger$, and that the person you use it for is from the same population that your data was sampled from. First, the logistic regression model is $$\DeclareMathOperator{\P}{\mathbb{P}} p=\P(\text{Hired} =1 | x)=\frac{e^{\beta_0+\beta_1 x + \dotsm}}{1+e^{\beta_0+\beta_1 x + \dotsm}} $$ so you just need to insert the value of $x$ for the person of interest, and the estimated coefficients, to get the estimated probability for that person. To do that in R you use the predict method for class "glm", that is, predict.glm. To get information on that you type in R

?predict.glm
example(predict.glm)

and study the output. For your data, you will need a new dataframe with the data for the person of interest (or multiple such persons). To make that I will assume that your variables education and experience are measured in years, and that sex is 0/1. Then do

mynewdata <- data.frame(educ=c(12,15,17),exper=c(20,0,5),sex=c(0,0,1)) 
predict(test, type="response", newdata=mynewdata)

and study the output ...

$^\dagger$ For a logistic regression model, assuming that variables like education and experience (with a large range of values) is acting linearly, is a very strong assumption. It could be, for instance, that very high values for experience, correlating with high age, lowers the probability, a non-monotonic effect that cannot be represented linearly. So I would look into representing those via splines, that is, replacing your glm call with something like

library(splines)
> test <- glm(hired ~ ns(educ,df=5) + ns(exper,df=5) + sex, data=data, family=binomial(link="logit"))
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.