Step1Measures {traj} | R Documentation |
Compute Measures for Identifying Patterns of Change in Longitudinal Data
Description
Step1Measures
computes up to 18 measures for each
longitudinal trajectory. See Details for the list of measures.
Usage
Step1Measures(
Data,
Time = NULL,
ID = FALSE,
measures = c(1:17),
midpoint = NULL,
cap.outliers = TRUE
)
## S3 method for class 'trajMeasures'
print(x, ...)
## S3 method for class 'trajMeasures'
summary(object, ...)
Arguments
Data |
a matrix or data frame in which each row contains the longitudinal data (trajectories). |
Time |
either |
ID |
logical. Set to |
measures |
a vector containing the numerical identifiers of the measures to compute (see "Details" section below). The default, 1:17, corresponds to measures 1-17 and thus excludes the measures which require specifying a midpoint. |
midpoint |
specifies which column of |
cap.outliers |
logical. If |
x |
object of class trajMeasures. |
... |
further arguments passed to or from other methods. |
object |
object of class trajMeasures. |
Details
Each trajectory must have a minimum of 3 observations otherwise it will be omitted from the analysis.
The 18 measures and their numerical identifiers are listed below. Please refer to the vignette for the specific formulas used to compute them.
Maximum
Range (max - min)
Mean value
Standard deviation
Slope of the linear model
-
R^2
: Proportion of variance explained by the linear model
Curve length (total variation)
Rate of intersection with the mean
Proportion of time spent under the mean
Minimum of the first derivative
Maximum of the first derivative
Mean of the first derivative
Standard deviation of the first derivative
Minimum of the second derivative
Maximum of the second derivative
Mean of the second derivative
Standard deviation of the second derivative
Early change/Later change
In the presence of highly correlated measures (Pearson correlation >
0.98), the function selects the highest-ranking measure on the list (see
Step1Measures
) and discards the others. Because the
K-means algorithm is sensitive to outliers, the measures are prevented from taking extreme or
infinite values (caused by a possible division by 0 in m18). Nishiyama's improved Chebychev
bound is used to determine extreme values for each measure, corresponding to
a 0.3% probability threshold. Extreme values beyond the threshold are then capped
to the 0.3% probability threshold. If applicable, the values of m18 which
would be of the form 0/0 are set to 1. PCA is applied on the remaining
measures using the principal
function from the
psych
package.
Value
An object of class trajMeasures
; a list containing the values
of the measures, a table of the outliers which have been capped, as well as
a curated form of the function's arguments.
References
Leffondre K, Abrahamowicz M, Regeasse A, Hawker GA, Badley EM, McCusker J, Belzile E. Statistical measures were proposed for identifying longitudinal patterns of change in quantitative health indicators. J Clin Epidemiol. 2004 Oct;57(10):1049-62. doi: 10.1016/j.jclinepi.2004.02.012. PMID: 15528056.
Nishiyama T, Improved Chebyshev inequality: new probability bounds with known supremum of PDF, arXiv:1808.10770v2 stat.ME https://doi.org/10.48550/arXiv.1808.10770
Examples
## Not run:
data("trajdata")
trajdata.noGrp <- trajdata[, which(colnames(trajdata) == "Group")] #remove the Group column
m1 = Step1Measures(trajdata.noGrp, ID = TRUE, measures = 18, midpoint = NULL)
m2 = Step1Measures(trajdata.noGrp, ID = TRUE, measures = 18, midpoint = 3)
identical(m1$measures, m2$measures)
## End(Not run)