lcMethodStratify {latrend} | R Documentation |
Specify a stratification method
Description
Specify a stratification method
Usage
lcMethodStratify(
response,
stratify,
center = meanNA,
nClusters = NaN,
clusterNames = NULL,
time = getOption("latrend.time"),
id = getOption("latrend.id"),
name = "stratify"
)
Arguments
response |
The name of the response variable. |
stratify |
An |
center |
The |
nClusters |
The number of clusters. This is optional, as this can be derived from the largest assignment number by default, or the number of |
clusterNames |
The names of the clusters. If a |
time |
The name of the time variable. |
id |
The name of the trajectory identification variable. |
name |
The name of the method. |
See Also
Other lcMethod implementations:
getArgumentDefaults()
,
getArgumentExclusions()
,
lcMethod-class
,
lcMethodAkmedoids
,
lcMethodCrimCV
,
lcMethodDtwclust
,
lcMethodFeature
,
lcMethodFunFEM
,
lcMethodFunction
,
lcMethodGCKM
,
lcMethodKML
,
lcMethodLMKM
,
lcMethodLcmmGBTM
,
lcMethodLcmmGMM
,
lcMethodMclustLLPA
,
lcMethodMixAK_GLMM
,
lcMethodMixtoolsGMM
,
lcMethodMixtoolsNPRM
,
lcMethodRandom
Examples
data(latrendData)
# Stratification based on the mean response level
method <- lcMethodStratify(
"Y",
mean(Y) > 0,
clusterNames = c("Low", "High"),
id = "Id",
time = "Time"
)
model <- latrend(method, latrendData)
summary(model)
# Stratification function
stratfun <- function(trajdata) {
trajmean <- mean(trajdata$Y)
factor(
trajmean > 1.7,
levels = c(FALSE, TRUE),
labels = c("Low", "High")
)
}
method <- lcMethodStratify("Y", stratfun, id = "Id", time = "Time")
# Multiple clusters
stratfun3 <- function(trajdata) {
trajmean <- mean(trajdata$Y)
cut(
trajmean,
c(-Inf, .5, 2, Inf),
labels = c("Low", "Medium", "High")
)
}
method <- lcMethodStratify("Y", stratfun3, id = "Id", time = "Time")