{"id":3423,"date":"2024-05-19T02:22:21","date_gmt":"2024-05-19T02:22:21","guid":{"rendered":"http:\/\/optimumsportsperformance.com\/blog\/?p=3423"},"modified":"2024-05-19T02:23:17","modified_gmt":"2024-05-19T02:23:17","slug":"estimating-a-standard-deviation-from-a-small-sample","status":"publish","type":"post","link":"https:\/\/optimumsportsperformance.com\/blog\/estimating-a-standard-deviation-from-a-small-sample\/","title":{"rendered":"Estimating a Standard Deviation from a Small Sample"},"content":{"rendered":"<p>I really enjoy Allen Downey&#8217;s work and if you haven&#8217;t checked out his books <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/www.amazon.com\/Think-Bayes-Bayesian-Statistics-Python\/dp\/149208946X\/ref=sr_1_4?crid=3BU8LA07XETYB&amp;dib=eyJ2IjoiMSJ9.wGuY9Yj7Yzu8sZQg-IeoAJqWpZ-T9dJfkKsb8YIqU1CIv89E8p_6Vpywl7_sVuGcNuznD39mGMNqSdyrW6zBsrFyeAvVqmbz4U1e1HM67AltFqHaHpYdBJ7D0Ayyvjb2P2L8dHkuFxyqG0JPFsTjU4kMXLThjVy8oI_q0exN-NZbkSeBOVxzmmBLHcKc8KinzeG3bIFr6goXiXI2SemkbTqv1woKzAWoOXEfqQC8MCs.XyY1YcAyCoDiBBFKVo-K-OzmLKTB1ruAjJcafm6HGoM&amp;dib_tag=se&amp;keywords=allen+downey&amp;qid=1716079703&amp;sprefix=allen+down%2Caps%2C177&amp;sr=8-4\">Think Bayes<\/a><\/span><\/strong>, <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/www.amazon.com\/Probably-Overthinking-Questions-Statistical-Decisions\/dp\/0226822583\/ref=sr_1_1?crid=3BU8LA07XETYB&amp;dib=eyJ2IjoiMSJ9.wGuY9Yj7Yzu8sZQg-IeoAJqWpZ-T9dJfkKsb8YIqU1CIv89E8p_6Vpywl7_sVuGcNuznD39mGMNqSdyrW6zBsrFyeAvVqmbz4U1e1HM67AltFqHaHpYdBJ7D0Ayyvjb2P2L8dHkuFxyqG0JPFsTjU4kMXLThjVy8oI_q0exN-NZbkSeBOVxzmmBLHcKc8KinzeG3bIFr6goXiXI2SemkbTqv1woKzAWoOXEfqQC8MCs.XyY1YcAyCoDiBBFKVo-K-OzmLKTB1ruAjJcafm6HGoM&amp;dib_tag=se&amp;keywords=allen+downey&amp;qid=1716079703&amp;sprefix=allen+down%2Caps%2C177&amp;sr=8-1\">Probably Overthinking It<\/a><\/span><\/strong>, and <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/www.amazon.com\/Modeling-Simulation-Python-Allen-Downey\/dp\/1718502168\/ref=sr_1_5?crid=3BU8LA07XETYB&amp;dib=eyJ2IjoiMSJ9.wGuY9Yj7Yzu8sZQg-IeoAJqWpZ-T9dJfkKsb8YIqU1CIv89E8p_6Vpywl7_sVuGcNuznD39mGMNqSdyrW6zBsrFyeAvVqmbz4U1e1HM67AltFqHaHpYdBJ7D0Ayyvjb2P2L8dHkuFxyqG0JPFsTjU4kMXLThjVy8oI_q0exN-NZbkSeBOVxzmmBLHcKc8KinzeG3bIFr6goXiXI2SemkbTqv1woKzAWoOXEfqQC8MCs.XyY1YcAyCoDiBBFKVo-K-OzmLKTB1ruAjJcafm6HGoM&amp;dib_tag=se&amp;keywords=allen+downey&amp;qid=1716079703&amp;sprefix=allen+down%2Caps%2C177&amp;sr=8-5\">Modeling and Simulation in Python<\/a><\/span><\/strong>, I highly suggest you do so. I can&#8217;t recommend his work enough.<\/p>\n<p>Recently, he&#8217;s been doing this cool thing where he grabs a question from the Reddit Statistics forum and constructs a short blog article on how he might go about solving the problem at hand. You can find all the articles he&#8217;s done to date <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/allendowney.github.io\/DataQnA\/index.html?utm_source=substack&amp;utm_medium=email\">HERE<\/a><\/span><\/strong>. His most recent article was about <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/allendowney.github.io\/DataQnA\/gauss_bayes.html\">estimating the standard deviation form a small sample (n = 6)<\/a><\/span><\/strong>. To solve the individual&#8217;s problem, Allen uses grid approximation, which is a simple and convenient approach to tackling problems using a Bayesian framework. I worked through his Python code but, admittedly, I&#8217;m <em>functional<\/em> in Python but I&#8217;m not the best Pythonista. So, that got me thinking about whether we could solve this in a different way.<\/p>\n<p>I&#8217;ve talked about different approaches, depending on what prior information you have available, to <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/optimumsportsperformance.com\/blog\/bayesian-updating-for-normally-distributed-data-a-few-different-approaches-for-the-normal-normal-conjugate\/\">solving a normal-normal conjugate problem in the past<\/a><\/span><\/strong>. Those approaches were all directed at trying to create an estimate for the mean, while we kept the standard deviation value fixed (known). However, you can solve these equations the other way, holding the mean fixed (known) and attempt to estimate the standard deviation parameter. Like the grid approximation approach Allen used, these approaches are easy to apply (if you are willing to make some assumptions), without having to code your own Markov Chain (like we did when we wrote our own GIBBS Sampler to <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/optimumsportsperformance.com\/blog\/tidyx-episode-103-gibbs-sampling\/\">estimate the mean and standard deviation<\/a><\/span><\/strong> or to perform <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/optimumsportsperformance.com\/blog\/bayesian-simple-linear-regression-by-hand-gibbs-sampler\/\">linear regression<\/a><\/span><\/strong>).<\/p>\n<p>So, let&#8217;s try and tackle this problem in a different way than Allen used. The code will be available in my <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/github.com\/pw2\/Bayesian-estimation-of-an-SD-from-small-samples\/blob\/main\/Bayesian%20estimation%20of%20an%20SD%20from%20small%20samples.R\">GitHub<\/a><\/span><\/strong>.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>The Problem<\/strong><\/span><\/p>\n<p>The question that was posed indicated that the individual had 6 blood samples of potassium level from one person. What they wanted to do was estimate the range of probable values if they were to obtain say 100 or 1000 samples from the same person (without having to draw that much blood).<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>The Data<\/strong><\/span><\/p>\n<p>The observations looked like this:<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\n## Six observations\r\nd &lt;- c(4.0, 3.9, 4.0, 4.0, 4.7, 4.2)\r\n\r\n# place observation info into their own objects\r\nobs_n &lt;- length(d)\r\nobs_df &lt;- obs_n - 1\r\nobs_mu &lt;- mean(d)\r\nobs_sd &lt;- sd(d)\r\n\r\nobs_mu\r\nobs_sd\r\n<\/pre>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.04.32\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3424\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.04.32\u202fPM.png\" alt=\"\" width=\"141\" height=\"98\" \/><\/a> <a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.04.24\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3425\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.04.24\u202fPM-1024x622.png\" alt=\"\" width=\"347\" height=\"211\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.04.24\u202fPM-1024x622.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.04.24\u202fPM-300x182.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.04.24\u202fPM-768x467.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.04.24\u202fPM-624x379.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.04.24\u202fPM.png 1224w\" sizes=\"auto, (max-width: 347px) 100vw, 347px\" \/><\/a><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Prior Mean<\/strong><\/span><\/p>\n<p>First, we will get a prior for the mean of potassium levels in the population. Allen suggested that this is usually reported with 5th to 95th percentile values ranging from 3.5 to 5.4. So, let&#8217;s use those values to determine the prior mean and we will put a prior standard error around that value of 0.6.<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\nlow95 &lt;- 3.5\r\nhigh95 &lt;- 5.4\r\n\r\nprior_mu &lt;- (low95 + high95) \/ 2\r\nprior_se &lt;- 0.6\r\n\r\n# plot prior mu\r\nplot(x = seq(from = 2, to = 7, length.out = 50),\r\n     y = dnorm(x = seq(from = 2, to = 7, length.out = 50), mean = prior_mu, sd = prior_se),\r\n     type = &quot;l&quot;,\r\n     main = &quot;Prior Mu Density&quot;,\r\n     ylab = &quot;PDF&quot;,\r\n     xlab = &quot;Blood Potassium&quot;)\r\n<\/pre>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.08.31\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3426\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.08.31\u202fPM-1024x597.png\" alt=\"\" width=\"524\" height=\"305\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.08.31\u202fPM-1024x597.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.08.31\u202fPM-300x175.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.08.31\u202fPM-768x448.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.08.31\u202fPM-624x364.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.08.31\u202fPM.png 1238w\" sizes=\"auto, (max-width: 524px) 100vw, 524px\" \/><\/a><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Prior Standard Deviation<\/strong><\/span><\/p>\n<p>There are a number of priors that one can use for a standard deviation &#8212; a value that cannot go negative (so bounded at 0) &#8212; such as gamma, exponential, inverse chi-square, etc. To have a good estimate of what the prior standard deviation is we&#8217;d probably need to know something about the blood testing measurement and how noisy it is as well as how much biological variability we&#8217;d expect from test to test, which Allen alluded to in his post. Allen chose to use a Gamma distribution with a shape parameter of 2 and a scale parameter of 0.5. I&#8217;ll use a different approach, but let&#8217;s look at his prior for the standard deviation with an inverse chi-square distribution.<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\n# Downey's example uses a gamma distribution so let's plot that\r\nalpha &lt;- 2\r\nbeta &lt;- 0.5\r\n\r\nplot(x = seq(from = 0.01, to = 5, length.out = 100),\r\n     y = dgamma(x = seq(from = 0.01, to = 5, length.out = 100), shape = alpha, scale = beta),\r\n     type = &quot;l&quot;,\r\n     main = &quot;Prior Sigma Density (Gamma Prior)&quot;,\r\n     ylab = &quot;PDF&quot;,\r\n     xlab = &quot;Sigma for Blood Potassium&quot;)\r\n<\/pre>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.12.40\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3427\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.12.40\u202fPM-1024x582.png\" alt=\"\" width=\"625\" height=\"355\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.12.40\u202fPM-1024x582.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.12.40\u202fPM-300x171.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.12.40\u202fPM-768x437.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.12.40\u202fPM-624x355.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.12.40\u202fPM.png 1242w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Calculate the Posterior SD<\/strong><\/span><\/p>\n<p>Now we get to the problem the individual was asking about &#8212; estimating the standard deviation from a small number of values.As stated above, Allen used grid approximation, so be sure to check out his article on how he did this. Instead, I&#8217;ll use an approach discussed in Chapter 15 of <span style=\"color: #0000ff;\"><strong><a style=\"color: #0000ff;\" href=\"https:\/\/www.amazon.com\/Introduction-Bayesian-Statistics-William-Bolstad\/dp\/1118091566\/ref=sr_1_fkmr0_2?crid=M8RC4VCYF6Z7&amp;dib=eyJ2IjoiMSJ9.IkVlA1uFNME40X7IcpR9kbjeHxeN_LTWFDSGedBu2WvLx3j0sxRH5c6aoKQD8rrN.Ch_kb3aoFoTTqFNg2qvhXrXmLLPUl1Xn__MmO5_OS-A&amp;dib_tag=se&amp;keywords=William+Bolstad+Bayes&amp;qid=1716080502&amp;sprefix=william+bolstad+baye%2Caps%2C175&amp;sr=8-2-fkmr0\">William Bolstad&#8217;s Introduction to Bayesian Statistics, 2nd Ed<\/a><\/strong>.<\/span> We will use an inverse chi-square distribution and multiple it by the sum of squared error value, which represents the sum of squared difference of each observed value to our prior_mu, and take the square root of this product to go from a variance to a standard deviation.<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\n# calculate the sum of squared error for each observation relative to the prior_mu\r\nsse &lt;- sum((d - prior_mu)^2)\r\nsse\r\n\r\nset.seed(333)\r\nposterior_sigma &lt;- mean(sqrt(sse *  1\/rchisq(n = 1000, df = obs_n)))\r\nposterior_sigma\r\n<\/pre>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.30.30\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3428\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.30.30\u202fPM-1024x250.png\" alt=\"\" width=\"625\" height=\"153\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.30.30\u202fPM-1024x250.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.30.30\u202fPM-300x73.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.30.30\u202fPM-768x188.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.30.30\u202fPM-624x152.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.30.30\u202fPM.png 1122w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>The posterior estimate of the standard deviation is 0.485, which is slightly larger than what we observed in the data (obs_sd = 0.29) and a little higher than Allen got with the gamma distribution and grid approximation approach (0.404).<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Posterior Mean<\/strong><\/span><\/p>\n<p>Because Allen used grid approximation, he had a probability mass for each value of mu and sigma, which allowed him to then create simulations to answer the question about what the standard deviation would be estimated to be with 100 or 1000 blood draws. So, I&#8217;ll calculate the posterior mean using the observed data and the prior_mu and prior_se, which we set above.<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\n### Calculate a posterior mean\r\nposterior_mu &lt;- ((1 \/ prior_se^2 * prior_mu) + (1 \/ obs_sd^2 * obs_mu)) \/ ((1\/obs_sd^2) + (1\/prior_se^2))\r\nposterior_se &lt;- sqrt(1 \/ (1\/obs_sd^2 + 1\/prior_se^2))\r\n\r\nposterior_mu\r\nposterior_se\r\n<\/pre>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.34.21\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3429\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.34.21\u202fPM.png\" alt=\"\" width=\"132\" height=\"87\" \/><\/a><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Simulating 100 Samples, Ten Times<br \/>\n<\/strong><\/span><\/p>\n<p>Allen made a nice plot\u00a0 from his grid approximation which showed about 10 different posterior simulations from the 1000 samples. I&#8217;ll try and recreate something similar here.<\/p>\n<p><strong><em>100 Samples<\/em><\/strong><\/p>\n<p>First, I&#8217;ll generate 100 samples using the posterior_mu and posterior_se, for the mean, and the sse and inverse chi-square distribution, for the standard deviation.<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\n## What would we expect the standard deviation to be if we had 100 samples?\r\nset.seed(456)\r\nposterior_mu100 &lt;- rnorm(n = 100, mean = posterior_mu, sd = posterior_se)\r\nposterior_sd100 &lt;- sqrt(sse *  1\/rchisq(n = 100, df = obs_n))\r\n\r\ndf100 &lt;- data.frame(mu = posterior_mu100, sigma = posterior_sd100)\r\n\r\nhead(df100)\r\n<\/pre>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.49.14\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3432\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.49.14\u202fPM.png\" alt=\"\" width=\"236\" height=\"200\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.49.14\u202fPM.png 358w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.49.14\u202fPM-300x255.png 300w\" sizes=\"auto, (max-width: 236px) 100vw, 236px\" \/><\/a><\/p>\n<p>Using this data frame of 100 possible posterior mu and sigma values, we will sample 100 pairs and using each pair run 100 simulations. We do this 10 different times to get ten, 100 simulated posterior mean values.<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\nsim_storage100 &lt;- matrix(data = NA, nrow = 100, ncol = 10)\r\n\r\nfor(i in 1:10){\r\n  \r\n  row_id &lt;- sample(1:nrow(df100), size = 1, replace = TRUE)\r\n  sim_storage100&#x5B;, i] &lt;- rnorm(n = 100, mean = df100&#x5B;row_id, &quot;mu&quot;], sd = df100&#x5B;row_id, &quot;sigma&quot;])\r\n}\r\n\r\nhead(sim_storage100)\r\n<\/pre>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.16\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3433\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.16\u202fPM-1024x516.png\" alt=\"\" width=\"625\" height=\"315\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.16\u202fPM-1024x516.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.16\u202fPM-300x151.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.16\u202fPM-768x387.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.16\u202fPM-624x315.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.16\u202fPM.png 1146w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/p>\n<p>Now let&#8217;s plot the 10 lines!<\/p>\n<p><a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.00\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3434\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.00\u202fPM-1024x892.png\" alt=\"\" width=\"537\" height=\"467\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.00\u202fPM-1024x892.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.00\u202fPM-300x261.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.00\u202fPM-768x669.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.00\u202fPM-624x544.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-6.50.00\u202fPM.png 1058w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/a><\/p>\n<p>Finally, we summarize the simulations in different ways<\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li>\u00a0Get the mean and the standard deviation of each column of 100 simulations<a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.02.50\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3436\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.02.50\u202fPM-1024x204.png\" alt=\"\" width=\"625\" height=\"125\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.02.50\u202fPM-1024x204.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.02.50\u202fPM-300x60.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.02.50\u202fPM-768x153.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.02.50\u202fPM-624x124.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.02.50\u202fPM.png 1384w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><\/li>\n<li>Calculate the Median \u00b1 90% CI for each of the 10 simulations<a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.06.57\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3437\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.06.57\u202fPM-1024x148.png\" alt=\"\" width=\"705\" height=\"102\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.06.57\u202fPM-1024x148.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.06.57\u202fPM-300x43.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.06.57\u202fPM-768x111.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.06.57\u202fPM-624x90.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.06.57\u202fPM.png 1520w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/a><\/li>\n<li>Calculate the Mean of each of the simulations and then calculate Median 90% Credible Interval across those values<br \/>\n<a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.07.52\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3438\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.07.52\u202fPM-1024x119.png\" alt=\"\" width=\"668\" height=\"78\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.07.52\u202fPM-1024x119.png 1024w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.07.52\u202fPM-300x35.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.07.52\u202fPM-768x90.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.07.52\u202fPM-624x73.png 624w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.07.52\u202fPM.png 1424w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/a><\/li>\n<li>Finally, we can calculate the mean of the standard deviation for each of the simulations<a href=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.09.37\u202fPM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3439\" src=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.09.37\u202fPM.png\" alt=\"\" width=\"902\" height=\"82\" srcset=\"https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.09.37\u202fPM.png 902w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.09.37\u202fPM-300x27.png 300w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.09.37\u202fPM-768x70.png 768w, https:\/\/optimumsportsperformance.com\/blog\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-18-at-7.09.37\u202fPM-624x57.png 624w\" sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/a><\/li>\n<\/ol>\n<p>This value is still larger than what we observed with our 6 observations (0.29) but smaller than what we observed from posterior sigma (0.489).<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Wrapping Up<\/strong><\/span><\/p>\n<p>I thought this was a fun problem to try and solve because dealing with small numbers of observations in sport physiology is something that we see often. Knowing about the error measurement of your test may help you estimate, or get closer to, a true value for an individual based on only a few data points. Additionally, under the Bayesian framework, every new observation you make for that individual allows you to update. your prior and move closer to something that is more relevant to their biological nuances. I tried to take a different approach than what Allen did. Estimating the posterior mu and posterior sigma are useful steps that I&#8217;ve worked through before in this blog (and I highly recommend Bolstad&#8217;s book) but simulating the 100 samples, ten times, to attempt to match what Allen got with his grid approximation was new to me. I&#8217;ve never done it that way, so if anyone recognizes any errors or issues please email me. Finally, be sure to check out all of the great resources Allen Downey has been putting out.<\/p>\n<p>If you&#8217;d like the code, it is available on my <strong><span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/github.com\/pw2\/Bayesian-estimation-of-an-SD-from-small-samples\/blob\/main\/Bayesian%20estimation%20of%20an%20SD%20from%20small%20samples.R\">GitHub<\/a><\/span><\/strong>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I really enjoy Allen Downey&#8217;s work and if you haven&#8217;t checked out his books Think Bayes, Probably Overthinking It, and Modeling and Simulation in Python, I highly suggest you do so. I can&#8217;t recommend his work enough. Recently, he&#8217;s been doing this cool thing where he grabs a question from the Reddit Statistics forum and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-3423","post","type-post","status-publish","format-standard","hentry","category-bayesian-model-building"],"_links":{"self":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/3423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/comments?post=3423"}],"version-history":[{"count":2,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/3423\/revisions"}],"predecessor-version":[{"id":3441,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/posts\/3423\/revisions\/3441"}],"wp:attachment":[{"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/media?parent=3423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/categories?post=3423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/optimumsportsperformance.com\/blog\/wp-json\/wp\/v2\/tags?post=3423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}