# Is there something as "Vector Regression", instead of having just one numerical responsable variable I have multiple of them?

I'm interested in predicting the sequence of the order of the events in an individual giving a bunch of predictive variables using Machine Learning. So my guess is, for an specific instance with around 10 predictive variables, I write the rank of each event (Let's say that there are 6 of them (Event A, B, C, D, E and F), (for example Event A = 5 because it was the fifth).

If I have a new individual with his info (his 10 predictive variables) then I apply regression to every of event rank variable individually, I will obtain for each of them a number between 1 and 6, and for each of them I will guess the sequence.

I guess it must be a more intelligent way of predicting the sequence but I don't know how.

• This sounds like a few different possible tasks; could you make the example a little more concrete (e.g., what are the events of interest, why are they ordered, what a single training example would look like)? Commented Aug 2, 2023 at 2:45
• @Firebug Why did you suppress the "traminer" tag? With the answer given, this thread is clearly relevant for the TraMineR community! Commented Aug 4, 2023 at 13:19
• @Gilbert the question is not about traminer, so that's why. Otherwise other people answering would feel like they need to offer a traminer-based answer, which is very clearly not the case here Commented Aug 4, 2023 at 13:58
• @Firebug OK, but then people browsing the traminer tag will miss this question that could be relevant for them. Commented Aug 6, 2023 at 15:45
• No @Gilbert, this question is not necessarily relevant to them, since the question does not even mention the toolkit. Taking this to an extreme, imagine if everyone adding an answer with a different toolset were to add their tags to questions that did not ever mention the tool. Commented Aug 6, 2023 at 16:19

## 1 Answer

A possible solution is to grow a regression tree of observed sequence orders. (See also this answer to related question.)

If you have a set of observed event sequences, you can compute pairwise dissimilarities between the sequences using some edit distance measure. Then, using the resulting pairwise dissimilarity matrix, you can grow a regression tree of the sequences. You thus partition the sequences into leaves, each characterized by a proper combination of values of the covariates (predictors). The values of the covariates of a case determine to which leaf of the tree it belongs. However, cases in a leaf do not all have the same order. To predict an order you need to identify a representative order of the leaf such as the medoid or the sequence with the densest neighborhood.

All this can be done in R with the TraMineR and TraMineRextras packages. I illustrate below using the actcal monthly activity data included in TraMineR.

library(TraMineR)
library(TraMineRextras)

## loading actcal data (one case per line)
data(actcal)

## loading time-stamped event sequences built from the actcal data
## actcal.tse is a vertical file with one event per line
data(actcal.tse)
## creating event sequence object (one sequence per case)
actcal.seqe <- seqecreate(actcal.tse)
## We have 8 different events in this dataset
## assign unit cost for insertion/deletion of each event
idcost <- rep(1, 8)
## computing the dissimilarity matrix
dd <- seqedist(actcal.seqe, idcost=idcost, vparam=.1)
dim(dd)
# [1] 2000 2000

## growing the tree
dtree <- disstree(dd ~ educat00 + civsta00 + age00, data=actcal)
## Plot the tree using parallel coordinate plots for rendering order
gvpath <- "C:/Program Files/Graphviz"
disstreedisplay(dtree, image.data=actcal.seqe, filename="fg-event-seq-tree",
image.fun=seqpcplot, show.tree=TRUE, gvpath=gvpath)


To extract representative orders you can use the dissrep function. For the above example, where most of the sequences have a single event, medoids are in each leaf a sequence with a single event.

References:

For regression trees from a dissimilarity matrix:

Studer, M., G. Ritschard, A. Gabadinho and N.S. Müller (2011), Discrepancy analysis of state sequences, Sociological Methods and Research, 40(3), pp. 471-510. doi: 10.1177/0049124111415372.

For dissimilarities between event sequences:

Ritschard, G., R. Bürgin and M. Studer (2013), Exploratory Mining of Life Event Histories, in J.J. McArdle and G. Ritschard (eds), Contemporary Issues in Exploratory Data Mining in the Behavioral Sciences, Quantitative Methodology Series , New York: Routledge, pages 221-253. Preprint (pdf).

For representative sequences:

Gabadinho, A. and G. Ritschard (2013), Searching for typical life trajectories applied to childbirth histories, in R. Levy and E. Widmer (eds), Gendered life courses - Between individualization and standardization. A European approach applied to Switzerland, Vienna-Lit. Pages 287-312. Preprint (pdf).

For the parallel coordinate plot:

Bürgin, R. and G. Ritschard (2014), A decorated parallel coordinate plot for categorical longitudinal data, The American Statistician. Vol. 68(2), 98-103, doi: 10.1080/00031305.2014.887591.

• Thank you so much. Im looking for more information on this topic. Instead of "vectorial Regression", is there any other common name? I heard sequence analysis but in that case the problem is much different that mine as I see because items can repeat. Commented Aug 7, 2023 at 13:53