Learn R Programming

lmenssp (version 1.2)

var.inspect: A function for calculating empirical variances with respect to time for data sets with regularly or irregularly spaced follow-up time points

Description

Calculates empirical variances for data sets with regularly or irregularly spaced time points, and plots the result

Usage

var.inspect(resid, timeVar, binwidth, numElems = 0, irregular = T)

Arguments

resid
a vector of empirical residuals
timeVar
a vector for the time variable
binwidth
a numerical value for the bin length, to be used for irregularly spaced data
numElems
a numerical value for the elimination of the bins with less than that number of elements
irregular
a character string, FALSE indicates the data are collected at regular time points

Value

Returns mid values and variances of the bins, and numbers of elements falling into the bins for irregular = TRUE, and unique time points and variances, and number of the elements for the time points for irregular = FALSE.

References

Asar O, Ritchie J, Kalra P, Diggle PJ (2015) Acute kidney injury amongst chronic kidney disease patients: a case-study in statistical modelling. To be submitted.

Diggle PJ, Sousa I, Asar O (2015) Real time monitoring of progression towards renal failure in primary care patients. Biostatistics, 16(3), 522-536.

Examples

Run this code
# loading the data set and subsetting it for the first 20 patients 
# for the sake illustration of the usage of the functions
data(data.sim.ibm)
data.sim.ibm.short <- data.sim.ibm[data.sim.ibm$id <= 20, ]

# obtaining empirical residuals by a linear model
# and calculating the empirical variances
lm.fit <- lm(log.egfr ~ sex + bage + fu + pwl, data = data.sim.ibm.short)
var.inspect(resid = resid(lm.fit), timeVar = data.sim.ibm.short$fu, binwidth = 0.1,
   numElems = 20, irregular = TRUE)

Run the code above in your browser using DataLab