5

I have country level data for a binary (good/bad) outcome. For each country, I have the number of individuals in the sample who answerd "good" and number of individuals who answered "bad". I also have percent of the sample (instead of number). So basically, instead of 1/0 for outcome, for each obseration (country) I have % of people for each category of the binary outcome. Hope this is clear enough...

How can I create a logistic regression model in R for this?

Andy
  • 18,070
  • 20
  • 77
  • 100
Jenny
  • 61
  • 1
  • 2
  • 1
    Glm package : For binomial and quasibinomial families the response can also be specified as a factor (when the first level denotes failure and all others success) or as a two-column matrix with the columns giving the numbers of successes and failures. – seanv507 Apr 05 '15 at 21:56
  • 1
    This looks like it's asking for R code but it seems it's actually a stats question in disguise. – John Apr 05 '15 at 22:51
  • The answer [here](http://stats.stackexchange.com/questions/55916/generalized-lm-or-lm-in-ecological-dataset/55919#55919) describes three approaches (all of which are implemented in R). – Glen_b Apr 06 '15 at 02:21
  • 1
    @John, what stats question are you seeing? – gung - Reinstate Monica Apr 06 '15 at 16:46
  • 2
    @gung, the actual model to use is probably not simple logistic regression, perhaps multi-level logistic or weighted beta. I happily concede it's written as an R question. – John Apr 06 '15 at 20:25
  • That's a reasonable point. Jenny, in light of @John's comment, can you provide more information about your situation, your data & your goals? It may be that this is an on-topic Q & that we can point you towards the most appropriate methods for your case. – gung - Reinstate Monica Apr 06 '15 at 20:30

1 Answers1

5

Try reading the documentation. It states:

A typical predictor has the form response ~ terms where response is the (numeric) response vector and terms is a series of terms which specifies a linear predictor for response. For binomial and quasibinomial families the response can also be specified as a factor (when the first level denotes failure and all others success) or as a two-column matrix with the columns giving the numbers of successes and failures.

You can find an example in King's R logistic regression tutorial here under Logistic Regression: One Numerical Predictor.

gung - Reinstate Monica
  • 132,789
  • 81
  • 357
  • 650