How to extract coefficients corresponding to data from each time in a mixed effect model in R?

jordanlau

New member
Joined
Aug 16, 2022
Messages
3
I am not good at statistics and might have a naive question. Any help is appreciated.

Here is the simplified question: Patients received two different vaccines twice and we collected their blood after each vaccination to measure antibody levels in the blood. There are other variables but here I omitted them and just want to know how different vaccines affect the antibody levels. It seems that the longitudinal data mixed effect model is a proper analysis.

Here is the simulated data. 6 patients received Vaccines A or B for the first vaccine and all received Vaccine B as the second vaccine; after each vaccination they visited a hospital to measure blood antibody levels (2 data points at 2 Visits). It is already confirmed with studies that Vaccine A induced higher antibody levels than Vaccine B. So if using only Visit 1 data to do a linear regression, we can see Vaccine A induced significantly higher antibody levels compared to that with Vaccine B. As all patients received A as the second vaccine, if using only Visit 2 data, there is no significance. My question is, if we include all the data in a linear mixed effect model, how to extract coefficients corresponding to each visit data? I only know how to use the summary() to get the coefficients for both visits data, however, the significance for the Vaccine type doesn't seem to be right.

data_raw = data.frame(ID=c(1,2,3,4,5,6,1,2,3,4,5,6),
Antibody=c(50,60,70,30,40,35,101,102,102,102,101,103),
Visit=c(1,1,1,1,1,1,2,2,2,2,2,2),
Vaccine=c("A","A","A","B","B","B","A","A","A","A","A","A"),
VaccineChange=c(0,0,0,0,0,0,0,0,0,1,1,1))

Linear regression of Visit 1 data confirmed that Vaccine A induced higher antibody levels.

lm_Visit1=subset(data_raw, Visit ==1)
summary(lm(Antibody~Vaccine,lm_Visit1))


Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 60.000 4.564 13.145 0.000193 ***
VaccineB -25.000 6.455 -3.873 0.017948 *

Linear regression of Visit 2 data indicated no significance as everyone got Vaccine A.

lm_Visit2=subset(data_raw, Visit ==2)
summary(lm(Antibody~VaccineChange,lm_Visit2))


Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 101.6667 0.4714 215.7 2.77e-09 ***
VaccineChange 0.3333 0.6667 0.5 0.643

If using mixed model with both visits data, the vaccine variable is significant. Is it possible to extract coefficients corresponding to each visit? Just to show similar results to linear regression that Visit 1 showed significance but not Visit 2.

summary(lmer(Antibody~Vaccine+(1|ID),data_raw))


Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 87.889 6.457 10.000 13.610 8.87e-08 ***
VaccineB -52.889 12.915 10.000 -4.095 0.00216 **

Originally, I performed two linear regression with each visit data. But I was told that for visit 2 data I should use linear mixed model as I got both visit data to account for repeated measurement within patient differences. Other covariates are not included in this simulated model just for simplicity.

Many thanks,

Jordan
 
I am not good at statistics and might have a naive question. Any help is appreciated.

Here is the simplified question: Patients received two different vaccines twice and we collected their blood after each vaccination to measure antibody levels in the blood. There are other variables but here I omitted them and just want to know how different vaccines affect the antibody levels. It seems that the longitudinal data mixed effect model is a proper analysis.

Here is the simulated data. 6 patients received Vaccines A or B for the first vaccine and all received Vaccine B as the second vaccine; after each vaccination they visited a hospital to measure blood antibody levels (2 data points at 2 Visits). It is already confirmed with studies that Vaccine A induced higher antibody levels than Vaccine B. So if using only Visit 1 data to do a linear regression, we can see Vaccine A induced significantly higher antibody levels compared to that with Vaccine B. As all patients received A as the second vaccine, if using only Visit 2 data, there is no significance. My question is, if we include all the data in a linear mixed effect model, how to extract coefficients corresponding to each visit data? I only know how to use the summary() to get the coefficients for both visits data, however, the significance for the Vaccine type doesn't seem to be right.



Linear regression of Visit 1 data confirmed that Vaccine A induced higher antibody levels.



Linear regression of Visit 2 data indicated no significance as everyone got Vaccine A.



If using mixed model with both visits data, the vaccine variable is significant. Is it possible to extract coefficients corresponding to each visit? Just to show similar results to linear regression that Visit 1 showed significance but not Visit 2.



Originally, I performed two linear regression with each visit data. But I was told that for visit 2 data I should use linear mixed model as I got both visit data to account for repeated measurement within patient differences. Other covariates are not included in this simulated model just for simplicity.

Many thanks,

Jordan
To clarify your goal is to test strictly whether A or B is more effective in producing antibodies.
My question to you is do you know that the vaccines have an additive effect? If so, is it linear?
By using the combined result of AB and BB you're not testing for A or B strictly speaking, but rather the effectiveness of A and B with an additive effect of B.
 
To clarify your goal is to test strictly whether A or B is more effective in producing antibodies.
My question to you is do you know that the vaccines have an additive effect? If so, is it linear?
By using the combined result of AB and BB you're not testing for A or B strictly speaking, but rather the effectiveness of A and B with an additive effect of B.
Thank you very much for your reply!

For your questions:
1. My goal is to test whether changing vaccines at second visit affect antibody levels compared to patients using one vaccine all the time
2. After vaccination, antibody concentration in our body decays over time, therefore, we repeat vaccinations after a few months to raise the antibody levels to protect us. Both Vaccines A and B are able to increase antibody levels. So I would say they have additive effect. However, I don't know if it is linear. After vaccination, our immune system produces huge antibodies in a few days, then antibodies diminish over time.

You are right, I try to test the effect of changing vaccines. We already know that Vaccine A induces higher antibody levels than Vaccine B (use only Visit 1 data). For the second visit, all people received Vaccine A. I used data from Visit 2 to perform a linear regression, results showed that there is no difference in antibody levels since everyone received Vaccine A, regardless of what vaccine (A or B) they received at Visit 1. However, a statistician told me that, since I already had both visits data, using only Visit 2 data is not correct. I should use both visits data to do mixed effect models to account for within patient variance.

So I performed linear mixed effect model with all the data. However, I don't know how to show the same results as what I got from linear regression with Visit 2 data -- which showed no difference in antibody levels since everyone got Vaccine A. Combining all data, the vaccine type variable will be significant in the model as data from Visit 1 is significantly different since some people got Vaccine B with lower antibody levels.

Thanks again for your help. Please let me know if you need more clarification.
 
1. My goal is to test whether changing vaccines at second visit affect antibody levels compared to patients using one vaccine all the time
If this is your objective then I'd agree with the suggestion you received from the statistician.
I'll test your simulated data once I have more time.
 
Top