lcMethod
) estimation procedureR/method.R
lcMethod-estimation.Rd
Each longitudinal cluster method represented by a lcMethod class implements a series of standardized steps that produce the estimated method as its output.
These steps, as part of the estimation procedure, are executed by the latrend()
function and other functions prefixed by "latrend" (e.g., latrendRep()
, latrendBoot()
, latrendCV()
).
The steps for estimating a lcMethod
object are defined and executed as follows:
compose()
: Evaluate and finalize the method argument values.
validate()
: Check the validity of the method argument values in relation to the dataset.
prepareData()
: Process the training data for fitting.
preFit()
: Prepare environment for estimation, independent of training data.
fit()
: Estimate the specified method on the training data, outputting an object inheriting from lcModel
.
postFit()
: Post-process the outputted lcModel
object.
The result of the fitting procedure is an lcModel object that inherits from the lcModel
class.
data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
model <- latrend(method, data = latrendData)
summary(model)
#> Longitudinal cluster model using lmkm
#> lcMethodLMKM specifying "lm-kmeans"
#> time: "Time"
#> id: "Id"
#> nClusters: 2
#> center: function (x) { mean(x, na.rm = TRUE)}
#> standardize: `scale`
#> method: "qr"
#> model: TRUE
#> y: FALSE
#> qr: TRUE
#> singular.ok: TRUE
#> contrasts: NULL
#> iter.max: 10
#> nstart: 1
#> algorithm: `c("Hartigan-Wong", "Lloyd", "Forgy", "M
#> formula: Y ~ Time
#>
#> Cluster sizes (K=2):
#> A B
#> 120 (60%) 80 (40%)
#>
#> Number of obs: 2000, strata (Id): 200
#>
#> Scaled residuals:
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> -3.57615 -0.62971 0.05638 0.00000 0.65400 3.20251
#>