1

I am very new to r and statistics so excuse me if the answer to my question is very obvious. I have surveyed 64 people on their Facebook behaviour related to their political participation. One of my independent variables is how many Facebook friends the people have and i divided their answers into 3 categories: 0-500= 1, 500-1000= 2 and 1000+ = 3.The independent variable is whether or not they voted, coded 0= no and 1= yes. I have been trying to run this as a logistic regression but for some reason it is not working. This is my code:

#fit bivariate logistic regression model for amount of friends and voting
fit3 <-glm(vote~as.factor(friends), family=binomial(link="logit"), data=politicalparticipation)
summary(fit3)
exp(coef(fit3))
abs(1-exp(coef(fit3)))*100
sjt.glm(fit3)

However, i continuously get the error message that there is a warning:

Warning messages:
1: glm.fit: fitted probabilities numerically 0 or 1 occurred

If someone could help me out, that'd be great!

Sven Hohenstein
  • 6,285
  • 25
  • 30
  • 39
Sharaiz
  • 11
  • 1
  • 3
    Try calculating the fraction of yes and no answers for each of the three categories. If one or more categories has 100% yes or 100% no answers, that's the source of the trouble; it's referred to as "separation" in the literature. – jbowman Oct 21 '17 at 14:44
  • You are looking at perfect separation, for at least one level of facebook friends people will always vote or never vote – Repmat Oct 21 '17 at 14:45
  • 2
    You may find it better to use number of friends (possibly transformed) as a predictor rather than categorise it which inevitably leads to a mis-specified model even if you do not have separation – mdewey Oct 21 '17 at 14:49
  • You need 96 observations just to have any hope in estimating a SINGLE probability. – Frank Harrell Oct 21 '17 at 15:09
  • @jbowman how exactly can i do that in r ? – Sharaiz Oct 21 '17 at 15:17
  • Use the "table" function is probably the easiest; `table(df$vote, df$friends)` where `df` is the name of your data frame. – jbowman Oct 21 '17 at 17:39

0 Answers0