Skip to content

Commit

Permalink
Work on #11
Browse files Browse the repository at this point in the history
- Run analysis with `n = 50` for more stable results
- Run analysis for every depth in column 1
  • Loading branch information
Damian-Oswald committed Feb 12, 2024
1 parent 4e17f25 commit 131ba8f
Show file tree
Hide file tree
Showing 9 changed files with 612 additions and 501 deletions.
110 changes: 55 additions & 55 deletions docs/data-preparation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ <h3 data-number="2.2.1" class="anchored" data-anchor-id="what-do-the-various-fun
}
return(results)
}
&lt;bytecode: 0x7fc8f7904440&gt;
&lt;bytecode: 0x7fcfce67aa40&gt;
&lt;environment: namespace:PRE&gt;</code></pre>
</div>
</div>
Expand Down
393 changes: 209 additions & 184 deletions docs/scripts/sensitivity-analysis/output/bulk-density-sensitiviy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"href": "introduction.html#installation-of-the-r-package-pre",
"title": "2  Introduction",
"section": "2.2 Installation of the R package PRE",
"text": "2.2 Installation of the R package PRE\nAll functions that are used repeatedly throughout this projec are implemented in an R package called PRE. The source code of this package is stored in a publically accessible way on GitHub. You can install the package directly from GitHub using the install_github function from the remotes package.\n\ninstall.packages(\"remotes\")\nremotes::install_github(\"https://github.com/Damian-Oswald/PRE\")\n\nAlternatively, you could download the GitHub repository and manually install the PRE package locally. Once the package is installed, you can attach it to the search path in the usual way.\n\nlibrary(PRE)\n\n\n2.2.1 What do the various functions do?\nThe R code shown on this project help page is extremely simplified. If you want want to understand what a specific function of the PRE package does, simple visit the corresponding R help page. For example, you could read on the function crossValidate by using one of the the following commands.\n\nhelp(\"crossValidate\", package = \"PRE\")\n?crossValidate\n\nIf you want to jump really deep into a function, you could print it out in your console.\n\nprint(crossValidate)\n\nfunction (FUN, x, y, k = nrow(x), r = 1, hyperparameter = NULL) \n{\n results &lt;- data.frame()\n for (R in 1:r) {\n I &lt;- matrix(c(sample(1:nrow(x)), rep(NA, k - nrow(x)%%k)), \n ncol = k, byrow = TRUE)\n for (K in 1:k) {\n i &lt;- na.omit(I[, K])\n result &lt;- cbind(cost = FUN(x_train = x[-i, ], y_train = y[-i, \n ], x_test = x[i, ], y_test = y[i, ], hyperparameter = hyperparameter), \n r = R, k = K)\n results &lt;- rbind(results, result)\n }\n }\n return(results)\n}\n&lt;bytecode: 0x7fc8f7904440&gt;\n&lt;environment: namespace:PRE&gt;\n\n\nNote this function source code output is lacking any comments. Those were automatically removed when compiling the R package. To see the commented source code, you’ll have to jump into the package files, or visit the GitHub page. Simply use the following URL:\nhttps://github.com/Damian-Oswald/PRE/blob/main/R/crossValidate.R\nNotice how the base name (the last part of the URL) matches the function name. You can replace that by any function name of your liking."
"text": "2.2 Installation of the R package PRE\nAll functions that are used repeatedly throughout this projec are implemented in an R package called PRE. The source code of this package is stored in a publically accessible way on GitHub. You can install the package directly from GitHub using the install_github function from the remotes package.\n\ninstall.packages(\"remotes\")\nremotes::install_github(\"https://github.com/Damian-Oswald/PRE\")\n\nAlternatively, you could download the GitHub repository and manually install the PRE package locally. Once the package is installed, you can attach it to the search path in the usual way.\n\nlibrary(PRE)\n\n\n2.2.1 What do the various functions do?\nThe R code shown on this project help page is extremely simplified. If you want want to understand what a specific function of the PRE package does, simple visit the corresponding R help page. For example, you could read on the function crossValidate by using one of the the following commands.\n\nhelp(\"crossValidate\", package = \"PRE\")\n?crossValidate\n\nIf you want to jump really deep into a function, you could print it out in your console.\n\nprint(crossValidate)\n\nfunction (FUN, x, y, k = nrow(x), r = 1, hyperparameter = NULL) \n{\n results &lt;- data.frame()\n for (R in 1:r) {\n I &lt;- matrix(c(sample(1:nrow(x)), rep(NA, k - nrow(x)%%k)), \n ncol = k, byrow = TRUE)\n for (K in 1:k) {\n i &lt;- na.omit(I[, K])\n result &lt;- cbind(cost = FUN(x_train = x[-i, ], y_train = y[-i, \n ], x_test = x[i, ], y_test = y[i, ], hyperparameter = hyperparameter), \n r = R, k = K)\n results &lt;- rbind(results, result)\n }\n }\n return(results)\n}\n&lt;bytecode: 0x7fcfce67aa40&gt;\n&lt;environment: namespace:PRE&gt;\n\n\nNote this function source code output is lacking any comments. Those were automatically removed when compiling the R package. To see the commented source code, you’ll have to jump into the package files, or visit the GitHub page. Simply use the following URL:\nhttps://github.com/Damian-Oswald/PRE/blob/main/R/crossValidate.R\nNotice how the base name (the last part of the URL) matches the function name. You can replace that by any function name of your liking."
},
{
"objectID": "data-preparation.html#description-of-the-measurements",
Expand Down Expand Up @@ -116,7 +116,7 @@
"href": "sensitivity-analysis.html#what-effect-does-the-bulk-density-have",
"title": "6  Sensitivity Analysis",
"section": "6.4 What effect does the bulk density have?",
"text": "6.4 What effect does the bulk density have?\nFirst, we’ll determine a range of bulk density to be searched.\nBD &lt;- getParameters()$BD + seq(-0.15, 0.15, 0.05)\nNext, we have to construct a function to return the process estimates for a give bulk density x.\nf &lt;- function(x) {\n parameters &lt;- getParameters(BD = x)\n data &lt;- subset(measurements, column==1) |&gt;\n getN2ON(parameters = parameters) |&gt;\n getMissing() |&gt;\n calculateFluxes(parameters = parameters)\n return(longPRE(data, 1, 7.5, n = 15)$processes)\n}\nFinally, we’ll apply said function to all bulk densities in the vector BD.\nresult &lt;- t(sapply(BD, f))\nThis process will return us the data to be analyzed.\n\n\n\nFigure 6.3: Illustration to the sensitivity of estimated process rates to a change in prior bulk density.\n\n\n\n\n\n\n \nNitrification\nDenitrification\nReduction\n\n\nPredictors\nEstimates\np\nEstimates\np\nEstimates\np\n\n\n(Intercept)\n47.4\n&lt;0.001\n26.7\n&lt;0.001\n-27.6\n&lt;0.001\n\n\nBD\n-20.9\n&lt;0.001\n-4.7\n0.001\n31.3\n&lt;0.001\n\n\nObservations\n7\n7\n7\n\n\nR2 / R2 adjusted\n0.989 / 0.987\n0.919 / 0.903\n0.996 / 0.995\n\n\n\n\n\n\n\n\n\n\nBates, D., M. Mächler, B. Bolker, and S. Walker. 2014. Fitting linear mixed-effects models using lme4. arXiv preprint arXiv:1406.5823.\n\n\nDecock, C., and J. Six. 2013. On the potential of \\(\\delta\\) 18O and \\(\\delta\\) 15N to assess N2O reduction to N2 in soil. European journal of soil science 64:610–620.\n\n\nDenk, T. R., J. Mohn, C. Decock, D. Lewicka-Szczebak, E. Harris, K. Butterbach-Bahl, R. Kiese, and B. Wolf. 2017. The nitrogen cycle: A review of isotope effects and isotope modeling approaches. Soil Biology and Biochemistry 105:121–137.\n\n\nLewicka-Szczebak, D., J. Augustin, A. Giesemann, and R. Well. 2017. Quantifying N₂O reduction to N₂ based on N₂O isotopocules – validation with independent methods (helium incubation and ¹⁵N gas flux method). Biogeosciences 14:711–732.\n\n\nSobol’, I. M. 1990. On sensitivity estimation for nonlinear mathematical models. Matematicheskoe modelirovanie 2:112–118.\n\n\nWell, R., and H. Flessa. 2008. Isotope fractionation factors of N₂O diffusion. Rapid Communications in Mass Spectrometry: An International Journal Devoted to the Rapid Dissemination of Up-to-the-Minute Research in Mass Spectrometry 22:2621–2628.\n\n\nWickham, H. 2011. The split-apply-combine strategy for data analysis. Journal of statistical software 40:1–29."
"text": "6.4 What effect does the bulk density have?\nFirst, we’ll determine a range of bulk density to be searched.\nBD &lt;- getParameters()$BD + seq(-0.15, 0.15, 0.05)\nNext, we have to construct a function to return the process estimates for a give bulk density x.\nf &lt;- function(x) {\n parameters &lt;- getParameters(BD = x)\n data &lt;- subset(measurements, column==1) |&gt;\n getN2ON(parameters = parameters) |&gt;\n getMissing() |&gt;\n calculateFluxes(parameters = parameters)\n return(longPRE(data, 1, 7.5, n = 15)$processes)\n}\nFinally, we’ll apply said function to all bulk densities in the vector BD.\nresult &lt;- t(sapply(BD, f))\nThis process will return us the data to be analyzed.\n\n\n\nFigure 6.3: Illustration to the sensitivity of estimated process rates to a change in prior bulk density.\n\n\nOnce again, we can use the lmer function from the lme4 package to model the process rates as a response of the bulk density as well as a random effect conditional on the depth (Bates et al. 2014).\n\n\n\n\n \nNitrification\nDenitrification\nReduction\n\n\nPredictors\nEstimates\np\nEstimates\np\nEstimates\np\n\n\n(Intercept)\n22.78\n0.008\n-2.57\n0.854\n-53.85\n0.005\n\n\nBD\n-11.61\n0.002\n10.94\n0.162\n48.79\n&lt;0.001\n\n\nRandom Effects\n\n\n\nσ2\n0.02\n0.03\n0.10\n\n\n\nτ00\n295.98 depth\n947.98 depth\n1430.21 depth\n\n\nτ11\n51.58 depth.BD\n280.97 depth.BD\n481.50 depth.BD\n\n\nρ01\n-0.99 depth\n-1.00 depth\n-1.00 depth\n\n\nICC\n1.00\n1.00\n0.99\n\n\nN\n5 depth\n5 depth\n5 depth\n\nObservations\n25\n25\n25\n\n\nMarginal R2 / Conditional R2\n0.023 / 0.999\n0.067 / 0.996\n0.502 / 0.996\n\n\n\n\n\n\n\n\n\nBates, D., M. Mächler, B. Bolker, and S. Walker. 2014. Fitting linear mixed-effects models using lme4. arXiv preprint arXiv:1406.5823.\n\n\nDecock, C., and J. Six. 2013. On the potential of \\(\\delta\\) 18O and \\(\\delta\\) 15N to assess N2O reduction to N2 in soil. European journal of soil science 64:610–620.\n\n\nDenk, T. R., J. Mohn, C. Decock, D. Lewicka-Szczebak, E. Harris, K. Butterbach-Bahl, R. Kiese, and B. Wolf. 2017. The nitrogen cycle: A review of isotope effects and isotope modeling approaches. Soil Biology and Biochemistry 105:121–137.\n\n\nLewicka-Szczebak, D., J. Augustin, A. Giesemann, and R. Well. 2017. Quantifying N₂O reduction to N₂ based on N₂O isotopocules – validation with independent methods (helium incubation and ¹⁵N gas flux method). Biogeosciences 14:711–732.\n\n\nSobol’, I. M. 1990. On sensitivity estimation for nonlinear mathematical models. Matematicheskoe modelirovanie 2:112–118.\n\n\nWell, R., and H. Flessa. 2008. Isotope fractionation factors of N₂O diffusion. Rapid Communications in Mass Spectrometry: An International Journal Devoted to the Rapid Dissemination of Up-to-the-Minute Research in Mass Spectrometry 22:2621–2628.\n\n\nWickham, H. 2011. The split-apply-combine strategy for data analysis. Journal of statistical software 40:1–29."
},
{
"objectID": "references.html",
Expand Down
Loading

0 comments on commit 131ba8f

Please sign in to comment.