Visualizing lmer and limits [Study Assessment]
Dear Shuanghe, Dear Detlew,
Happy New Year!
Here's my attempt to visualize the results of lmer.
I tried to add the acceptance criteria to the plot.
What do you think? Is that suitable? Did I understand the article correctly?
![[image]](img/uploaded/image209.jpg)
Black dots: Observed values
Blue dots: Predicted values
Blue area: 90% prediction area for all observations
Blue dashed line: fitted regression line
Blue dot-dashed lines: 90% limits built using 90% CIs for the slope and intercept
Red lines: 80-125% acceptance limits
Happy New Year!
Here's my attempt to visualize the results of lmer.
I tried to add the acceptance criteria to the plot.
What do you think? Is that suitable? Did I understand the article correctly?
library(lme4)
# the next one has A LOT of dependencies
# I added it to visualize confidence limits for each observation, by the way for the ribbon only max and min are used for each dose level
library(merTools)
library(ggplot2)
library(dplyr)
lowBind <- 0.8
Subj <- c(1, 2, 4, 5, 6, 4, 5, 6, 7, 8, 9, 7, 8, 9)
Dose <- c(25, 25, 50, 50, 50, 250, 250, 250, 75, 75, 75, 250, 250, 250)
AUC <- c(326.40, 437.82, 557.47, 764.85, 943.59, 2040.84, 2989.29,
4107.58, 1562.42, 982.02, 1359.68, 3848.86, 4333.10, 3685.55)
Cmax <- c(64.82, 67.35, 104.15, 143.12, 243.63, 451.44, 393.45,
796.57, 145.13, 166.77, 296.90, 313.00, 387.00, 843.00)
resp <- data.frame(Subj, Dose, Cmax, AUC)
resp$Subj <- factor(resp$Subj)
muddle <- lmer(log(Cmax) ~ log(Dose) + (1|Subj), data=resp)
coefs <- data.frame(summary(muddle)$coefficients)
pred <- cbind(resp, predictInterval(muddle, resp, level=0.9)) %>%
mutate(minDose = min(Dose),
lowL = exp(coefs['(Intercept)','Estimate'])*Dose^(1+log(lowBind)/log(Dose/minDose)),
upL = exp(coefs['(Intercept)','Estimate'])*Dose^(1+log(1/lowBind)/log(Dose/minDose))
) %>%
group_by(Dose) %>%
mutate(ymax = max(upr),
ymin = min(lwr))
ggplot(pred,aes(x = log(Dose), y = log(Cmax))) +
geom_point(shape = Subj, size = 2)+
geom_point(aes(y = fit), shape = Subj, size = 2, colour = 'blue')+
geom_ribbon(aes(ymin = ymin, ymax = ymax), fill = 'blue', alpha = .2) +
geom_abline(intercept = coefs['(Intercept)','Estimate'], slope = coefs['log(Dose)','Estimate'], size = 2, color = 'blue', linetype = 'dashed') +
geom_abline(intercept = coefs['(Intercept)','Estimate'] - qt(1-0.05, coefs['(Intercept)', 't.value']) * coefs['(Intercept)', 'Std..Error'],
slope = coefs['log(Dose)', 'Estimate'] - qt(1-0.05, coefs['log(Dose)', 't.value']) * coefs['log(Dose)', 'Std..Error'], size = 2, color = 'blue', linetype = 'dotdash' ) +
geom_abline(intercept = coefs['(Intercept)','Estimate'] + qt(1-0.05, coefs['(Intercept)', 't.value']) * coefs['(Intercept)', 'Std..Error'],
slope = coefs['log(Dose)', 'Estimate'] + qt(1-0.05, coefs['log(Dose)', 't.value']) * coefs['log(Dose)', 'Std..Error'], size = 2, color = 'blue', linetype = 'dotdash') +
geom_line(aes(y=log(lowL)), colour = 'red', size = 2) +
geom_line(aes(y=log(upL)), colour = 'red', size = 2) +
scale_y_continuous(labels = function(x) paste0(signif(x,4), "(", signif(exp(x), 4), ")")) +
scale_x_continuous(breaks=log(Dose), labels = function(x) paste0(signif(x,4), "(", signif(exp(x), 4), ")"))
![[image]](img/uploaded/image209.jpg)
Black dots: Observed values
Blue dots: Predicted values
Blue area: 90% prediction area for all observations
Blue dashed line: fitted regression line
Blue dot-dashed lines: 90% limits built using 90% CIs for the slope and intercept
Red lines: 80-125% acceptance limits
—
Kind regards,
Mittyri
Kind regards,
Mittyri
Complete thread:
- Dose Proportionality and Variance AngusMcLean 2016-05-11 16:55 [Study Assessment]
- More information, please Helmut 2016-05-12 14:34
- More information, please AngusMcLean 2016-05-13 16:40
- Setup in Phoenix/WinNonlin Helmut 2016-05-14 02:26
- Setup in Phoenix/WinNonlin AngusMcLean 2016-05-14 18:54
- Setup in Phoenix/WinNonlin Helmut 2016-05-15 14:47
- Setup in Phoenix/WinNonlin AngusMcLean 2016-05-15 15:17
- Phoenix 64 Warning Helmut 2016-05-15 15:56
- Phoenix 64 Warning AngusMcLean 2016-05-15 20:11
- OT: imperial vs. metric units Helmut 2016-05-16 16:26
- Phoenix 64 Warning AngusMcLean 2016-05-15 20:11
- Setup in Phoenix/WinNonlin ElMaestro 2016-05-15 20:54
- Setup in Phoenix/WinNonlin AngusMcLean 2016-05-15 22:30
- Phoenix 64 Warning Helmut 2016-05-15 15:56
- Setup in Phoenix/WinNonlin AngusMcLean 2016-05-15 15:17
- Setup in Phoenix/WinNonlin Helmut 2016-05-15 14:47
- Setup in Phoenix/WinNonlin AngusMcLean 2016-05-16 21:00
- NCSS vs. PHX/WNL vs. SAS Helmut 2016-05-17 01:50
- NCSS vs. PHX/WNL vs. SAS - Validation? mittyri 2016-05-18 08:23
- Diagnostics ElMaestro 2016-05-18 09:20
- Diagnostics: R and Phoenix Helmut 2016-05-18 15:14
- Diagnostics: R zizou 2016-05-22 19:07
- Diagnostics: R Helmut 2016-05-23 01:22
- SASian potpourri d_labes 2016-05-24 12:02
- Compilation Helmut 2016-05-24 14:27
- REML or not d_labes 2016-05-24 16:33
- complete or not Helmut 2016-05-24 16:57
- Compilation AngusMcLean 2016-05-26 16:46
- doubts about NCSS Helmut 2016-05-26 19:13
- Doubts about NCSS zizou 2016-05-26 23:38
- doubts about NCSS Helmut 2016-05-26 19:13
- Compilation AngusMcLean 2016-05-28 00:51
- Kenward-Roger? Helmut 2016-05-28 15:59
- 90% confidence interval for R_dnm Shuanghe 2019-01-04 17:45
- 90% confidence interval for R_dnm d_labes 2019-01-05 14:01
- Visualizing lmer and limitsmittyri 2019-01-06 17:00
- Visualizing lmer and limits Shuanghe 2019-01-07 11:05
- Visualizing lmer and limits d_labes 2019-01-07 15:08
- Visualizing lmer and limits mittyri 2019-01-13 23:53
- 90% confidence interval for R_dnm Shuanghe 2019-01-07 10:53
- 90% confidence interval for R_dnm d_labes 2019-01-07 15:17
- 90% confidence interval for R_dnm Shuanghe 2019-01-07 17:11
- 90% confidence interval for R_dnm d_labes 2019-01-07 18:24
- offtop: greek letters and tables mittyri 2019-01-08 00:19
- OT: greek letters and symbols Helmut 2019-02-02 16:04
- 90% confidence interval for R_dnm Shuanghe 2019-01-07 17:11
- 90% confidence interval for R_dnm d_labes 2019-01-07 15:17
- Visualizing lmer and limitsmittyri 2019-01-06 17:00
- 90% confidence interval for R_dnm d_labes 2019-01-05 14:01
- REML or not d_labes 2016-05-24 16:33
- Compilation Helmut 2016-05-24 14:27
- SASian potpourri d_labes 2016-05-24 12:02
- Diagnostics: R Helmut 2016-05-23 01:22
- Diagnostics: R zizou 2016-05-22 19:07
- Diagnostics: R and Phoenix Helmut 2016-05-18 15:14
- Smith’s paper Helmut 2016-05-18 14:44
- Smith’s paper d_labes 2019-01-05 15:00
- Diagnostics ElMaestro 2016-05-18 09:20
- NCSS vs. PHX/WNL vs. SAS - Validation? mittyri 2016-05-18 08:23
- NCSS vs. PHX/WNL vs. SAS Helmut 2016-05-17 01:50
- Setup in Phoenix/WinNonlin AngusMcLean 2016-05-14 18:54
- Setup in Phoenix/WinNonlin Helmut 2016-05-14 02:26
- More information, please AngusMcLean 2016-05-13 16:40
- More information, please Helmut 2016-05-12 14:34