## 3 Research Methods
### Data Analysis
#### 3.4.1 Phase One: Topic Modeling with Latent Dirichlet Allocation (LDA) and pyLDAvis  
Topic modeling is fundamental for identifying latent thematic structures in extensive text corpora. In this study, LDA was employed, which posits that documents are composed of a mixture of latent topics, each characterized by a distribution across the vocabulary [54]. The analysis used LDA for topic extraction and pyLDAvis for interactive visualization to help interpret the topics. The procedure was as follows:  
Step 1. Feature extraction: Prior to applying the LDA model, feature extraction was conducted to convert text data into a bag-of-words model. Important feature words were extracted by setting appropriate parameters, ensuring that subsequent topic modeling focused on the most significant feature words. Step 2. Determining the optimal number of topics: The number of topics was determined by evaluating the model's perplexity. Lower perplexity indicates better generalization ability. The formula for perplexity is (1):  
\[\text{Perplexity}=\exp\left\{-\frac{1}{N}\sum_{d=1}^{D}\log P(w_{d})\right\} \tag{1}\]  
where \(N\) is the total number of words, and \(P(w_{d})\) is the probability of words in document \(d\). Lower perplexity indicates better model performance, but excessive topics can lead to overfitting and reduced interpretability. The elbow method was used to find the \"elbow point\" of the curve, where adding more topics has diminishing returns in reducing perplexity. Step 3. LDA model training: The document-word matrix was trained using the LDA model, setting the number of topics \(K\) and iterating for optimization. The objective was to maximize the likelihood function of the document's topic distribution and the topic's word distribution (2):  
\[Maximize\;P(w|\alpha,\beta)=\prod_{d=1}^{D}\int\left(\prod_{n=1}^{N_{d}}\sum_{ k=1}^{K}P(w_{dn}|z_{dn},\beta_{k})P(z_{dn}|\theta_{d})\right)P(\theta_{d}| \alpha)d\theta_{d} \tag{2}\]  
where \(w\) is the word, \(\alpha\) and \(\beta\) are hyperparameters, \(D\) is the number of documents, \(N_{d}\) is the number of words in document \(d\), and \(K\) is the number of topics. Gibbs sampling was employed to update the topic assignments (3). The process involved setting the number of topics \(K\) and Dirichlet distribution hyperparameters \(\alpha\) and \(\beta\), randomly assigning a topic to each word in each document, and using Gibbs sampling to update the topic assignment for each word based on the current topic distribution and word distribution, as shown in Equation (3). Then, the document-topic distribution, \(\theta_{d}\), and topic-word distribution, \(\varphi_{k}\), parameters were updated based on the current topic assignments, as indicated in Equations (4) and (5). This was repeated until the likelihood function converged or the maximum number of iterations was reached. \[P(z_{dn}=k|z_{-dn},w)\propto\frac{n_{dk}^{-dn}+\alpha}{n_{d}^{-dn}+K\alpha} \cdot\frac{n_{kw}^{-dn}+\beta}{n_{k}^{-dn}+V\beta} \tag{3}\]  
where \(z_{-dn}\) is the topic assignment for the \(n\)-th word in document \(d\), \(n_{dk}^{-dn}\) is the count of words assigned to topic \(k\), excluding the current word, and \(V\) is the vocabulary size. The model parameters \(\theta\) and \(\phi\) were updated iteratively, as indicated in Equations (4) and (5):  
\[\theta_{dk} = \frac{n_{dk}+\alpha}{n_{d}+K\alpha} \tag{4}\] \[\phi_{kw} = \frac{n_{kw}+\beta}{n_{k}+V\beta} \tag{5}\]  
These parameters represent the probability of topic \(k\) in document \(d\) and the probability of word \(w\) in topic \(k\), respectively, providing a probabilistic interpretation of topic distributions. Step 4. Visualizing and validating topics: pyLDAvis was used to visualize the fitted LDA model, aiding in intuitive understanding of topics. It offers an interactive web-based view, ranking the representative words by importance within each topic, which helps to evaluate model coherence--an indicator of model quality. High coherence means stronger word associations, effectively capturing the main content of each topic.