1
$\begingroup$

I posted my original question here, but was told that I should have posted at Cross Validated, below is the link to the original question:

https://stackoverflow.com/questions/20943584/predict-binary-outcome-with-r?noredirect=1#comment31453858_20943584

thanks!

$\endgroup$
  • $\begingroup$ I've flagged your original question to recommend its migration. Your question doesn't seem to be a programming problem, but a statistical problem, so it does belong here. So does the answer you've already received, which I voted up; I would've given the same answer myself. $\endgroup$ – Nick Stauner Jan 6 '14 at 5:57
  • $\begingroup$ Thanks Nick, sorry I didnt know this rule, but will keep it in mind next time posting statistics related questions. $\endgroup$ – PMa Jan 6 '14 at 6:02
  • $\begingroup$ No problem! Common mistake. :) Some of these Stack Exchange sites have picky moderators; others just let it be as long as it gets answered. The main cost is to you as the asker; you're more likely to receive answers from statisticians than programmers over here. (Or so I would assume...) $\endgroup$ – Nick Stauner Jan 6 '14 at 6:06
1
$\begingroup$

@Perri Ma .Factor analysis won't work because it is predominantly a dimension reduction technique rather than predictive modelling. There are multiple ways to go about it

1) Statistics : Use logistic regression the glm package in R serves that. It is the most common method used for the type of problems that you asked.

2) Machine Learning methods : Basically what you want to do is predictive classification, i.e predicting accepted or terminated. The most common methods here are SVM( Support Vector Machine), Neural Networks,Decision Trees.

I suggests you start with building logistic regression model first then read into the machine learning methods. Even though the concepts of ML methods are bit difficult at first but there lots of packages to implement and result interpretation is quite easy

$\endgroup$
  • $\begingroup$ I used the glm function: glm(formula = status ~ age + sex + race + grade + tenure, family = binomial, data = data), it returned Coefficients of the variables. While I need to interpret those coefficients, how can I use glm to include all variables in the table rather than using "~ variable 1 + variable 2 +..."? $\endgroup$ – PMa Jan 6 '14 at 6:07
  • $\begingroup$ @PerriMa I'm not completely sure but you can try this glm(status~.,data=data,family=binomial) Let me know if this works. I dont what other arguments did you pass but just change the formula part and keep rest as it is $\endgroup$ – NG_21 Jan 6 '14 at 6:11
  • $\begingroup$ I tried both statements: glm(data$status~, family = binomial) and glm(status~, data = data, family = binomial), both gave me this error message: Error: unexpected ',' in "glm(status~," :( $\endgroup$ – PMa Jan 6 '14 at 17:27
  • $\begingroup$ @Perri Ma , You have to put a "dot"after the sign. It should be like this status~. or this data$status~. I hope this helps $\endgroup$ – NG_21 Jan 6 '14 at 17:29
  • $\begingroup$ I added "." glm(data$status ~ . family = binomial) and get this error message: glm(data$status ~ . family = binomial). I also tried use ".," glm(data$status ~ ., family = binomial) and get this error message: Error in terms.formula(formula, data = data) : '.' in formula and no 'data' argument. Any clue :( $\endgroup$ – PMa Jan 6 '14 at 17:37
0
$\begingroup$

As mentioned, one way to solve this is through multivariable logistic regression. You can fit a model that predicts the probability of outcome (Status) from the other variables:

fit <- lrm(Status ~ Age + Tenure + Function + ...)

There are several packages that can help: glm was already mentioned, and I like rms. Check out the documentation in rms because it has a detailed example for exactly your kind of problem, that you can work through. There are several books on logistic regression, including one by rms's author.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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