I am not an astronomer, but I find the science fascinating. A public dataset gives me a way to ask questions, draw pictures, and see where my understanding falls short.
Many astronomical relationships are nonlinear. That curiosity helped inspire RainbowStats’ CROSS_SECTION_MODEL: write an equation, estimate its coefficients, and compare the fitted relationship with the observations.
Our question: how much can a star’s temperature tell us about its absolute magnitude?
An exploration by Bill Igoe · RainbowStats · November 2026
The dslabs stars dataset is a teaching compilation of selected stars: 96 rows in the version examined here.
| Column | Meaning |
|---|---|
| star | Star name or identifier |
| magnitude | Absolute magnitude: smaller numbers mean brighter stars |
| temp | Temperature in kelvin |
| type | Spectral classification |
Absolute magnitude compares brightness at a standard distance. The magnitude scale itself is logarithmic.
The package credits multiple open-access VizieR sources. Names repeat; rows are not necessarily distinct, independent stars.
For a star described by an effective temperature, total luminosity follows:
L = 4πR²σT&sup4;
Radius matters as well as temperature. A cool, large star can be very luminous; a small star can be faint despite being hot.
This dataset mixes stellar populations. A single curve cannot be expected to explain them all.
The equation concerns bolometric luminosity. A magnitude measured in a particular band is not automatically bolometric magnitude. Our fitted temperature slope is not a direct test of the fourth-power law.
| Model | Equation | Coefficients |
|---|---|---|
| Linear | m = a + bT | 2 |
| Quadratic | m = a + bT + cT² | 3 |
| Log temperature | m = a + b log10(T) | 2 |
All three use least squares. The last two are curved in temperature but remain linear in their unknown coefficients.
We specify the theory-shaped equation; CROSS_SECTION_MODEL estimates a, b, and, where needed, c.
| Model | R² | Training RMSE | LOOCV RMSE | AIC |
|---|---|---|---|---|
| Linear | 0.401 | 5.662 | 5.752 | 611.34 |
| Quadratic | 0.481 | 5.273 | 5.443 | 599.64 |
| Log temperature | 0.536 | 4.984 | 5.070 | 586.85 |
The logarithmic model performs best on these measures, using one fewer coefficient than the quadratic.
RMSE is in magnitude units; lower is better. LOOCV leaves one row out at a time. AIC balances fit and parameter count.
Recorded from production on November 7, 2026: all 96 rows used, none omitted. This table is a fixed snapshot; the following model summary is computed live. Repeated stars make row-wise validation potentially optimistic.
The quadratic bends upward at the hot end. The logarithmic model keeps declining and fits these observations better overall.
Yet the logarithmic model explains only about 54% of the variation in magnitude. The remaining scatter is part of the scientific question.
Radius, evolutionary stage, composition, and the measurement band can matter. Spectral type alone is not a label for giant, main-sequence star, or white dwarf.
A flexible equation helps us explore a theory. A good fit does not establish that the theory is correct.
These plots place temperature increasing to the right and numeric magnitude increasing upward. That differs from the usual orientation of a Hertzsprung–Russell diagram.
I did not set out to make an astronomical discovery. I wanted to understand what I was looking at.
That led to a useful addition to RainbowStats: write an equation using named data columns, fit it, draw the actual model curve, and examine what remains unexplained.
The same workflow extends beyond astronomy. Multiple columns, transformations, and interactions let us turn proposed relationships into models we can test against data.
The most useful result may be the next question: what information would explain the stars that our curve misses?