0
$\begingroup$

I've got sample data of the prevalence of a certain characteristic in two different groups, with prevalence in group 1 being 65% and prevalence in group 2 40%:

# Generate data where the presence of the characteristic is higher in group 1 compared to group 2.
group_1 <- data.frame(id=as.numeric(1:100), 
                   presence=factor(sample(c("Yes", "No"), 100, replace=T, prob=c(0.65, 0.35)), levels=c("No", "Yes")), 
                   group=factor("Group 1", levels=c("Group 1", "Group 2")))

group_2 <- data.frame(id=as.numeric(101:200), 
                    presence=factor(sample(c("Yes", "No"), 100, replace=T, prob=c(0.4, 0.6)), levels=c("No", "Yes")), 
                    group=factor("Group 2", levels=c("Group 1", "Group 2")))

data <- rbind(group_1, group_2)
rm(group_1, group_2)

I'm trying to find a way to do the following: 'if you have a sample with a prevalence of x% of group 1 persons, then thís would be the predicted prevalence if they were in group 2'. I thought I should do this with logistic regression, but I don't think I'm finding what I need:

# Logistic regression model: how is presence in group 1 related to the presence in group 2.
model <- data %>% glm(formula=presence ~ group, family=binomial, data=.) 
summary(model) # The regression formula is log(p/1-p) = -0.4895 + 0.9791 * Group 1

# The probability being present/prevalent in group 2 that follow from this model would then be:
exp(-0.4895 + 0.9791) / (exp(-0.4895*1 + 0.9791) + 1) # 0.62

I'm pretty sure the 0.62 is not something I'm looking for, but I'm also not sure what number I ám looking for.

$\endgroup$
2
  • 1
    $\begingroup$ What do you mean by "perform this permutation to obtain the predicted prevalence in group 2"? What do you want to permute? A permutation only reorders things, it does not change prevalences. $\endgroup$ Commented Nov 8, 2022 at 13:41
  • $\begingroup$ What I meant was, if you found a certain prevalence of this characteristic in persons from group 1 then what would the predicted prevalence be if they would have been from group 2. I've clarified this in the post. $\endgroup$
    – tcvdb1992
    Commented Nov 8, 2022 at 13:48

0

Your Answer

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

Browse other questions tagged or ask your own question.