Heller title: “PHAR7381 week6” output: html_document 092624 #lirbaries
library(dplyr)
library(ggplot2)
#theme
my_theme<-function(x){theme_bw()+
theme(text = element_text(size=20))+
theme(axis.line.y = element_line(size = 2.0))+
theme(axis.line.x = element_line(size = 2.0))+
theme(axis.ticks = element_line(size = 1.5,colour="black"))+
theme(axis.ticks.length= unit(0.45, "cm"))+
theme(axis.title.y =element_text(vjust=1.2))+
theme(axis.title.x =element_text(vjust=-0.2))+
theme(axis.text=element_text(colour="black"))+
theme(panel.background = element_rect(fill ="white"))}
#import data
pkdt<-read.csv("c:/Heller/PHAR7381/Week6/UNT234.csv",stringsAsFactors = F)
#Exploratory data analysis
##linear plot
ggplot(data=pkdt%>%filter(TIME>0),aes(TIME,DV))+
geom_point(size=4)+
my_theme()+
labs(x="Time (min)",y="Concentration (ug/L)")
## Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
## i Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
##log plot
ggplot(data=pkdt%>%filter(TIME>0),aes(TIME,DV))+
geom_point(size=4)+
my_theme()+
coord_trans(y="log2")+
labs(x="Time (min)",y="Concentration (ug/L)")
#one compartment model fit
onecomp<-read.table("c:/Heller/PHAR7381/Week6/ONECOMP.res")
names(onecomp)<-c("ID","TIME","DV","IPRED","WRES")
#Time versus observed and predicted
ggplot(data=onecomp%>%filter(TIME>0),aes(TIME,DV))+
geom_point(size=3) +
geom_line(data=onecomp%>%filter(TIME>0),aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
coord_trans(y="log2")+
labs(x="Time (min)",y="Concentration (ug/L")
#TIME versus WRES plot
ggplot(data=onecomp%>%filter(TIME>0),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")
#Predictions versus WRES plot
ggplot(data=onecomp%>%filter(TIME>0),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (CWRES)")
#Homework assignment #two compartment model fit
twocomp<-read.table("c:/Heller/PHAR7381/Week6/twocomp.res")
names(twocomp)<-c("ID","TIME","DV","IPRED","WRES")
#Time versus observed and predicted
ggplot(data=twocomp%>%filter(TIME>0),aes(TIME,DV))+
geom_point(size=3) +
geom_line(data=twocomp%>%filter(TIME>0),aes(TIME,IPRED),linetype="dashed")+
theme_bw()+
my_theme()+
coord_trans(y="log2")+
labs(x="Time (min)",y="Concentration (ug/L")
#TIME versus WRES plot
ggplot(data=twocomp%>%filter(TIME>0),aes(TIME,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x="Time (min)",y="Weighted residuals (WRES)")
#Predictions versus WRES plot
ggplot(data=twocomp%>%filter(TIME>0),aes(IPRED,WRES))+
geom_point(shape=19) +
geom_hline(yintercept = 0, colour="black") +
geom_hline(yintercept = c(-6,6),linetype = 2)+
theme_bw()+
my_theme()+
labs(x=" Predictions (ug/L)",y="Weighted residuals (CWRES)")