variogram: A function for calculating the empirical variogram for data...

Description Usage Arguments Value Author(s) References Examples

View source: R/variogram.R

Description

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

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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)

lmenssp documentation built on May 29, 2017, 10:33 p.m.