Skip to content

Commit

Permalink
Work on #7
Browse files Browse the repository at this point in the history
- Add stargazer table of linear model results as a preliminary sensitivity analysis.
  • Loading branch information
Damian-Oswald committed Jan 28, 2024
1 parent 8e10276 commit 0de979c
Show file tree
Hide file tree
Showing 7 changed files with 506 additions and 7 deletions.
4 changes: 2 additions & 2 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: 0x7fc96069d240&gt;
&lt;bytecode: 0x7fd974e14a40&gt;
&lt;environment: namespace:PRE&gt;</code></pre>
</div>
</div>
Expand Down
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: 0x7fc96069d240&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: 0x7fd974e14a40&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 @@ -88,7 +88,7 @@
"href": "sensitivity-analysis.html",
"title": "6  Sensitivity Analysis",
"section": "",
"text": "Sensitivity analysis is a method used to determine how different values of an independent variable impact a particular dependent variable under a given set of assumptions. This technique is used in various fields such as finance, engineering, and environmental studies to test the robustness of models against changes in input values. By systematically varying key parameters, sensitivity analysis helps in identifying which variables have the most significant impact on the outcome, aiding in decision-making and risk assessment.\n\n\n\nTable 6.1: Isotope end members values used for modeling gross nitrification derived N2O production, gross denitrification derived N2O production, and gross N2O reduction. Lewicka-Szczebak et al. (2017) originally report \\(\\delta \\ce{^{18} O \\text - N2O} (\\ce{N2O}/\\ce{H2O})\\). When a range is indicated, a random number from the range was selected in each iteration. When an average and standard deviation is indicated, a random value was drawn from the normal distribution in each iteration.\n\n\n\n\n\n\n\n\n\n\nEnd Member\n\nValue [‰]\nValue reference\nSampling\nRange reference\n\n\n\n\neta_SP_diffusion\n\\(\\eta\\: \\text{SP}_\\text{diff.}\\)\n1.55\nWell and Flessa (2008)\n\\(\\sim \\mathcal{N}(1.55, 0.28^2)\\)\nWell and Flessa (2008)\n\n\neta_18O_diffusion\n\\(\\eta\\ce{^{18}O}_\\text{diff.}\\)\n-7.79\nWell and Flessa (2008)\n\\(\\sim \\mathcal{N}(-7.79, 0.27^2)\\)\nWell and Flessa (2008)\n\n\nSP_nitrification\n\\(\\text{SP}_\\text{nit.}\\)\n34.4\nDecock and Six (2013)\n\\(\\sim \\mathcal{U}(26.2, 34.6)\\)\nDenk et al. (2017)\n\n\nd18O_nitrification\n\\(\\delta\\ce{^{18}O_\\text{nit.}}\\)\n36.5\nLewicka-Szczebak et al. (2017)\n\\(\\sim \\mathcal{N}(36.5, 2^2)\\)\n\n\n\nSP_denitrification\n\\(\\text{SP}_\\text{den.}\\)\n-2.4\nDecock and Six (2013)\n\\(\\sim \\mathcal{U}(-2.4, -0.9)\\)\nDenk et al. (2017)\n\n\nd18O_denitrification\n\\(\\delta\\ce{^{18}O_\\text{den.}}\\)\n11.1\nLewicka-Szczebak et al. (2017)\n\\(\\sim \\mathcal{N}(11.1, 2^2)\\)\n\n\n\neta_SP_reduction\n\\(\\eta\\:\\text{SP}_\\text{red.}\\)\n-5.3\nDenk et al. (2017)\n\\(\\sim \\mathcal{U}(-8, -2)\\)\nDenk et al. (2017)\n\n\neta_18O_reduction\n\\(\\eta\\ce{^{18}O_\\text{red.}}\\)\n-16.1\nLewicka-Szczebak et al. (2017)\n\n\n\n\n\n\n\n\nn &lt;- 200\nparameters &lt;- data.frame(eta_SP_diffusion = rnorm(n, 1.55, 0.28),\n eta_18O_diffusion = rnorm(n, -7.79, 0.27),\n SP_nitrification = runif(n, 26.2, 34.6),\n d18O_nitrification = rnorm(n, 36.5, 2),\n SP_denitrification = runif(n, -2.4, -0.9),\n d18O_denitrification = rnorm(n,11.1, 2),\n eta_SP_reduction = runif(n,-8,-2),\n eta_18O_reduction = runif(n,-24,-6))\n\n\n\n\n\nFigure 6.1: Pairwise results of the sensitivity analysis of the isotope end members.\n\n\n\n\n\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\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."
"text": "Sensitivity analysis is a method used to determine how different values of an independent variable impact a particular dependent variable under a given set of assumptions. This technique is used in various fields such as finance, engineering, and environmental studies to test the robustness of models against changes in input values. By systematically varying key parameters, sensitivity analysis helps in identifying which variables have the most significant impact on the outcome, aiding in decision-making and risk assessment.\n\n\n\nTable 6.1: Isotope end members values used for modeling gross nitrification derived N2O production, gross denitrification derived N2O production, and gross N2O reduction. Lewicka-Szczebak et al. (2017) originally report \\(\\delta \\ce{^{18} O \\text - N2O} (\\ce{N2O}/\\ce{H2O})\\). When a range is indicated, a random number from the range was selected in each iteration. When an average and standard deviation is indicated, a random value was drawn from the normal distribution in each iteration.\n\n\n\n\n\n\n\n\n\n\nEnd Member\n\nValue [‰]\nValue reference\nSampling\nRange reference\n\n\n\n\neta_SP_diffusion\n\\(\\eta\\: \\text{SP}_\\text{diff.}\\)\n1.55\nWell and Flessa (2008)\n\\(\\sim \\mathcal{N}(1.55, 0.28^2)\\)\nWell and Flessa (2008)\n\n\neta_18O_diffusion\n\\(\\eta\\ce{^{18}O}_\\text{diff.}\\)\n-7.79\nWell and Flessa (2008)\n\\(\\sim \\mathcal{N}(-7.79, 0.27^2)\\)\nWell and Flessa (2008)\n\n\nSP_nitrification\n\\(\\text{SP}_\\text{nit.}\\)\n34.4\nDecock and Six (2013)\n\\(\\sim \\mathcal{U}(26.2, 34.6)\\)\nDenk et al. (2017)\n\n\nd18O_nitrification\n\\(\\delta\\ce{^{18}O_\\text{nit.}}\\)\n36.5\nLewicka-Szczebak et al. (2017)\n\\(\\sim \\mathcal{N}(36.5, 2^2)\\)\n\n\n\nSP_denitrification\n\\(\\text{SP}_\\text{den.}\\)\n-2.4\nDecock and Six (2013)\n\\(\\sim \\mathcal{U}(-2.4, -0.9)\\)\nDenk et al. (2017)\n\n\nd18O_denitrification\n\\(\\delta\\ce{^{18}O_\\text{den.}}\\)\n11.1\nLewicka-Szczebak et al. (2017)\n\\(\\sim \\mathcal{N}(11.1, 2^2)\\)\n\n\n\neta_SP_reduction\n\\(\\eta\\:\\text{SP}_\\text{red.}\\)\n-5.3\nDenk et al. (2017)\n\\(\\sim \\mathcal{U}(-8, -2)\\)\nDenk et al. (2017)\n\n\neta_18O_reduction\n\\(\\eta\\ce{^{18}O_\\text{red.}}\\)\n-16.1\nLewicka-Szczebak et al. (2017)\n\n\n\n\n\n\n\n\nn &lt;- 200\nparameters &lt;- data.frame(eta_SP_diffusion = rnorm(n, 1.55, 0.28),\n eta_18O_diffusion = rnorm(n, -7.79, 0.27),\n SP_nitrification = runif(n, 26.2, 34.6),\n d18O_nitrification = rnorm(n, 36.5, 2),\n SP_denitrification = runif(n, -2.4, -0.9),\n d18O_denitrification = rnorm(n,11.1, 2),\n eta_SP_reduction = runif(n,-8,-2),\n eta_18O_reduction = runif(n,-24,-6))\n\n\nf &lt;- function(p) {\n x &lt;- PRE(data, 1, 7.5, \"2015-08-27\", n = 20, parameters = do.call(getParameters, as.list(p)))\n apply(x, 2, mean)\n}\n\n\nresults &lt;- t(apply(parameters, 1, f))\n\n\n\n\n\nFigure 6.1: Pairwise results of the sensitivity analysis of the isotope end members.\n\n\n\nSome text before.\n\n\n\n\n\n\n\n\n\n\n\nDependent variable:\n\n\n\n\n\n\n\n\n\n\n\n\nNitrification\n\n\nDenitrification\n\n\nReduction\n\n\n\n\n\n\n(1)\n\n\n(2)\n\n\n(3)\n\n\n\n\n\n\n\n\nSP_nitrification\n\n\n0.157***\n\n\n\n\n\n\n\n\n\n\n(0.014)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSP_denitrification\n\n\n-0.551***\n\n\n\n\n\n\n\n\n\n\n(0.077)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\neta_SP_diffusion\n\n\n\n\n-0.652\n\n\n\n\n\n\n\n\n\n\n(0.465)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nd18O_nitrification\n\n\n\n\n-0.088\n\n\n\n\n\n\n\n\n\n\n(0.058)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nd18O_denitrification\n\n\n0.073***\n\n\n0.431***\n\n\n-0.280***\n\n\n\n\n\n\n(0.017)\n\n\n(0.060)\n\n\n(0.106)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\neta_SP_reduction\n\n\n1.130***\n\n\n-0.135**\n\n\n\n\n\n\n\n\n(0.020)\n\n\n(0.067)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\neta_18O_reduction\n\n\n-0.135***\n\n\n-0.917***\n\n\n0.487***\n\n\n\n\n\n\n(0.007)\n\n\n(0.023)\n\n\n(0.042)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nConstant\n\n\n-7.348***\n\n\n3.642\n\n\n45.322***\n\n\n\n\n\n\n(0.483)\n\n\n(2.341)\n\n\n(1.304)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nObservations\n\n\n200\n\n\n200\n\n\n200\n\n\n\n\nR2\n\n\n0.955\n\n\n0.900\n\n\n0.434\n\n\n\n\nAdjusted R2\n\n\n0.954\n\n\n0.897\n\n\n0.429\n\n\n\n\nResidual Std. Error\n\n\n0.477 (df = 194)\n\n\n1.622 (df = 194)\n\n\n2.937 (df = 197)\n\n\n\n\nF Statistic\n\n\n820.752*** (df = 5; 194)\n\n\n347.543*** (df = 5; 194)\n\n\n75.614*** (df = 2; 197)\n\n\n\n\n\n\n\n\nNote:\n\n\np&lt;0.1; p&lt;0.05; p&lt;0.01\n\n\n\n\n\n\n\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\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."
},
{
"objectID": "references.html",
Expand Down
Loading

0 comments on commit 0de979c

Please sign in to comment.