Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

variogram

Empirical variogram for longitudinal data


Description

Calculates the variogram for observed measurements, with two components, the total variability in the data, and the variogram for all time lags in all individuals.

Usage

variogram(indv, time, Y)

Arguments

indv

vector of individual identification, as in the longitudinal data, repeated for each time point.

time

vector of observation time, as in the longitudinal data.

Y

vector of observed measurements. This can be a vector of longitudinal data, or residuals after fitting a model for the mean response.

Details

The empirical variogram in this function is calculated from observed half-squared-differences between pairs of measurements, v_ijk = 0.5 * (r_ij-r_ik)^2 and the corresponding time differences u_ijk=t_ij-t_ik. The variogram is plotted for averages of each time lag for the v_ijk for all i.

Value

An object of class vargm and list with two elements. The first svar is a matrix with columns for all values (u_ijk,v_ijk), and the second sigma2 is the total variability in the data.

Note

There is a function plot.vargm which should be used to plot the empirical variogram.

Author(s)

Ines Sousa (isousa@math.uminho.pt)

Examples

data(mental)
mental.unbalanced <- to.unbalanced(mental, id.col = 1, 
                                   times = c(0, 1, 2, 4, 6, 8),
                                   Y.col = 2:7, 
                                   other.col = c(8, 10, 11))
names(mental.unbalanced)[3] <- "Y"

vgm <- variogram(indv = tail(mental.unbalanced[, 1], 30),
                 time = tail(mental.unbalanced[, 2], 30),
                 Y = tail(mental.unbalanced[, 3], 30))

joineR

Joint Modelling of Repeated Measurements and Time-to-Event Data

v1.2.5
GPL-3 | file LICENSE
Authors
Pete Philipson [aut, cre] (<https://orcid.org/0000-0001-7846-0208>), Ines Sousa [aut] (<https://orcid.org/0000-0002-2712-1713>), Peter J. Diggle [aut] (<https://orcid.org/0000-0003-3521-5020>), Paula Williamson [aut] (<https://orcid.org/0000-0001-9802-6636>), Ruwanthi Kolamunnage-Dona [aut] (<https://orcid.org/0000-0003-3886-6208>), Robin Henderson [aut], Graeme L. Hickey [aut] (<https://orcid.org/0000-0002-4989-0054>), Maria Sudell [ctb], Medical Research Council [fnd] (Grant numbers: G0400615 and MR/M013227/1)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.