2025-11-10

Introduction

  • This presentation shows how does a planet’s orbital period relates to its distance from the Sun.
  • This is related to Kepler’s Third Law: The squares of the orbital periods of the planets are directly proportional to the cubes of the semi-major axes of their orbits (T^2 ∝ R^3).
  • We’ll verify this with a log–log linear regression and visualize the Solar System with ggplot2 and a 3D Plotly plot.

Data

  • Loads required R libraries and displays the data as a table.
  • Creates the Solar System dataset with each planet’s distance(AU), orbital period(days), mass(Earth Masses), and radius(km).
    Solar System Planets
    name distance_AU orbital_period_days radius_km mass_earths
    Mercury 0.39 88 2440 0.055
    Venus 0.72 225 6052 0.815
    Earth 1.00 365 6371 1.000
    Mars 1.52 687 3390 0.107
    Jupiter 5.20 4333 69911 317.800
    Saturn 9.58 10759 58232 95.200
    Uranus 19.18 30687 25362 14.500
    Neptune 30.07 60190 24622 17.100

ggplot (log–log regression)

  • Transforms the data using logarithms and fits a linear regression model log(T) vs log(R).
  • Plots the relationship with a regression line and planet labels to visualize Kepler’s Law.

ggplot (diagnostics)

  • Plots residuals versus fitted values from the regression model to check model fit and assumptions.
  • Ensures there’s no strong pattern, confirming a good linear relationship in log–log space.

Plotly 3D: Mass–Radius–Distance

  • Creates an interactive 3D scatter plot of planet mass, radius, and distance from the Sun using Plotly.
  • Lets you rotate and explore planetary relationships in three dimensions.

Inference for the slope

  • Extracts the slope estimate, standard error, p-value, and confidence interval from the regression.
  • Tests whether the slope is approximately 1.5, confirming consistency with Kepler’s Law.
## Estimated slope: 1.5000
## SE(beta1): 0.0015
## t-stat (H0: beta1=1.5): 0.021
## p-value: 0.9837
## 95% CI: [1.4964, 1.5037]

If the 95% CI contains 1.5 and the p-value is large, the data are consistent with Kepler’s law.

Code (reproducible)

  • This slide displays the core R code used to reproduce the analysis of Kepler’s Third Law. It shows how the Solar System data are created, transformed into logarithmic form, and modeled using simple linear regression. -The final lines use ggplot2 to visualize the relationship between log(T) (orbital period) and log(R) (AU), producing the log–log plot seen earlier.
# Build data
planets <- tibble::tibble(
  name = c("Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"),
  distance_AU = c(0.39, 0.72, 1.00, 1.52, 5.20, 9.58, 19.18, 30.07),
  orbital_period_days = c(88, 225, 365, 687, 4333, 10759, 30687, 60190)
)

# Transform + fit model
df <- planets %>% mutate(logT = log10(orbital_period_days),
                         logR = log10(distance_AU))
m <- lm(logT ~ logR, data = df)

# Visualize
ggplot(df, aes(logR, logT)) +
  geom_point() +
  geom_smooth(method = "lm")

Conclusion

  • The log–log regression slope is ~1.5, which matches Kepler’s Third Law.
  • Diagnostics show the linear model is a good approximation on the log scale.
  • 3D Plotly view adds intuition about mass and radius vs distance.