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.
variogram(indv, time, Y)
vector of individual identification, as in the longitudinal data, repeated for each time point.
vector of observation time, as in the longitudinal data.
vector of observed measurements. This can be a vector of longitudinal data, or residuals after fitting a model for the mean response.
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.
An object of class
list with two elements.
svar is a matrix with columns for all values
(u_ijk,v_ijk), and the second
sigma2 is the total variability
in the data.
There is a function
plot.vargm which should be used to
plot the empirical variogram.
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) <- "Y" vgm <- variogram(indv = tail(mental.unbalanced[, 1], 30), time = tail(mental.unbalanced[, 2], 30), Y = tail(mental.unbalanced[, 3], 30))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.