Lotus Records wants to screen demo tracks before
release. This section of the report uses ordinary least squares
(OLS) regression to examine which pre-release song characteristics are
associated with song_hotttnesss, the output variable of
interest. We first estimate an initial model, then test three extensions
(two polynomial terms and one interaction), and finally report all
models in a single table and select a preferred model.
The full Million Song Dataset (MSD) is loaded, and a random subset of
20,000 songs is drawn. The subset is split 50/50 into
training_data (used for model training in this section) and
test_data (held out for model validation later in the A2
pipeline).
# Load the full MSD (object name: MSD)
load("MSD.RData")
# Draw a reproducible random subset of 20,000 songs
set.seed(2204)
msd_subset <- MSD[sample(nrow(MSD), 20000), ]
# Split the subset 50/50 into training and test data
train_index <- sample(nrow(msd_subset), 0.5 * nrow(msd_subset))
training_data <- msd_subset[ train_index, ]
test_data <- msd_subset[-train_index, ]
# Recode mode into readable labels; Minor (0) is the reference category
training_data$mode <- factor(training_data$mode, levels = c("0", "1"),
labels = c("Minor", "Major"))
test_data$mode <- factor(test_data$mode, levels = c("0", "1"),
labels = c("Minor", "Major"))
# Free memory: the full MSD is no longer needed
rm(MSD)
The training_data contains 10,000 songs. However, only
3,038 (30.4%) have complete information on all five variables used in
this section. Most of the missingness comes from the output variable
song_hotttnesss (5,444 missing) and from year
(4,873 missing). Because lm() uses listwise deletion by
default, the models below are estimated on the complete cases only; this
issue is addressed in the next stage of the report (missing data).
The initial model predicts song hotness from four input variables:
\[ \widehat{song\_hotttnesss} = \hat{\beta}_0 + \hat{\beta}_1 \cdot tempo + \hat{\beta}_2 \cdot duration + \hat{\beta}_3 \cdot mode_{Major} + \hat{\beta}_4 \cdot year \]
where \(mode_{Major}\) equals 1 for songs in a major key and 0 for songs in a minor key (the reference category).
The input variables were chosen because they can be
practically obtained before a track is released.
duration and year are standard metadata
attached to every digital audio file, so they are available at no cost.
tempo and mode are musical characteristics
that a producer or A&R staff member can determine from the demo
itself, either by ear or with widely available audio software, so they
would also be known when the model is used to screen new tracks.
Variables such as artist_hotttnesss and
artist_familiarity were deliberately
excluded. Although they are strongly correlated with
song_hotttnesss, they are themselves outcome-type measures
that are only known after an artist has an established audience; for a
new artist they would be unknown (or would themselves need to be
predicted). Including them would inflate \(R^2\) during training but make the model
useless for screening new music, and would introduce multicollinearity
with the output. loudness was also excluded because, while
measurable, it depends heavily on mastering decisions made late in
production and requires processing the audio file, so it would not be
reliably available at the demo stage.
m1 <- lm(song_hotttnesss ~ tempo + duration + mode + year,
data = training_data)
Overall significance. The F-statistic is 15.80 on 4 and 3,033 degrees of freedom (p < 0.001), so the model explains significantly more variation in song hotness than an intercept-only model.
Model fit. The adjusted \(R^2\) is 1.91%, meaning the model explains
only 1.91% of the variation in song_hotttnesss. This is
low, which is common for a complex cultural outcome such as popularity,
and it suggests that extensions to the model should be explored.
Input variables.
Missing data. 6,962 of the 10,000 training observations (69.6%) were deleted due to missingness, leaving 3,038 observations. This is a large loss of information and a potential source of bias.
There may be an optimal tempo for a popular song: a song can be too
slow to engage listeners or too fast to be comfortable. To test for this
curvilinear effect, a quadratic tempo term is added with
I().
m2 <- lm(song_hotttnesss ~ tempo + I(tempo^2) + duration + mode + year,
data = training_data)
The quadratic term I(tempo^2) is not significant
(p = 0.175), and the linear tempo term becomes not significant
once the quadratic term is included (p = 0.064). The adjusted
\(R^2\) changes from 1.91% in m1 to
1.94% in m2, a difference of only 0.03 percentage points. Because the
new term is not significant and adds complexity without meaningful
explanatory power, there is no evidence of a tempo “sweet
spot”, and this extension is not retained.
Music tastes evolve over time, so the effect of release year may not be linear. A quadratic year term is added to the initial model.
m3 <- lm(song_hotttnesss ~ tempo + duration + mode + year + I(year^2),
data = training_data)
The quadratic term I(year^2) is significant (p
= 0.001), and the adjusted \(R^2\)
increases from 1.91% (m1) to 2.21% (m3). This extension is therefore
retained.
Turning point. Using the estimates stored in
m3:
\[ \text{Turning point} = -\frac{\hat{\beta}_{year}}{2 \times \hat{\beta}_{year^2}} = -\frac{-0.2577}{2 \times 6.519 \times 10^{-5}} \approx 1977 \]
The turning point of year is at 1977. Because the
quadratic coefficient is positive, the curve is
U-shaped: predicted hotness is lowest for songs
released around 1977, and rises for songs released after that point. For
Lotus Records this means that recent releases enjoy a strong “recency”
advantage in hotness, while the model also predicts higher hotness for
older catalogue songs (pre-1977) — possibly reflecting the enduring
popularity of “classic” tracks that have survived in the catalogue.
However, only 5.8% of the songs used in the model were released before
1980, so the left-hand side of the curve rests on few observations; it
is largely a consequence of the quadratic shape and should not be
over-interpreted (see Figure 2).
Tempo may matter differently for major-key (typically “bright” or
“happy”) songs than for minor-key (typically “dark” or “sad”) songs. An
interaction term between tempo and mode is added to the best model so
far (m3) using the : operator.
m4 <- lm(song_hotttnesss ~ tempo + duration + mode + year + I(year^2) + tempo:mode,
data = training_data)
The interaction term tempo:mode is significant
(p = 0.004), and the adjusted \(R^2\) rises from 2.21% (m3) to 2.44% (m4).
The quadratic year term remains significant (p = 0.003), with a
turning point of 1976, very close to m3.
Interpreting the interaction. Because Minor is the
reference category, the coefficient on tempo is now the
effect of tempo for minor-key songs, and the
interaction coefficient shows how much this effect changes for
major-key songs:
In plain terms: a faster tempo helps minor-key songs, but makes almost no difference for major-key songs. For Lotus Records, an upbeat minor-key demo (e.g. dance or electronic tracks in a minor key) may be more promising than a slow minor-key ballad, whereas for major-key tracks tempo is not a useful screening signal. Note also that the main effect of mode has become significant (p = 0.006); it now represents the difference between major and minor songs at a tempo of 0 BPM, which is not meaningful on its own, so mode should be interpreted together with the interaction.
Table 1 summarises all four models. Standard errors are shown in parentheses.
| m1 | m2 | m3 | m4 | |
|---|---|---|---|---|
| + p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001 | ||||
| Intercept | -3.449533*** | -3.514928*** | 255.146011** | 239.991842** |
| (0.587239) | (0.589131) | (80.709884) | (80.785889) | |
| Tempo (BPM) | 0.000242** | 0.000870+ | 0.000248** | 0.000571*** |
| (0.000083) | (0.000470) | (0.000082) | (0.000139) | |
| Duration (sec) | -0.000091*** | -0.000093*** | -0.000085** | -0.000085** |
| (0.000027) | (0.000027) | (0.000027) | (0.000027) | |
| Major mode | -0.000931 | -0.000919 | -0.000967 | 0.061653** |
| (0.005973) | (0.005972) | (0.005964) | (0.022595) | |
| Year | 0.001965*** | 0.001978*** | -0.257726** | -0.242568** |
| (0.000294) | (0.000294) | (0.081050) | (0.081125) | |
| Tempo² | -0.000002 | |||
| (0.000002) | ||||
| Year² | 0.000065** | 0.000061** | ||
| (0.000020) | (0.000020) | |||
| Tempo × Major mode | -0.000497** | |||
| (0.000173) | ||||
| Num.Obs. | 3038 | 3038 | 3038 | 3038 |
| R2 Adj. | 0.019 | 0.019 | 0.022 | 0.024 |
The preferred model is m4, which has the highest
adjusted \(R^2\) (2.44%) of the four
models. Compared with the initial model (m1), it explains an additional
0.53 percentage points of variation in song_hotttnesss, and
every extension it contains is statistically significant. It remains
parsimonious: it uses the same four practical input
variables as m1, adding only one polynomial term (year²)
and one interaction (tempo × mode), each grounded in a clear theory
(changing music trends over time, and the different emotional character
of major and minor keys). The tempo² term from m2 was
dropped because it did not improve fit, showing that adding complexity
does not guarantee a better model.
Figure 1 shows the tempo × mode interaction from the preferred model, holding duration at its mean and year at its median.
Figure 1. Predicted song hotness by tempo and mode (preferred model)
Figure 2 shows the U-shaped effect of release year, holding tempo and duration at their means for minor-key songs.
Figure 2. Predicted song hotness by release year (preferred model)
tempo and
mode are algorithmic estimates and may contain error, which
tends to weaken estimated relationships.training_data only. The final stage of the A2 pipeline will
use the preferred model to predict song_hotttnesss in the
held-out test_data to assess how well it generalises to
songs it has not seen.