glmClust(formula, data, ident, timeVar, nClust, family = 'gaussian', effectVar = '', weights = rep(1,nrow(data)), affUser, timeParametric = TRUE, separateSampling = TRUE, max_itr = 100, verbose = TRUE)
'glmClust' also deals with multiple covariates with different level effects, different in each cluster and/or identical for all of them.
The introduction of covariates is possible thanks to 'glm' which fits a generalised linear model and take into account the type of the response (normal, binomial, Poisson ...etc) and the link function.
Several parameters of 'glmClust' are in common with
'glm', like the formula
which requires a
particular attention by specifying the covariates with a
cluster effect, for e.g. clust(T1+T2+..+Tn)
, the
covariates with an identical effect in each cluster are
specified with the keyword pop, for e.g.
pop(X1+X2+..+Xn)
, note that these last covariates
are optional. The data are in the long format and no
missing values are allowed.
In the parametric case (timeParametric = TRUE
)
multiples covariates are allowed, in the non-parametric
case only one covariate is allowed.
The algorithm depends greatly on the starting condition, which is obtained by randomly affecting the trajectories to the clusters unless the user introduce his own partition. To obtain better results it is desirable to run the algorithm several times from different starting points, therefore it is preferable to use kmlCov which runs the algorithm several times with different number of clusters.
At the end of the algorithm, an object of class
GlmCluster is returned and contains
information about the affectation of the trajectories,
the proportions, the convergence, ...etc. The main
trajectories can be simply visualised by
plot(my_GlmCluster_Object)
.
data(artifdata)
res <- glmClust(formula = Y ~ clust(time + time2 + time3) + pop(treatTime),
data = artifdata, ident = 'id', timeVar = 'time', effectVar = 'treatment', nClust = 4)
# the trajectories with indices 0 indicate the ones with a normal treatment, 1 indicate a high dose
# the color indicates the clusters
# the proportions are in the table above the diagram
plot(res)
Run the code above in your browser using DataLab