1
$\begingroup$

I have data that looks like this:

personID <- 1:20
country <- c(rep(1,10), rep(2, 10))
success <- c(rbinom(10, 1, .2), rbinom(10, 1, .8))
income <- c(100, 100, 300, 200, 200, 200, 150, 300, 100, 100, 400, 300, 300, 250, 300, 350, 500, 200, 200, 300)

x <- data.frame(personID = personID, country = country, success = success, income = income)

> x
   personID country success income
1         1       1       0    100
2         2       1       0    100
3         3       1       0    300
4         4       1       1    200
5         5       1       0    200
6         6       1       1    200
7         7       1       1    150
8         8       1       0    300
9         9       1       0    100
10       10       1       0    100
11       11       2       1    400
12       12       2       1    300
13       13       2       1    300
14       14       2       1    250
15       15       2       1    300
16       16       2       1    350
17       17       2       1    500
18       18       2       0    200
19       19       2       1    200
20       20       2       1    300

I want to test the rate of success (success = 1) of the two countries (with a hypothesis test where the null hypothesis is that there is no difference in the rate of success between the two countries), but while controlling for the effect of income. Without wanting to control for income, this would be easy, as I could just set up a two-sample Z-test comparing the two proportions of success for each country. But how can I test the proportions while controlling for the new variable, income?

$\endgroup$

1 Answer 1

2
$\begingroup$

You can analyze data like this using logistic regression.

The Success variable is the response variable, then you have an indicator (0/1) variable representing country as one of the predictors, then income (and any other variables that you want to adjust for) as an additional predictor. The test on the coefficient for country will be the test comparing proportions between the 2 groups adjusting for the other terms in the model.

Do be aware of the Hauk-Donner effect where very strong effects can be seen as not significant due to an overestimate of the standard error.

$\endgroup$
1
  • $\begingroup$ Sometimes the simple things aren't apparent. Thank you for your answer! $\endgroup$
    – bob
    Commented Aug 6, 2020 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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