The whole world watches the Olympic games, and the winner of every game depends on the country’s athletes. However, Using this data, we can see which countries’ athletes get more Olympic medals, and take the win home and we can see if the athlete previous medals, or age is the reason for that victory.
#| label: setup#| message: falselibrary(brms)
Warning: package 'brms' was built under R version 4.4.1
Loading required package: Rcpp
Loading 'brms' package (version 2.21.0). Useful instructions
can be found by typing help('brms'). A more detailed introduction
to the package is available through vignette('brms_overview').
Attaching package: 'brms'
The following object is masked from 'package:stats':
ar
data <-read.csv("Olympic_Games_Medal_Tally.csv")model <-brm( total ~ gold + silver + bronze,data = data,family =gaussian(), prior =c(set_prior("normal(0, 10)", class ="b"), set_prior("cauchy(0, 2)", class ="Intercept"), set_prior("cauchy(0, 2)", class ="sigma") ),chains =4, iter =2000, warmup =1000, cores =2)
Compiling Stan program...
Start sampling
Warning: There were 1231 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
Warning: There were 3 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
Warning: There were 4 chains where the estimated Bayesian Fraction of Missing Information was low. See
https://mc-stan.org/misc/warnings.html#bfmi-low
Warning: Examine the pairs() plot to diagnose sampling problems
Warning: The largest R-hat is 1.77, indicating chains have not mixed.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#r-hat
Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
summary(model)
Warning: Parts of the model have not converged (some Rhats are > 1.05). Be
careful when analysing the results! We recommend running more iterations and/or
setting stronger priors.
Warning: There were 1231 divergent transitions after warmup. Increasing
adapt_delta above 0.8 may help. See
http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
Family: gaussian
Links: mu = identity; sigma = identity
Formula: total ~ gold + silver + bronze
Data: data (Number of observations: 1807)
Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
total post-warmup draws = 4000
Regression Coefficients:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept 0.00 0.00 -0.00 0.00 1.05 341 417
gold 1.00 0.00 1.00 1.00 1.01 821 782
silver 1.00 0.00 1.00 1.00 1.01 608 935
bronze 1.00 0.00 1.00 1.00 1.02 889 728
Further Distributional Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sigma 0.00 0.00 0.00 0.00 1.77 6 30
Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
and Tail_ESS are effective sample size measures, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).
plot(model)
# Posterior predictive checkspp_check(model)
Using 10 posterior draws for ppc type 'dens_overlay' by default.