Skip to contents

This is a template function for creating structured goodness of fit diagnostics using the functions in the Xpose specific library.

Usage

gof(
  runno = NULL,
  save = FALSE,
  onefile = FALSE,
  saveType = "pdf",
  pageWidth = 7.6,
  pageHeight = 4.9,
  structural = TRUE,
  residual = TRUE,
  covariate = FALSE,
  iiv = FALSE,
  iov = FALSE,
  all = FALSE,
  myTrace = xpPage
)

Arguments

runno

The run number fo Xpose to identify the appropriate files to read. In addition runno is used to construct the file name to save plots in. runno can also be NULL for cases in which the function is used for non-Xpose based code.

save

Logical. TRUE if the plot(s) is to be saved in a file. FALSE if the plot(s) is to be displayed on screen. The plot(s) will be saved in a file named with the function name followed by the word 'run', the run number, an order number followed by a file name extension appropriate for the selected saveType. For example 'gofrun1-01.pdf' for the first plot file created by a script called gof based on output from run 1 and saveType='pdf'.

onefile

Logical. TRUE if plots are to be save in a single file and FALSE if each plot should be saved as a separate file. In the latter case, each file will be have an incremented order number (01-99).

saveType

The type of graphics file to produce if save=TRUE. Allowed values are 'pdf' (default), 'wmf' (only Windows) and 'png'.

pageWidth

The width of the graphics device in inches.

pageHeight

The height of the graphics device in inches.

structural

Logical. TRUE if the code in the structural model section (see below) should be executed and FALSE if not.

residual

Logical. TRUE if the code in the residual model section (see below) should be executed and FALSE if not.

covariate

Logical. TRUE if the code in the covariate model section (see below) should be executed and FALSE if not.

iiv

Logical. TRUE if the code in the IIV model section (see below) should be executed and FALSE if not.

iov

Logical. TRUE if the code in the IOV model section (see below) should be executed and FALSE if not.

all

Logical. TRUE if the code in all sections (see below) should be executed.

myTrace

NULL or the name of a function. The value of myTrace can used with the lattice page= argument to annotate plots for traceability.

Value

Does not return anything unless the user specify a return value.

Details

The gof function is provided as a template to facilitate the (structured) use of the functions in the Xpose specific library. Xpose specific is extensively described in the 'Xpose Bestiary'.

The function can be renamed so that multiple scripts can be used in parallel.

The function is set up to make it easy to display plots on screen as well as to save them in files. In the latter case, plots are save in a sub-directory called 'Plots'.

The arguments structural, residual, covariate, iiv, iov and all are just "switches" to different parts of the code (if-blocks). These blocks can be removed or the default values of the arguments changed to better suit the needs of the user.

It is also possible to add tracing information to the produced plots. This is done via the myTrace argument. A non-NULL value should be a function that returns a panel.text object. The default is the xpPage function that will put a string concatenated from the device name, function name, working directory and date, in small, faint grey, font at the bottom of each graph page. Note that the user need to add page=myTrace as an argument to the Xpose functions for this to have an effect.

The function calls a support function called gofSetup, which is responsible for setting up the graphics device and determining the file names for saved graphs.

Author

E. Niclas Jonsson, Mats Karlsson and Andrew Hooker

Examples


if (FALSE) {
## This is an example of how the function may be setup by a user.

library(xpose4)
mygof <- gof
fix(mygof)

myggof <- function (runno = NULL, save = FALSE, onefile = FALSE, saveType = "pdf", 
         pageWidth = 7.6, pageHeight = 4.9, structural = TRUE, residual = TRUE, 
         covariate = FALSE, iiv = FALSE, iov = FALSE, all = FALSE, myTrace=xpPage) {

         gofSetup(runno, save, onefile, saveType, pageWidth, pageHeight)
         xpdb <- xpose.data(runno)

         if (structural || all) {
          xplot <- dv.vs.pred.ipred(xpdb, page = myPage)
          print(xplot)
         }
         if (residual || all) {
          xplot <- absval.wres.vs.pred(xpdb, page = myPage)
          print(xplot)
         }
         if (covariate || all) {
         }
         if (iiv || all) {
         }
         if (iov || all) {
         }
         if (save) dev.off()
    invisible()
  }

## The function can then be execute, e.g.:
mygof(1)

}