plot_data_draft <- results |>mutate(Draft_Pos =paste0(Draft_Round,".",Draft_Pos),Draft_Pos =ifelse(Draft_Round =="NA", "NA", Draft_Pos)) |>group_by(Draft_Pos) %>%summarize(mean =mean(Total),sd =sd(Total),min =min(Total),n =n(),max =max(Total)) %>%mutate(#Draft_Pos = factor(Draft_Pos,# levels = c(as.character(1:10),# paste0("PB",1:5))),lb = mean -1.96*sd/sqrt(n), #update later with error cislb =ifelse(lb <=0, 0, lb),ub = mean +1.96*sd/sqrt(n)) p <-ggplot(plot_data_draft, aes(x = Draft_Pos, y = mean, colour = Draft_Pos)) +geom_point() +geom_errorbar(aes(ymin = lb, ymax = ub)) +ylab("Points")ggplotly(p)
Code
plot_data_driver <- results %>%rowwise() %>%mutate(Points =sum(c(Race_Points, Qualifying_Points, Sprint_Points, Sprint_Qualifying),na.rm =TRUE)) %>%group_by(Driver) %>%summarize(mean =mean(Points),sd =sd(Points),min =min(Points),n =n(),max =max(Points)) %>%mutate(sd =ifelse(is.na(sd), 0, sd),lb = mean -1.96*sd/sqrt(n), #update later with error cislb =ifelse(lb <=0, 0, lb),ub = mean +1.96*sd/sqrt(n)) p <-ggplot(plot_data_driver, aes(x = Driver, y = mean, colour = Driver)) +geom_point() +theme(axis.text.x =element_text(angle =45)) +geom_errorbar(aes(ymin = lb, ymax = ub)) +ylab("Points (No Bonus)")ggplotly(p)
Model
[model description by chatGPT (to update), will run model and associated outputs following race 5]
The hierarchical model used in this analysis is structured as follows:
Let \(y_i\) represent the observed data for the \(i\)-th observation, and \(\mu_i\) represent the underlying true value for that observation.
For each observation \(i\) (ranging from 1 to \(N\)), \(\mu_i\) is assumed to follow a normal distribution with mean \(\mu_{\text{group}}[i]\), where \(\mu_{\text{group}}[i]\) is a group-specific mean corresponding to the group of the \(i\)-th observation. The variance of this normal distribution is \(\tau_{\text{group}}[i]\), representing the group-specific variance.
Additionally, the observed data \(y_i\) is assumed to follow a normal distribution with mean \(\mu_i\) and a common variance parameter \(\tau\).
The group-specific means \(\mu_{\text{group}}[i]\) are assumed to follow a normal distribution with mean \(\mu_{\text{prior}}\) and variance \(\tau_{\mu}\).
The hyperparameters \(\sigma\) and \(\sigma_{\mu}\) represent the standard deviations for the common variance \(\tau\) and the group-specific means’ variance \(\tau_{\mu}\) respectively.
The priors for \(\sigma\) and \(sigma_{\mu}\) are specified as uniform distributions between 0 and 100.
The prior for \(\mu_{\text{prior}}\) is assumed to be a normal distribution with mean 0 and a very small variance to reflect little prior information about the group means.
The hierarchical model aims to estimate the group-specific means and variances, as well as the common variance parameter, using the observed data and specified prior distributions.