DOI: 10.7910/dvn/ee3de2
title: Replication Data for: "A Topic-based Segmentation Model for Identifying Segment-Level Drivers of Star Ratings from Unstructured Text Reviews"

description: We provide instructions, codes and datasets for replicating the article by Kim, Lee and McCulloch (2024), "A Topic-based Segmentation Model for Identifying Segment-Level Drivers of Star Ratings from Unstructured Text Reviews." This repository provides a user-friendly R package for any researchers or practitioners to apply A Topic-based Segmentation Model with Unstructured Texts (latent class regression with group variable selection) to their datasets. First, we provide a R code to replicate the illustrative simulation study: see file 1. Second, we provide the user-friendly R package with a very simple example code to help apply the model to real-world datasets: see file 2, Package_MixtureRegression_GroupVariableSelection.R and 
Dendrogram.R. Third, we provide a set of codes and instructions to replicate the empirical studies of customer-level segmentation and restaurant-level segmentation with Yelp reviews data: see files 3-a, 3-b, 4-a, 4-b. Note, due to the dataset terms of use by Yelp and the restriction of data size, we provide the link to download the same Yelp datasets (https://www.kaggle.com/datasets/yelp-dataset/yelp-dataset/versions/6).
Fourth, we provided a set of codes and datasets to replicate the empirical study with professor ratings reviews data: see file 5. Please see more details in the description text and comments of each file. 
&lt;br&gt;&lt;br&gt;

&lt;b&gt;[A guide on how to use the code to reproduce each study in the paper]&lt;/b&gt;&lt;br&gt;
 
&lt;i&gt;1. Full codes for replicating Illustrative simulation study.txt&lt;/i&gt; -- [see Table 2 and Figure 2 in main text]:
This is R source code to replicate the illustrative simulation study. Please run from the beginning to the end in R. In addition to estimated coefficients (posterior means of coefficients), indicators of variable selections, and segment memberships, you will get dendrograms of selected groups of variables in Figure 2. Computing time is approximately 20 to 30 minutes &lt;br&gt;
 
&lt;i&gt;3-a. Preprocessing raw Yelp Reviews for Customer-level Segmentation.txt&lt;/i&gt;:
Code for preprocessing the downloaded unstructured Yelp review data and preparing DV and IVs matrix for customer-level segmentation study.&lt;br&gt;

 
&lt;i&gt;3-b. Instruction for replicating Customer-level Segmentation analysis.txt&lt;/i&gt; -- [see Table 10 in main text; Tables F-1, F-2, and F-3 and Figure F-1 in Web Appendix]:
Code for replicating customer-level segmentation study with Yelp data. You will get estimated coefficients (posterior means of coefficients), indicators of variable selections, and segment memberships. Computing time is approximately 3 to 4 hours. &lt;br&gt;

 
&lt;i&gt;4-a. Preprocessing raw Yelp reviews_Restaruant Segmentation (1).txt&lt;/i&gt;:
R code for preprocessing the downloaded unstructured Yelp data and preparing DV and IVs matrix for restaurant-level segmentation study.&lt;br&gt;

 
&lt;i&gt;4-b. Instructions for replicating restaurant-level segmentation analysis.txt&lt;/i&gt; -- [see Tables 5, 6 and 7 in main text; Tables E-4 and E-5 and Figure H-1 in Web Appendix]:
Code for replicating restaurant-level segmentation study with Yelp. you will get estimated coefficients (posterior means of coefficients), indicators of variable selections, and segment memberships. Computing time is approximately 10 to 12 hours. &lt;br&gt;
&lt;u&gt;[Guidelines for running Benchmark models in Table 6]&lt;/u&gt; &lt;br&gt;
&lt;li&gt;Unsupervised Topic model: 'topicmodels' package in R -- after determining the number of topics(e.g., with 'ldatuning' R package), run 'LDA' function in the 'topicmodels'package. Then, compute topic probabilities per restaurant (with 'posterior' function in the package) which can be used as predictors. Then, conduct prediction with regression &lt;br&gt;&lt;/li&gt;
&lt;li&gt; Hierarchical topic model (HDP): 'gensimr' R package -- 'model_hdp' function for identifying topics in the package (see https://radimrehurek.com/gensim/models/hdpmodel.html or https://gensimr.news-r.org/). &lt;br&gt;&lt;/li&gt;
&lt;li&gt; Supervised topic model: 'lda' R package -- 'slda.em' function for training and 'slda.predict' for prediction.&lt;br&gt;&lt;/li&gt;
&lt;li&gt; Aggregate regression: 'lm' default function in R. &lt;br&gt;&lt;/li&gt;
&lt;li&gt; Latent class regression without variable selection: 'flexmix' function in 'flexmix' R package. Run flexmix with a certain number of segments (e.g., 3 segments in this study). Then, with estimated coefficients and memberships, conduct prediction of dependent variable per each segment. &lt;br&gt;&lt;/li&gt;
&lt;li&gt; Latent class regression with variable selection: 'Unconstraind_Bayes_Mixture' function in Kim, Fong and DeSarbo(2012)'s package. Run the Kim et al's model (2012) with a certain number of segments (e.g., 3 segments in this study). Then, with estimated coefficients and memberships, we can do prediction of dependent variables per each segment. The same R package ('KimFongDeSarbo2012.zip') can be downloaded at: https://sites.google.com/scarletmail.rutgers.edu/r-code-packages/home&lt;/li&gt;
 
&lt;i&gt;5. Instructions for replicating Professor ratings review study.txt&lt;/i&gt; -- [see Tables G-1, G-2, G-4 and G-5, and Figures G-1 and H-2 in Web Appendix]:
Code to replicate the Professor ratings reviews study. Computing time is approximately 10 hours.&lt;br&gt;&lt;br&gt;

&lt;b&gt;[A list of the versions of R, packages, and computer specification used in the paper]&lt;/b&gt;&lt;br&gt;

R version: 4.3.1 (2023-06-16 ucrt)&lt;br&gt;
Package versions: MCMCpack_1.6-3 coda_0.19-4 / mvtnorm_1.2-3 / MASS_7.3-60 / tm_0.7-11 / hunspell_3.0.3 / cluster_2.1.4 &lt;br&gt;
Processor: 11th Gen Intel(R) Core(TM) i7-11700 @ 2.50GHz 2.50 GHz&lt;br&gt;
Installed RAM: 32.0 GB (31.6 GB usable)&lt;br&gt;&lt;br&gt;



[Disclaimer] &lt;br&gt;
We developed these R packages and code to be as user-friendly as possible. However, a minimum familiarity with the R language and a good understanding of statistics are recommended for properly importing the data, running the model, and interpreting the results. There is no in-built protection against misuse.
&lt;br&gt;
[Technical Help or Problem Report] &lt;br&gt;
We are expecting the R packages and codes to be easy to use and to be working well. Please send any questions or report bugs to Sunghoon Kim (E-mail: Sunghoon.Kim@rutgers.edu).
&lt;br&gt;&lt;br&gt;
Note, another repo is available at &lt;i&gt; GitHub: https://github.com/Sunghoon-cloud/Topic-based-Clustering&lt;/i&gt;
&lt;br&gt;&lt;br&gt;
description: R, 4.3.1 or higher