# Analyzing Student Behavioral Patterns in MOOCs Using Hidden Markov Models in Distance Education
## 2 Materials and Methods
The model has been trained from a sample data of 4037 student IDs. The observed frequency of transitions from state K to state L is e.g., \(p_{KL}=1/9\). We consider nine hidden states in our experiments. The observed frequency of transitions from Moodle state K to Moodle state L in the training set (i.e., the given set of observations) of the students in the dataset is the \(p_{KL}\).The transition probabilities among the nine states are given in a 9 \(\times\) 9 transition probability matrix, which reveals the entire space of possible transitions between the selected states. The step in the sequence for a student ID \(t\) is represented by the rows, while the step for a student ID \(t+1\) is represented by the columns. The sum of each row in the transition matrix is 1. The transition matrix in our experiments appears in Table 3.  
As mentioned above, observed states are considered to be the final grades in the course. Hidden Markov Models assume that a given state is only dependent on the previous state. In addition, HMMs assume that the probability of an observation depends only on the current state. By determining as hidden states the sequence of Moodle states for a given training set of observations from 4037 students, the emission matrix is the probability matrix for seeing an observation state \(V_{m}\) (i.e., a final grade) at a hidden state \(S_{n}\). We define as emission probability matrix the matrix \(B=\{b_{nm}|b_{nm}=P(O_{t}=V_{m}|S_{t}=n)\}\). If the number of hidden states is \(J\), the number of observed states is \(K\), and the number of student IDs is \(T\), then the emission matrix has dimensions \(JxK\). In order to find the maximum probability for the given set of observations, i.e., the final grades of the students, we apply the solution to an optimization problem. Therefore, we are looking for a criterion for this optimization, and we apply the maximum likelihood criterion. Thus, we aim to find the HMM parameters that maximize the probability of occurring in the given observation sequence. The probability of the occurrence of this observation sequence is the solution to the following equation. \[\lambda^{*}=argmax_{\lambda}\{P[O|\lambda]\}\]  
Because of the complexity of the solution, the maximization of \(P[O|\lambda]\) is performed locally, and it employs iterations. This method is called Baum-Welch. In order to find the optimal state sequence associated with a given observation sequence \(O\) of the given model \(\lambda\), we are looking for the sequence \(Q\) that maximizes the probability \(P[Q|O,\lambda]\). In the current study, we have \(T\) = 4037 observations (final grades) and N = 9 Moodle states. Hence, the possible sequences are \(N^{T}\) for the \(Q\). Considering two consecutive states in a sequence that have a probability of 0 to occur, this results in an invalid state sequence. The Viterbi algorithm is a dynamic algorithm that avoids the occurrence of this kind of sequence. We provide two charts with the statistics of the input data in Figure 1. The first chart illustrates columns with the number of occurrences of each Moodle state in the course. The second chart illustrates columns with the number of the achievements of each final grade. We observe that many students view the forum discussions, less students start and submit the quizzes. Only a few students view the wiki pages, and fewer create or view a wiki comment. For some students, only a few create or delete a forum post. Most students achieve in the final exams a Grade 8 to 9, and a smaller percentage achieve Grade 7 or Grade 10. A small percentage fail with Grade 0. Only 2 students take Grade 4, and only 105 students receive Grades 5 to 6. The proposed algorithm is given in the following Algorithm 1. **Step 1** Transition Emission Matrixes  
From the emission matrix we derive conclusions about the grades achieved from the students after the participation to each resource of the MOOC.