Sunset from the Overlook Firetower

For many years, I would hike up Overlook Mountain to watch the sunset in December. Most years it would be cloudy or otherwise not peak conditions, but one year I really lucked out.

Taken on Wednesday December 19, 2012 at Overlook Mountain.

I’ve been brushing up on my statistics lately, and realizing it’s kind of important to include on my graphs with linear models the linear equation, p-value and r^2-value

I’ve been brushing up on my statistics lately, and realizing it’s kind of important to include on my graphs with linear models the linear equation, p-value and r^2-value. I was hoping to find a simple R library to produce this text, but I ended up using a StackOverflow answer, along with some R code I wrote myself

get_equation <- function(model) {
  pValue <- paste('p_value=',  format(summary(model)$coefficients[,4], scientific=T), sep='')  
  r2Value <- paste('r^2_value=', round(summary(model)$r.squared,4), sep='') 
  
  formula <- broom::tidy(model)[, 1:2] %>%
    mutate(sign = ifelse(sign(estimate) == 1, '+', '-')) %>% #coeff signs
    mutate_if(is.numeric, ~ abs(round(., 7))) %>% #for improving formatting
    mutate(a = ifelse(term == '(Intercept)', paste0('y=', estimate), paste0(sign, estimate, 'x'))) %>%
    summarise(formula = paste(a, collapse = '')) %>%
    as.character 
  
  paste(formula, pValue, r2Value, sep='n')
}

To add this code to the upper right-hand side of the graph, you can use this code in ggplot2:

annotate('text', x=Inf,y=Inf, hjust=1, vjust=1, label=get_formula(lm(comb$avg ~ comb$Value))[1] ) 

Here is a rather silly example:

Weather Update – December 10, 2021

Looks to be mild the next few days 🌧️

Rainy Saturday ahead though. But then real nice for the work week next week. I might take off Monday and Tuesday after work it should be nice for walking downtown and getting my COVID-19 and tetanus boosters. Wednesday is the work at home day and I’ll probably be aching and sore. But what’s the alternative?

Today.
Feels like …
December 3rd.

Mostly Cloudy

Mostly cloudy.

South wind 6 to 10 mph.

and

42 degrees , 4:22
sunset.
Tonight.
Feels like …
November 13th.

Partly Cloudy then Chance of Rain

A chance of rain, mainly after 5am. Mostly cloudy.

South wind 3 to 7 mph. Chance of precipitation is 30%. New precipitation amounts of less than a tenth of an inch possible.

and

32 degrees , 7:15
sunrise.
Saturday.
Feels like …
October 24th.

Showers

Rain likely before 8am, then showers, mainly after 8am.

South wind 10 to 16 mph, with gusts as high as 26 mph. Chance of precipitation is 80%. New precipitation amounts between a tenth and quarter of an inch possible.

and

58 degrees , 4:22
sunset.
Saturday Night.
Feels like …
October 28th.

Showers and Breezy

Showers and possibly a thunderstorm before 1am, then a slight chance of showers between 1am and 4am.

Breezy, with a south wind 16 to 22 mph becoming west after midnight. Winds could gust as high as 38 mph. Chance of precipitation is 80%. New precipitation amounts of less than a tenth of an inch, except higher amounts possible in thunderstorms.

and

37 degrees , 7:16
sunrise.
Sunday.
Feels like …
November 23rd.

Mostly Sunny

Mostly sunny.

West wind 8 to 14 mph, with gusts as high as 24 mph.

and

46 degrees , 4:22
sunset.
Sunday Night.
Feels like …
November 20th.

Mostly Clear

Mostly clear.

 

and

30 degrees , 7:17
sunrise.
Monday.
Feels like …
November 18th.

Sunny

Sunny.

 

and

48 degrees , 4:22
sunset.
Monday Night.
Feels like …
November 17th.

Partly Cloudy

Partly cloudy.

 

and

31 degrees , 7:17
sunrise.
Tuesday.
Feels like …
November 28th.

Mostly Sunny

Mostly sunny.

 

and

44 degrees , 4:22
sunset.
Tuesday Night.
Feels like …
November 23rd.

Mostly Cloudy

Mostly cloudy.

 

and

29 degrees , 7:18
sunrise.
Wednesday.
Feels like …
November 28th.

Partly Sunny

Partly sunny.

 

and

44 degrees , 4:22
sunset.
Wednesday Night.
Feels like …
October 28th.

Mostly Cloudy

Mostly cloudy.

 

and

37 degrees , 7:19
sunrise.
Thursday.
Feels like …
November 1st.

Mostly Cloudy

Mostly cloudy.

 

and

55 degrees , 4:23
sunset.