R Markdown

All data from the data-frame called ‘cncr’ is pulled from the seer.cancer.gov website; I was not entirely certain how to pull the data as it was only shown to read EXCEL files as .csv type, but nothing otherwise (apologies if it appears sloppy as a consequence).

R Data Frame cncr (2019-2021 is cutoff)

   YrDiagnosis rateper100k lowCI hiCI modrate
1         2000        19.3  19.0 19.5    19.3
2         2001        19.5  19.3 19.8    19.5
3         2002        19.6  19.4 19.9    19.7
4         2003        19.9  19.7 20.2    19.9
5         2004        20.3  20.0 20.5    20.2
6         2005        20.3  20.0 20.5    20.4
7         2006        20.1  19.9 20.3    20.3
8         2007        20.2  20.0 20.5    20.2
9         2008        20.3  20.1 20.5    20.1
10        2009        20.3  20.1 20.5    20.0
11        2010        20.0  19.8 20.3    20.0
12        2011        19.6  19.4 19.8    19.9
13        2012        19.7  19.5 19.9    19.8
14        2013        19.5  19.3 19.7    19.7
15        2014        19.9  19.7 20.1    19.6
16        2015        19.6  19.4 19.8    19.5
17        2016        19.6  19.3 19.8    19.5
18        2017        19.3  19.1 19.5    19.4
19        2018        19.2  19.0 19.4    19.3
20        2019        19.4  19.2 19.6    19.2
21        2020        18.0  17.8 18.2    19.1
22        2021        19.0  18.8 19.2    19.1

How ggplot is generated using this data

test1 <- ggplot(cncr, aes(YrDiagnosis, hiCI)) + geom_point(alpha=0.5) +
  geom_smooth(method="lm", se=F, color="magenta")

ggplot of cncr Data Set: High Confidence Interval (CI) vs. Year Diagnosed

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

ggplot cncr Data Set: Low Confidence Interval (CI) vs. Year Diagnosed

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

ggplot cncr Data Set: Modeled Rate (as a Trend Line) vs. Year Diagnosed

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

ggplotly cncr Data Set: Rate per 100,000 vs. Year Diagnosed

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

Least Squares Linear Regression Formula (simplest form)

LINEAR REGRESSION: \(\hat{y} = b + mx\)

Meaning of variables in Linear Regression Formula

\(b= \bar{y} - b\bar{x}\) and \(m = {\sum(x_i-\bar{x})(y_i-\bar{y}) \over \sum(x_i-\bar{x})^2}\) and \(\bar{x} = {\sum(x) \over n}\) and \(\bar{y} = {\sum(y) \over n}\)