5
$\begingroup$

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?

$\endgroup$
6
  • 1
    $\begingroup$ 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. $\endgroup$ – seanv507 Apr 5 '15 at 21:56
  • 1
    $\begingroup$ This looks like it's asking for R code but it seems it's actually a stats question in disguise. $\endgroup$ – John Apr 5 '15 at 22:51
  • $\begingroup$ The answer here describes three approaches (all of which are implemented in R). $\endgroup$ – Glen_b Apr 6 '15 at 2:21
  • 1
    $\begingroup$ @John, what stats question are you seeing? $\endgroup$ – gung - Reinstate Monica Apr 6 '15 at 16:46
  • 2
    $\begingroup$ @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. $\endgroup$ – John Apr 6 '15 at 20:25
5
$\begingroup$

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.

$\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.