### Install xpose R Package Source: https://github.com/uupharmacometrics/xpose/blob/master/README.md This snippet shows how to install the xpose R package. It includes installation from CRAN for the latest release and from GitHub for the development version using the devtools package. Ensure devtools is installed if you choose the GitHub installation method. ```r install.packages('xpose') ``` ```r devtools::install_github('UUPharmacometrics/xpose') ``` -------------------------------- ### Generate QQ Plots with xpose Source: https://context7.com/uupharmacometrics/xpose/llms.txt Functions for creating Quantile-Quantile (QQ) plots to assess the normality assumptions of random effects, parameters, and residuals. Allows for guide line customization and stratification. ```r # ETA QQ plot eta_qq(xpdb) # Multiple ETAs with reference line eta_qq(xpdb, guide = TRUE, point_color = 'blue', guide_color = 'red', facets = 'MED1') # Residual QQ plots res_qq(xpdb, res = c('IWRES', 'CWRES')) # Parameter QQ plot prm_qq(xpdb, drop_fixed = TRUE) # Covariate QQ plot cov_qq(xpdb, facets = 'SEX') ``` -------------------------------- ### Data Import Functions for NONMEM Tables Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Handles importing NONMEM tables from .csv and .zip formats. Supports multiple $PROB blocks and the FIRSTONLY option. Includes manual import and functions for setting variable types, labels, and units. ```R read_nm_tables(file, "path/to/your/table.csv") manual_nm_import(data, "path/to/your/table.csv") set_vars_type(xpdb, "ID", "numeric") set_vars_label(xpdb, "AGE", "Patient Age") set_vars_units(xpdb, "WEIGHT", "kg") ``` -------------------------------- ### Accessing and Summarizing xpdb Data Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Provides methods to print and summarize the xpdb object, a central data structure in xpose. Includes functions to list available variables and access specific data components like code, data, files, and summaries. ```R print(xpdb) summary(xpdb) list_vars(xpdb) get_code(xpdb) get_data(xpdb) get_file(xpdb) get_summary(xpdb) ``` -------------------------------- ### Load xpose Library in R Source: https://github.com/uupharmacometrics/xpose/blob/master/README.md This R code demonstrates how to load the xpose package into your current R session. This is a prerequisite for using any of the functions provided by the xpose package for model diagnostics. ```r library(xpose) ``` -------------------------------- ### Parameter Table Generation and Transformation Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Functions to generate parameter tables and control parameter transformations. Allows disabling transformations and ensures RSE is always reported, with corrected calculations for off-diagonal elements in OMEGA and SIGMA blocks. ```R get_prm(xpdb, transform = FALSE) prm_table(xpdb, transform = FALSE) ``` -------------------------------- ### General Plotting Functions Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md A suite of general plotting functions for distribution, QQ plots, and scatter plots, integrated with data fetching from xpdb using data_opt_set(). ```R xplot_distrib(xpdb, ...) xplot_qq(xpdb, ...) xplot_scatter(xpdb, ...) data_opt_set(xpdb, ...) ``` -------------------------------- ### Summarize xpose Data Object Source: https://github.com/uupharmacometrics/xpose/blob/master/README.md This R code displays a summary of the imported xpose data object. The `summary` function, when applied to an xpose database object, provides detailed information about the model run, including software version, file paths, estimation results, and shrinkage values for different problems within the run. ```r summary(xpdb, problem = 1) ``` -------------------------------- ### Access xpose Data Tables and Files Source: https://context7.com/uupharmacometrics/xpose/llms.txt Retrieve specific data tables, output files, or parameter estimates from an xpdb object. Functions like get_data, get_file, and get_prm allow for targeted data extraction for custom analyses. ```r # Get specific table sdtab <- get_data(xpdb, table = 'sdtab001') # Get all tables for a problem all_tables <- get_data(xpdb, .problem = 1) # Get parameter file phi_data <- get_file(xpdb, file = 'run001.phi') # Get extension file ext_data <- get_file(xpdb, ext = 'ext', .problem = 1) # Get multiple files files <- get_file(xpdb, ext = c('ext', 'phi', 'cov')) # Get parameters with transformations params <- get_prm(xpdb, .problem = 1, transform = TRUE, # Convert OMEGA/SIGMA to SD/corr digits = 4) # Get model code code <- get_code(xpdb, .problem = 1) # Get summary statistics summary_stats <- get_summary(xpdb, .problem = 0) run_time <- summary_stats$runtime ofv_value <- summary_stats$ofv # List available data list_data(xpdb) # Available tables list_files(xpdb) # Available output files list_vars(xpdb) # Variable classifications list_special(xpdb) # Special data (VPC) ``` -------------------------------- ### Listing Data Structure Information Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Utility functions to retrieve information about the data structure within an xpdb object. Helps in understanding the organization of data before analysis. ```R list_data(xpdb) list_files(xpdb) list_special(xpdb) ``` -------------------------------- ### Xpose Plot Theme Customization Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Functions to customize the appearance of xpose plots. Includes default themes and options for global faceting settings. ```R xp_theme(...) theme_bw2() theme_readable() theme_xp_default() theme_xp_xpose4() ``` -------------------------------- ### Accessing Parameter Information with get_prm() Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Retrieves parameter information, with improved parsing for OMEGA and SIGMA BLOCKS. Supports disabling parameter transformation and provides accurate RSE reporting. ```R get_prm(xpdb, include_omega_sigma = TRUE, transform = TRUE) ``` -------------------------------- ### Diagnose Minimization with Parameter and Gradient Plots Source: https://context7.com/uupharmacometrics/xpose/llms.txt Visualize parameter values and gradients across estimation iterations using prm_vs_iteration() and grd_vs_iteration(). These functions help diagnose minimization issues by tracking convergence. ```r # Parameter values vs iteration prm_vs_iteration(xpdb, labeller = 'label_value') # Gradients vs iteration grd_vs_iteration(xpdb, labeller = 'label_value') # Customized minimization diagnostics prm_vs_iteration(xpdb, labeller = 'label_value', line_color = 'steelblue', point_color = 'red', title = 'Parameter Estimates by Iteration | @run', subtitle = 'Final OFV: @ofv') # Combined view gridExtra::grid.arrange( prm_vs_iteration(xpdb), grd_vs_iteration(xpdb), ncol = 1 ) ``` -------------------------------- ### VPC Wrapper Function Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Provides a wrapper around the ronkeizer/vpc package for generating Visual Predictive Checks (VPCs). ```R vpc_data(xpdb, ...) ``` -------------------------------- ### Adding Simulation Counter with irep() Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Adds a simulation counter to any dataset, which can be useful for analyses involving multiple simulation runs. ```R irep(xpdb, "sim_counter") ``` -------------------------------- ### Summarize Model with summary() and prm_table() in R Source: https://context7.com/uupharmacometrics/xpose/llms.txt Functions summary() and prm_table() extract and display model metadata, parameter estimates, and run statistics from an xpdb object. summary() provides overall model information, while prm_table() presents detailed parameter estimates, standard errors, and shrinkage values. get_prm() and get_summary() allow programmatic extraction. ```r # View model summary summary(xpdb, problem = 1) # Display parameter table prm_table(xpdb, problem = 1, digits = 4) # Extract parameters programmatically params <- get_prm(xpdb, .problem = 1, transform = TRUE) ofv <- get_summary(xpdb, .problem = 0)$ofv ``` -------------------------------- ### Generate Distribution Plots using xpose Source: https://github.com/uupharmacometrics/xpose/blob/master/README.md Generates distribution plots for model parameters using the eta_distrib function from the xpose package. This function takes an xpdb object and an optional labeller as input. The output is a plot visualizing parameter distributions. ```r eta_distrib(xpdb, labeller = 'label_value') ``` -------------------------------- ### Accessing Summary Data with get_summary() Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Retrieves summary data from the xpdb object. This function is part of the convenience functions for accessing xpdb data. ```R get_summary(xpdb) ``` -------------------------------- ### Basic Goodness-of-Fit Plot: DV vs IPRED Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md A proof-of-concept function for plotting DV (dependent variable) versus IPRED (individual prediction), a common goodness-of-fit diagnostic. ```R dv_vs_ipred(xpdb_ex_pk) ``` -------------------------------- ### Data Import Functions for NONMEM Files Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Imports data from NONMEM files, including support for multiple $PROB blocks and sub-problems. This function is crucial for integrating NONMEM output into the xpose workflow. ```R read_nm_files(dir = "path/to/nonmem/output", "file.csv") ``` -------------------------------- ### Import Run Output with xpose Source: https://github.com/uupharmacometrics/xpose/blob/master/README.md This R code snippet imports the output of a run into an xpose database object. The `xpose_data` function is used, typically taking a run number as an argument to identify the specific model run to be imported and analyzed. ```r xpdb <- xpose_data(runno = '001') ``` -------------------------------- ### Import NONMEM Data with xpose_data() in R Source: https://context7.com/uupharmacometrics/xpose/llms.txt The xpose_data() function imports NONMEM model output into R, creating an xpose database (xpdb) object. It supports importing by run number or file name and allows customization of graphical themes and inclusion of extra files. The output provides a summary of the imported data and model information. ```r library(xpose) # Import by run number xpdb <- xpose_data(runno = '001', dir = 'models') # Import by file name xpdb <- xpose_data(file = 'run001.lst', dir = 'analysis/model/pk/') # Import with custom themes xpdb <- xpose_data( runno = '001', dir = 'models', gg_theme = theme_bw(), xp_theme = theme_xp_xpose4(), extra_files = c('.ext', '.phi', '.cov', '.cor') ) # View imported data print(xpdb) ``` -------------------------------- ### Theme Customization for xpose Plots Source: https://context7.com/uupharmacometrics/xpose/llms.txt Function to update global plot appearance using ggplot2 themes and xpose-specific layer aesthetics. Allows for consistent styling across multiple plots. ```r # Example usage of update_themes would go here, # but no specific code was provided in the input text. # update_themes(...) ``` -------------------------------- ### Generate Distribution Plots with xpose Source: https://context7.com/uupharmacometrics/xpose/llms.txt Functions to create various distribution plots for estimated parameters, random effects, residuals, and covariates. Supports stratification and customization of plot aesthetics. ```r eta_distrib(xpdb, type = 'd', facets = 'MED1', density_fill = 'steelblue', title = 'Eta Distribution | @run', subtitle = 'Based on @nind individuals, Eta shrink: @etashk') prm_distrib(xpdb, type = 'hr', drop_fixed = TRUE) res_distrib(xpdb, res = c('IWRES', 'CWRES'), type = 'hdr', # histogram + density + rug histogram_fill = 'grey80') cov_distrib(xpdb, type = 'd', facets = 'SEX') ``` -------------------------------- ### Specific Plotting Functions Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Implements various specific plots for pharmacokinetic and pharmacodynamic analysis, including DV vs. IDV, predicted values, individual plots, VPC, and parameter distributions. ```R dv_vs_idv(xpdb, ...) ipred_vs_idv(xpdb, ...) pred_vs_idv(xpdb, ...) dv_preds_vs_idv(xpdb, ...) ind_plots(xpdb, ...) vpc(xpdb, ...) prm_distrib(xpdb, ...) eta_distrib(xpdb, ...) res_distrib(xpdb, ...) cov_distrib(xpdb, ...) prm_qq(xpdb, ...) eta_qq(xpdb, ...) res_qq(xpdb, ...) cov_qq(xpdb, ...) prm_vs_iteration(xpdb, ...) grd_vs_iteration(xpdb, ...) ``` -------------------------------- ### Create Visual Predictive Checks (VPCs) with xpose Source: https://context7.com/uupharmacometrics/xpose/llms.txt Functions to generate Visual Predictive Checks (VPCs) by comparing observed data with model simulations. Supports various VPC types, binning, stratification, and censored data. ```r # Basic continuous VPC xpdb %>% vpc_data(opt = vpc_opt(n_bins = 7)) %>% vpc() # Stratified VPC with LLOQ xpdb %>% vpc_data( stratify = 'SEX', opt = vpc_opt( n_bins = 7, lloq = 0.1, pi = c(0.05, 0.95), ci = c(0.05, 0.95) ) ) %>% vpc( smooth = TRUE, area_fill = c('steelblue3', 'grey60', 'steelblue3'), line_linetype = c('93', 'solid', '93'), facets = 'SEX' ) # Censored VPC for data below LLOQ xpdb %>% vpc_data(vpc_type = 'censored', opt = vpc_opt(lloq = 1, n_bins = 7)) %>% vpc() # Categorical VPC xpdb %>% vpc_data(vpc_type = 'categorical') %>% vpc() # Time-to-event VPC xpdb %>% vpc_data(vpc_type = 'time-to-event') %>% vpc() # Using PsN VPC output xpdb %>% vpc_data(psn_folder = 'vpc_dir', psn_bins = TRUE) %>% vpc() ``` -------------------------------- ### Export xpose Plots to Files Source: https://context7.com/uupharmacometrics/xpose/llms.txt Save xpose plots to various file formats (PDF, PNG, JPEG, TIFF) using xpose_save(). Supports template keywords for dynamic filenames and automatic directory generation, ideal for publication-ready figures. ```r # Save last plot dv_vs_ipred(xpdb) xpose_save(file = 'dv_vs_ipred.pdf', width = 7, height = 6) # Save with template keywords xpdb %>% dv_vs_ipred() %>% xpose_save( file = '@run_@plotfun_[@ofv].pdf', dir = '@dir', width = 8, height = 6, dpi = 300 ) # Creates: models/run001_dv_vs_ipred_[-1403.905].pdf # Save multiple formats plot <- eta_distrib(xpdb) xpose_save(plot, file = 'eta_dist.pdf', device = 'pdf') xpose_save(plot, file = 'eta_dist.png', device = 'png', dpi = 300) xpose_save(plot, file = 'eta_dist.jpeg', device = 'jpeg', dpi = 200) # High-resolution for publication vpc_plot <- xpdb %>% vpc_data() %>% vpc() xpose_save(vpc_plot, file = 'vpc_final.tiff', width = 10, height = 7, units = 'in', dpi = 600) ``` -------------------------------- ### Generate Minimization Diagnostics using xpose Source: https://github.com/uupharmacometrics/xpose/blob/master/README.md Generates plots for minimization diagnostics using the prm_vs_iteration function from the xpose package. This function visualizes parameter values against iteration numbers, taking an xpdb object and an optional labeller. It helps in assessing model convergence. ```r prm_vs_iteration(xpdb, labeller = 'label_value') ``` -------------------------------- ### Saving Plots with xpose_save() Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Functionality to save plots generated by xpose. Supports multiple pages and various output formats. ```R xpose_save(plot_object, filename = "my_plot.png", pages = 1:5) ``` -------------------------------- ### Accessing Special Data in xpdb Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Provides a function to access special data elements within the xpdb object. This is useful for retrieving specific metadata or configuration information. ```R get_special(xpdb, "some_special_key") ``` -------------------------------- ### Generate Individual Plots with xpose Source: https://github.com/uupharmacometrics/xpose/blob/master/README.md This R code generates individual plots for model diagnostics. The `ind_plots` function takes an xpose database object and a page number as arguments to display plots related to individual patient data and model predictions. This helps in assessing the model's performance for each individual. ```r ind_plots(xpdb, page = 1) ``` -------------------------------- ### Perform Visual Predictive Check (VPC) in R Source: https://github.com/uupharmacometrics/xpose/blob/master/README.md This R code performs a Visual Predictive Check (VPC) using the xpose package. It first prepares the data for VPC using `vpc_data`, allowing stratification by variables like 'SEX' and customization of options like the number of bins and lower limit of quantification (LLOQ). Subsequently, the `vpc` function generates the VPC plot, comparing observed data with simulated data distributions. ```r xpdb %> vpc_data(stratify = 'SEX', opt = vpc_opt(n_bins = 7, lloq = 0.1)) %> vpc() ``` -------------------------------- ### Distribution Plots in R using xpose Source: https://context7.com/uupharmacometrics/xpose/llms.txt Distribution plots visualize the spread of parameters, random effects (ETAs), residuals, or covariates using histograms, density plots, and rug plots. Functions like eta_distrib() allow for different plot types (e.g., 'hr' for histogram and rug) to explore parameter variability. ```r # ETA distributions with histogram and rug eta_distrib(xpdb, type = 'hr') ``` -------------------------------- ### Goodness-of-Fit Plots in R using xpose Source: https://context7.com/uupharmacometrics/xpose/llms.txt xpose provides functions like dv_vs_ipred() and dv_vs_pred() to generate goodness-of-fit plots. These functions visualize observed values against predictions (individual or population) with options for identity lines, smoothing, faceting, and custom styling. dv_preds_vs_idv() allows overlaying multiple predictions. ```r # Basic DV vs IPRED plot dv_vs_ipred(xpdb) # Customized with faceting and styling dv_vs_ipred(xpdb, facets = 'SEX', point_color = 'blue', point_alpha = 0.6, smooth_method = 'lm', title = 'Observations vs Individual Predictions | @run', subtitle = 'OFV: @ofv, Epsilon shrinkage: @epsshk') # DV vs population predictions dv_vs_pred(xpdb, log = 'xy', # Log-log scale facets = c('SEX', 'MED1'), type = 'pls') # points + line + smooth # Multiple predictions overlaid dv_preds_vs_idv(xpdb, facets = 'ID', page = 1) ``` -------------------------------- ### Plotting Amount vs. Individual Value Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Adds a new plot type `amt_vs_idv()` for visualizing amount versus individual values. ```R amt_vs_idv(xpdb, ...) ``` -------------------------------- ### Dplyr Integration for xpdb Editing Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Enables the use of dplyr verbs for editing the xpdb object, allowing for efficient data manipulation. This includes slicing, selecting, renaming, distinct, summarizing, grouping, and ungrouping data. ```R library(dplyr) xpdb %>% slice(1:10) xpdb %>% select(ID, AGE) xpdb %>% rename(patient_id = ID) xpdb %>% distinct(ID) xpdb %>% summarize(mean_age = mean(AGE)) xpdb %>% group_by(SEX) xpdb %>% ungroup() ``` -------------------------------- ### Individual Subject Plots in R using ind_plots() Source: https://context7.com/uupharmacometrics/xpose/llms.txt The ind_plots() function generates faceted plots displaying observations, individual predictions, and population predictions versus time for each subject. Users can customize the layout (nrow, ncol), page number, colors, point transparency, line types, and titles for publication-ready individual fits. ```r # First page with 3x3 grid ind_plots(xpdb, page = 1, nrow = 3, ncol = 3) # Customized individual plots ind_plots(xpdb, page = 2, nrow = 2, ncol = 2, color = c('grey60', 'deepskyblue4', 'deepskyblue3'), point_alpha = c(0.8, 0, 0), line_linetype = c('blank', 'solid', '55'), title = 'Individual Fits | @run', subtitle = 'OFV: @ofv') # Semi-log scale ind_plots(xpdb, page = 1, log = 'y') ``` -------------------------------- ### Advanced xpose Plotting with ggplot2 Integration Source: https://context7.com/uupharmacometrics/xpose/llms.txt Customize xpose plots using ggplot2's grammar of graphics for advanced aesthetics, mappings, and faceting. Supports layer-specific aesthetics, custom aes() mappings, and flexible faceting with pagination and margins. ```r # Layer-specific aesthetics dv_vs_ipred(xpdb, point_color = 'blue', point_alpha = 0.5, point_size = 1.5, point_shape = 16, line_color = 'black', line_linetype = 'dashed', smooth_color = 'red', smooth_method = 'lm', smooth_se = FALSE, guide_color = 'grey50', guide_linetype = '44') # Custom mappings with aes() xpdb %>% dv_vs_ipred(aes(point_color = SEX, point_shape = MED1), point_size = 2) # Wrap faceting with pagination dv_vs_pred(xpdb, facets = c('SEX', 'MED1', 'RACE'), nrow = 2, ncol = 2, page = 1, scales = 'free') # Grid faceting with margins res_vs_pred(xpdb, res = 'CWRES', facets = SEX ~ MED1, margins = TRUE) ``` -------------------------------- ### Data Manipulation with dplyr verbs in xpose Source: https://context7.com/uupharmacometrics/xpose/llms.txt Apply standard dplyr data manipulation verbs like filter(), mutate(), and select() directly to xpdb objects. Supports problem-specific targeting. ```r # Filter observations xpdb_filtered <- xpdb %>% filter(DV > 0, TIME > 0, .problem = 1) # Create new variables xpdb_modified <- xpdb %>% mutate( lnDV = log(DV), TAD = TIME - TAFD, CMAX_group = cut(DV, breaks = c(0, 1, 5, Inf)), .problem = 1 ) # Use modified data in plots xpdb_modified %>% dv_vs_idv(aes(y = lnDV), facets = 'CMAX_group') # Select specific columns xpdb_subset <- xpdb %>% select(ID, TIME, DV, IPRED, CWRES, SEX, .problem = 1) # Group and summarize xpdb %>% group_by(ID, SEX, .problem = 1) %>% summarise(CMAX = max(DV), AUC = sum(DV * 0.5), .problem = 1) %>% ungroup(.problem = 1) %>% xplot_distrib(aes(x = CMAX, density_fill = SEX), type = 'dr') # Simulation counter for repeated IDs xpdb %>% mutate(sim_id = irep(ID), .problem = 2) ``` -------------------------------- ### Filtering xpdb with dplyr::filter() Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Allows filtering of the xpdb object using the standard dplyr::filter() verb, enabling subsetting of data based on specified conditions. ```R library(dplyr) xpdb %>% filter(SEX == "M" & AGE > 30) ``` -------------------------------- ### Generate DV vs IPRED Plot in R Source: https://github.com/uupharmacometrics/xpose/blob/master/README.md This R code generates a standard goodness-of-fit plot showing the observed dependent variable (DV) against the individual predicted values (IPRED). The `dv_vs_ipred` function from the xpose package is used for this purpose, utilizing the xpose database object. ```r dv_vs_ipred(xpdb) ``` -------------------------------- ### Plotting Residuals vs. IDV Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md General function for plotting residuals against the individual variability (IDV). This replaces older specific functions like cwres_vs_idv. ```R res_vs_idv(xpdb, res = 'CWRES') ``` -------------------------------- ### ggplot2 Integration with xpose_geom Source: https://github.com/uupharmacometrics/xpose/blob/master/NEWS.md Defines the core `xpose_geom()` function to directly map arguments to ggplot2 layers, facilitating the creation of customized plots within the xpose framework using tidyverse principles. ```R library(ggplot2) library(magrittr) xpose_geom(aes(x = TIME, y = DV), geom = "point") %>% + xpose_theme() ``` -------------------------------- ### Variable Management Functions in xpose Source: https://context7.com/uupharmacometrics/xpose/llms.txt Functions to modify variable types, labels, and units within xpdb objects. This allows for customization of plot axes and the use of alternative independent variables. ```r # Change independent variable from TIME to TAD xpdb_tad <- set_var_types(xpdb, .problem = 1, idv = 'TAD') # Set multiple variable types xpdb_modified <- set_var_types(xpdb, .problem = 1, idv = 'TAD', dv = 'CONC', catcov = c('SEX', 'RACE', 'MED1'), contcov = c('AGE', 'WT', 'HT')) # Set descriptive labels xpdb_labeled <- set_var_labels(xpdb, .problem = 1, ALAG1 = 'Absorption lag time', CL = 'Clearance', V = 'Volume of distribution', KA = 'Absorption rate constant') # Set units xpdb_units <- set_var_units(xpdb, .problem = 1, ALAG1 = 'h', CL = 'L/h', V = 'L', KA = '1/h') # Combined workflow xpdb_complete <- xpdb %>% set_var_types(idv = 'TAD', .problem = 1) %>% set_var_labels(TAD = 'Time after dose', .problem = 1) %>% set_var_units(TAD = 'h', .problem = 1) # List current variable classifications list_vars(xpdb_complete) ``` -------------------------------- ### Update xpose Plot Aesthetics Source: https://context7.com/uupharmacometrics/xpose/llms.txt Modify the visual appearance of xpose plots by updating theme elements such as point color, size, line color, and smooth method. This allows for customization of both xpose-specific themes and integration with ggplot2 themes. ```r xpdb_styled <- xpdb %>% update_themes( xp_theme = list( point_color = 'steelblue', point_alpha = 0.6, point_size = 2, line_color = 'red', smooth_color = 'orange', smooth_method = 'loess' ) ) xpdb_themed <- xpdb %>% update_themes( gg_theme = theme_bw() + theme( legend.position = 'top', axis.text = element_text(size = 12), strip.background = element_rect(fill = 'grey90') ) ) xpdb_custom <- xpdb %>% update_themes( gg_theme = theme_minimal(), xp_theme = list( point_color = 'blue', line_color = 'blue', smooth_color = 'red', area_fill = 'grey80' ) ) xpdb_xpose4 <- xpdb %>% update_themes(xp_theme = theme_xp_xpose4()) ``` -------------------------------- ### Residual Diagnostics Plots in R using xpose Source: https://context7.com/uupharmacometrics/xpose/llms.txt Residual diagnostic plots are generated using functions like res_vs_pred() and res_vs_idv(). These plots visualize residuals (e.g., CWRES, IWRES, NPDE) against predictions or independent variables to assess model fit and identify bias. Options include specifying residual types, stratification, point styling, and smoothing methods. ```r # CWRES vs predictions res_vs_pred(xpdb, res = 'CWRES') # CWRES vs time with stratification res_vs_idv(xpdb, res = 'CWRES', facets = 'SEX', point_color = 'steelblue', smooth_color = 'red') # Multiple residual types res_vs_pred(xpdb, res = c('IWRES', 'CWRES', 'NPDE')) # Absolute residuals absval_res_vs_idv(xpdb, res = 'CWRES', smooth_method = 'loess', facets = 'MED1') ``` -------------------------------- ### Customize Xpose Plot Scales and Add ggplot2 Layers Source: https://context7.com/uupharmacometrics/xpose/llms.txt This snippet demonstrates how to customize the x-axis and y-axis scales for an xpose plot, including setting break points and labels. It also shows how to add custom ggplot2 layers, such as horizontal lines and labels, to enhance the plot's informational content. This is useful for refining plot aesthetics and highlighting specific features of the diagnostic plots. ```R dv_vs_idv(xpdb, xscale_name = 'Time (hours)', xscale_breaks = c(0, 6, 12, 24, 48), xscale_labels = c('0', '6h', '12h', '1d', '2d'), yscale_name = 'Concentration (ng/mL)', log = 'y') xpdb %>% res_vs_pred(res = 'CWRES') + geom_hline(yintercept = c(-2, 2), linetype = 'dashed', color = 'red', alpha = 0.5) + labs(caption = 'Reference lines at ±2') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.