Code
# run this line once in the console to get package
# if (!requireNamespace("data4soils", quietly = TRUE)) remotes::install_github("byuidatascience/data4soils")
library(data4soils)March 19, 2001
This project outline and background information have been provided to assist you as you complete your project. You should assume the reader of your work has no knowledge or access to this information.
How much explosive material remains in the soil? The military is concerned about amount of explosives that remain in the soils of training ranges because soldiers are out on the training range and explosive residues are carcinogens (they cause cancer). Collecting a representative sample from the training ranges is difficult to do and researchers are continuing to work on developing, refining, and validating sampling methods. Source
Our work in this project relies on assumptions and use of probability distributions. We will (1) fit probability distributions to data, (2) create simulated samples from those fitted probability distributions, and (3) use the fitted probability distributions to provide probability information about explosive residue in the surface soil of a training range.
The Environment Protection Agency (EPA) specifies regulatory levels of Nitroglycerin concentrations for human heath. For this project, we will use 10 mg/kg1 as the toxicity threshold for surface soil of this training range. Source
There are 4 probability models we’ll be exploring in this project. They are the uniform distribution, the normal distribution, the gamma distribution, and the exponential distribution.
The probability density function for the uniform distribution is
We have seen this probability model before in our Example Project. The probability is the same (uniform) for all measurements between \(a\) and \(b\). The command ?dunif or ?runif in your R console will access the R documentation for the uniform distribution.
The probability density function for the normal distribution is
The probability that measurements are near \(\mu\) is larger than the probability that measurements will be far from \(\mu\). This distribution is symmetric and defined for all values of \(x\) (both positive and negative values are possible). We have seen this probability model before in our Example Project and in Project 2. The command ?dnorm or ?rnorm in your R console will access the R documentation for the normal distribution.
The probability density function for the gamma distribution is
The function \(\Gamma(x)\) is called the gamma function (NOT the gamma distribution). The gamma distribution and the gamma function are different functions. One way to think about the gamma function is a generalization of the factorial to noninteger values. We have seen this probability model before in our Example Project. The command ?dgamma or ?rgamma in your R console will access the R documentation for the gamma distribution. The command ?gamma in your R console will access the R documentation pages about the gamma function.
The probability density function for the exponential distribution is
The exponential distribution is often thought of as a “waiting time” model. The command ?dexp or ?rexp in your R console will access the R documentation for the exponential distribution.
embed-resources: true so your rendered .html inlines all plots — required so the file you upload to Canvas displays your charts. See Quarto Hints for a working YAML template.This code creates a vector called “Ng”. The vector contains the measurements Nitroglycerin (Ng) measured as mg/kg found in 100 soil samples.
?mean in your Console to access the R documentation for the mean() command.?var in your Console to access the R documentation for the var() command.\(f_0(x; a,b) = \frac{1}{b-a}\) with \(-\infty < a < x < b < \infty\) (and 0 otherwise)
This is called the uniform distribution. We have seen this probability model before in our Example Project. Use the command ?dunif or ?runif in your Console to access the R documentation for the uniform distribution. The probability is the same (uniform) for all measurements between \(a\) and \(b\).
\(f_1(x; \mu,\sigma) = \frac{1}{\sqrt{2\pi \sigma^2}}e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}\) with \(\mu > 0\), \(\sigma > 0\), and \(-\infty < x < \infty\)
This is called the normal distribution. We have seen this probability model before in our Example Project and in Project 2. Use the command ?dnorm or ?rnorm in your Console to access the R documentation for the normal distribution distribution. The probability measurements are near \(\mu\) is larger than the probability that measurements will be far from \(\mu\). This distribution is symmetric and defined for all values of \(x\).
\(f_2(x; \alpha,\beta) = \frac{\beta^{\alpha}}{\Gamma(\alpha)}x^{\alpha-1}e^{-\beta x}\) with \(\alpha > 0\), \(\beta >0\), and \(x \geq 0\) (and 0 otherwise)
This is called the gamma distribution. We have seen this probability model before in our Example Project. Use the command ?dgamma or ?rgamma in your Console to access the R documentation for the gamma distribution. The function \(\Gamma(x)\) is call the gamma function (NOT the gamma distribution). The gamma distribution and the gamma function are different functions. One way to think about the gamma function is a generalization of the factorial to noninteger values. Use the command ?gamma in your Console to access the R documentation pages about the gamma function.
\(f_3(x; \lambda) = \lambda e^{-\lambda x}\) with \(\lambda > 0\) and \(x \geq 0\) (and 0 otherwise)
This is called the exponential distribution. Use the command ?dexp or ?rexp in your Console to access the R documentation for the exponential distribution. The exponential distribution is often thought of as a “waiting time” model.
rgamma() and rexp() commands to create simulated samples each of 2500 random measurements one using each of the fitted model \(f_2\) and \(f_3\) (you will have 2 simulated samples one for each fitted model).
Create a new Quarto document.
Answer the question, “What is the amount of explosives in the soil?”
While it is possible to fit all four probability models, to this data, explain why \(f_0\) and \(f_1\) should not be used as models for the amount of Nitroglycerin in the soil in this situation. How are these models inconsistent with the information we see in the the density histogram of the Nitroglycerin data?
Describe in 4-6 sentences how the information (or answer) you get from the data depends on the general model you assume. Use results from your calculations above to illustrate this idea. Why is this an important concept to understand when working with models and data?
Organize your work into a cohesive analysis and submit it to Canvas. Your narrative should stand alone apart from the “project instructions” (meaning your reader should not need the instructions for the project to understand what you are doing or explaining) and separate from the individual Tasks (meaning you should not assume your reader has read any of your previous narratives). It is your job in the narrative to lead your reader from the background and question to given data and 4 general models, fitting those models, and answering a question about the data using those fitted models.
Reflect on your work for this project. At the bottom of your report include the following in a brief (1-2 paragraph) reflection.
This number is a simplified story for illustrative purposes only.↩︎