Last data update: 2014.03.03

R: A function for calculating the empirical variogram for data...
variogramR Documentation

A function for calculating the empirical variogram for data sets with regularly or irregularly spaced follow-up time points

Description

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

Usage

variogram(resid, timeVar, id, binwidth, numElems = 0, inc.var = TRUE, 
irregular = TRUE)

Arguments

resid

a vector of empirical residuals

timeVar

a vector for the time variable

id

a vector for subject identification

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

inc.var

a character string, if set FALSE process variance is not included in the plot

irregular

a character string, FALSE indicates the data are collected at regular time points

Value

Returns mid values and means of the bins, and numbers of elements falling into the bins for irregular = TRUE, and lags and means of the lags, and number of the elements for the lags for irregular = FALSE. Process variance is also returned.

Author(s)

Ozgur Asar, Peter J. Diggle

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 (1988) An approach to the analysis of repeated measurements. Biometrics, 44, 959-971.

Diggle PJ, Heagerty PJ, Liang K-Y, Zeger SL. (2002) Analysis of Longitudinal Data, 2nd edition. Oxford University Press: Oxford.

Diggle PJ, Ribeiro PJ Jr. (2007) Model-based Geostatistics. Springer-Verlag: New York.

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

# 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 variogram
lm.fit <- lm(log.egfr ~ sex + bage + fu + pwl, data = data.sim.ibm.short)
variogram(resid = resid(lm.fit), timeVar = data.sim.ibm.short$fu, id = data.sim.ibm.short$id,
  binwidth = 0.1, numElems = 20, inc.var = FALSE)

Results