I have data of a protein "F" in patients who used or not used a drug "X". I have 3 cofounders (age, BMI, sex) that I should adjust.
I successfully calculated the means of protein amount in the drug-group and no-drug group by using the below code:
> F <- data$f
> by(F, drugnodrug, summary)
> summ(F, by=drugnodrug)
Now, I want to calculate the absolute mean difference (95% confidence interval).
How can I do this in R (dplyr package)? Can I use Multiple Linear regression for this calculation and how?
This can be done with base R, because
t.test
also reports a confidence interval for the mean difference:The mean values are stored in the entry estimate, and you can compute the difference of the means with
or equivalently