2025-09-22

## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

Introduction

In Astronomy, Astronomers regularly study the relationship between star’s color and its temperature.For us to be able to see this relationship we can use Simple linear regression.

Formulas

\[ y= \beta_0 + \beta_1 x + \epsilon \] Where: - \(y\) = star temperature - \(x\) = color index (B-V) - \(\beta_0\) = intercept - \(\beta_1\) = slope - \(\epsilon\) = error term

Simulated Star Data

For us to be able to test our simple linear regression, we first have to create simulated star data. - 20 stars with random color (B-V, values between 0 and 2) - Temperature that corresponds to the color of stars

##   color_index temperature
## 1   0.5751550    8775.345
## 2   1.5766103    5910.939
## 3   0.8179538    8402.678
## 4   1.7660348    6023.980
## 5   1.8809346    5708.454
## 6   0.0911130   10116.538

Scatter plot:Color vs Temperature

If we plot our simulated stars we would expect a negative relationship an increase of color but a decrease in temerature.

## `geom_smooth()` using formula = 'y ~ x'

Scatter Plot

Simple linear regression results

model = lm(temperature ~ color_index, data=stars)
summary(model)
## 
## Call:
## lm(formula = temperature ~ color_index, data = stars)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1217.9  -234.9   -28.9   235.7  1043.1 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 10120.98     109.56   92.38   <2e-16 ***
## color_index -2569.52      93.71  -27.42   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 426.1 on 58 degrees of freedom
## Multiple R-squared:  0.9284, Adjusted R-squared:  0.9271 
## F-statistic: 751.8 on 1 and 58 DF,  p-value: < 2.2e-16

Summary

As a Astronomical & Planetary Science major I decided to base this assignment off the relationship between Color and Temperature of Stars. We attempted to simulate star data so that we could successfully explore the relationship between Color and Temperature. Our miniature research suggested that stars with higher B-V are redder, meaning they are more cool.Stars with lower B-V are bluer, meaning they are hotter stars.