From 6ba53b553d17f9a84a07fb21ee572cff6a64659d Mon Sep 17 00:00:00 2001 From: DrLundRasmussen Date: Thu, 13 May 2021 08:36:59 +0200 Subject: [PATCH 1/6] Testing create_seq_bin_part() function --- tests/testthat/test_create_seq_bin_part.R | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/testthat/test_create_seq_bin_part.R diff --git a/tests/testthat/test_create_seq_bin_part.R b/tests/testthat/test_create_seq_bin_part.R new file mode 100644 index 0000000..56d0551 --- /dev/null +++ b/tests/testthat/test_create_seq_bin_part.R @@ -0,0 +1,8 @@ +context("create_seq_bin_part() checks") + +test_that("create_seq_bin_part() states error if non-numerics or multiple values are used", { + + expect_error(create_seq_bin_part("b")) + expect_error(create_seq_bin_part(c(2,3))) + +}) From 3107ee9efbe58798a6f7a2c1ec1c89625c564d7c Mon Sep 17 00:00:00 2001 From: DrLundRasmussen Date: Fri, 14 May 2021 12:52:41 +0200 Subject: [PATCH 2/6] Testing function extract_lm_quantities --- tests/testthat/test_extract_lm_quantities.R | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/testthat/test_extract_lm_quantities.R diff --git a/tests/testthat/test_extract_lm_quantities.R b/tests/testthat/test_extract_lm_quantities.R new file mode 100644 index 0000000..03187d6 --- /dev/null +++ b/tests/testthat/test_extract_lm_quantities.R @@ -0,0 +1,28 @@ +context("extract_lm_quantities() checks") + +x <- runif(10) +y <- 3 * x + 7 + rnorm(10) +example_lm1 <- lm(y ~ x) + +test_that("extract_lm_quantities() correctly throws errors for bad input", { + + expect_error( + extract_lm_quantities(example_lm1, "alpha") + ) + + expect_error( + extract_lm_quantities(y~x, "alpha") + ) + +}) + +test_that("extract_lm_quantities() is a list", { + + expect_output(str(extract_lm_quantities(example_lm1)), "List of 5") + + expect_output(str(extract_lm_quantities(example_lm1)), "List of 5", fixed=T) + +}) + + + From f1be3c6334c400defd59da9420972a98ea485502 Mon Sep 17 00:00:00 2001 From: DrLundRasmussen Date: Wed, 26 May 2021 16:27:27 +0200 Subject: [PATCH 3/6] Started on the vignette based on the package description already made. Having some issues with the use_vignette function, so don't think this is a proper vignette... probably just a markdown. --- Deltacomp vignette.Rmd | 174 ++++++++++++++++++++++ tests/testthat/test_create_seq_bin_part.R | 4 +- 2 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 Deltacomp vignette.Rmd diff --git a/Deltacomp vignette.Rmd b/Deltacomp vignette.Rmd new file mode 100644 index 0000000..940cd13 --- /dev/null +++ b/Deltacomp vignette.Rmd @@ -0,0 +1,174 @@ +--- +title: "Introduction to deltacomp" +author: "Ty Stanford, Charlotte Lund Rasmussen, Dorothea Dumuid" +date: "`r Sys.Date()`" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Vignette Title} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r setup, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +The goal of deltacomp is to provide ready-to-use functions enabling analysis of compositional data and produce predictions for relative increases and decreases in the compositional parts. + +In the following, we provide examples of how to use the package functions `XX` and `XX`, provided in the package. + + +## 1. Background: compositional isotemporal substitution analysis + +For an outcome variable Y, D compositional parts (x_1, ..., x_D) and C covariates (z_1, ..., z_C); this package fits the compositional data analysis model (notation inexact): + +Y = b_0 + b_1 ilr_1 + ... + b_{D-1} ilr_{D-1} + a_1 z_1 + ... + a_C z_C + e + +where ilr_i are the D-1 isometric log ratio variables derived from the D compositional parts (x_1, ..., x_D), b_0, ..., b_{D-1}, a_1, ..., a_C are D+C parameters to be estimated and e ~ N(0, sigma) is the error. The package then makes predictions in alterations of the compositional variables (the linearly dependent set of compositional parts) based on this model. + + +For a starting point to learn about compositional data analysis please see [Aitchison (1982)](https://doi.org/10.1111/j.2517-6161.1982.tb01195.x) or [van den Boogaart and Tolosana-Delgado (2013)](https://link.springer.com/book/10.1007%2F978-3-642-36809-7). + +However the articles [Dumuid et al. (2017a)](https://doi.org/10.1177/0962280217710835), [Dumuid et al. (2017b)](https://doi.org/10.1177%2F0962280217737805), and [Dumuid et al. (2020)](https://doi.org/10.3390/ijerph17072220) may be more approachable introductions both to compositional data analysis and compositional isotemporal substitution analysis. + + +## 2. Datasets in package + +Two datasets are supplied with the package: + +* `fairclough` and +* `fat_data`. + +The `fairclough` dataset was kindly provided by the authors of [Fairclough et al. (2017)](https://doi.org/10.1186/s12966-017-0521-z). `fat_data` is a randomly generated test dataset that might roughly mimic a real dataset. + +## 3. Options for reallocating of time between compositional parts + +The deltacomp package enables either one-to-remaining or one-to-one reallocation between the compositional parts. Both types of time-use reallocations are done proportionally. + +One-from-remaining reallocation allows for time-use exchange between one compositional part and the remaining compositional parts. In the `predict_delta_comps` function, this type of reallocation is chosen when using the `comparisons = "prop-realloc"` option. +For a detailed description of one-to-remaining time-use reallocation, please see [Dumuid et al. (2017a)](https://doi.org/10.1177/0962280217710835) + +One-to-one reallocation enables time-use exchange between two compositional parts. Note that this reallocation can be done independent of the number of parts in the composition. This type of reallocation is chosen when using the `comparisons = "one-v-one"` option of the `predict_delta_comps()` function. +For a detailed description of one-to-one time-use reallocation, please see +[Dumuid et al. (2017b)](https://doi.org/10.1177%2F0962280217737805). + +### 3.1. Example of one-from-remaning realloction (`comparisons = "prop-realloc"` option) + +Suppose you have 3-part composition summing to 1 (e.g. a day) to predict an outcome variable. The three compositonal parts are time spent `active` `sedentary`, and `sleeping`. Let's assume the mean sampled composition is: + +* `active = 0.2` (i.e., 20% a day) +* `sedentary = 0.5` (i.e., 50% a day) +* `sleeping = 0.3` (i.e., 30% a day) + +If you wanted to predict the change in the outcome variable from the above mean composition when `delta = +0.05` (5% of the day) is added to `sedentary`, the option `comparisons = "prop-realloc"` reduces the remaining parts by the 5% proportionately based on their mean values, illustrated below: + +* `sedentary* = 0.5 + delta = 0.5 + 0.05 = 0.55` +* `active* = 0.2 - delta * active / (sleeping + active) = 0.2 - 0.05 * 0.2 / (0.3 + 0.2) = 0.2 - 0.02 = 0.18` +* `sleeping* = 0.3 - delta * sleeping / (sleeping + active) = 0.3 - 0.05 * 0.3 / (0.3 + 0.2) = 0.3 - 0.03 = 0.27` + +By reducing the parts with 5% proportionally, the new composition still sums to 1: `sedentary* + active* + sleeping* = 0.55 + 0.18 + 0.27 = 1`. + +Of note, in the example above, the option `comparisons = "prop-realloc"` in `predict_delta_comps()` will automatically produce separate predictions for a `delta = +0.05` on each of the parts against the remaining parts. I.e. not only the `sedentary* = 0.5 + delta` scenario as illustrated above but also `sleep* = 0.3 + delta` and `active* = 0.2 + delta` cases. + +### 3.2. Example of one-to-one realloction (`comparisons = "one-v-one"` option) + +Similarily to the previous example, suppose you have 3-part composition summing to 1 (e.g. a day) to predict an outcome variable. The three compositonal parts are time spent `active` `sedentary`, and `sleeping`. Let's assume the mean sampled composition is: + +* `active = 0.2` (i.e., 20% a day) +* `sedentary = 0.5` (i.e., 50% a day) +* `sleeping = 0.3` (i.e., 30% a day) + +If you wanted to predict the change in the outcome variable from the above mean composition with `delta = +0.05` (5% of the day), the option `comparisons = "one-v-one"` looks at all pairwise exchanges between the parts `(sedentary*, sleeping*, active*)`: + +* `(0.5 + 0.05, 0.3 - 0.05, 0.2 )` +* `(0.5 + 0.05, 0.3 , 0.2 - 0.05)` +* `(0.5 , 0.3 + 0.05, 0.2 - 0.05)` +* `(0.5 - 0.05, 0.3 + 0.05, 0.2 )` +* `(0.5 - 0.05, 0.3 , 0.2 + 0.05)` +* `(0.5 , 0.3 - 0.05, 0.2 + 0.05)` + + +## 4. Example usage + +```{r} + +library(devtools) # see https://www.r-project.org/nosvn/pandoc/devtools.html +devtools::install_github('tystan/deltacomp') +library(deltacomp) +### see help file to run example +?predict_delta_comps + +#example of one-from-remaining reallocation + +predict_delta_comps( + dataf = fat_data, + y = "fat", + comps = c("sl", "sb", "lpa", "mvpa"), + covars = c("sibs", "parents", "ed"), + deltas = seq(-60, 60, by = 5) / (24 * 60), + comparisons = "prop-realloc", + alpha = 0.05 +) + + +#example of one-to-one reallocation + +predict_delta_comps( + dataf = fat_data, + y = "fat", + comps = c("sl", "sb", "lpa", "mvpa"), + covars = c("sibs", "parents", "ed"), + deltas = seq(-60, 60, by = 5) / (24 * 60), + comparisons = "one-v-one", + alpha = 0.05 +) +``` + + +## 5. Output and plotting results + +Output is a `data.frame` that can be turned into the plot below using the following code. + +```{r} + +pred_df <- + predict_delta_comps( + dataf = fairclough, + y = "z_bmi", + comps = c("sleep", "sed", "lpa", "mvpa"), + covars = c("decimal_age", "sex"), + # careful deltas greater than 25 min in magnitude induce negative compositions + # predict_delta_comps() will warn you about this :-) + deltas = seq(-20, 20, by = 5) / (24 * 60), + comparisons = "prop-realloc", # or try "one-v-one" + alpha = 0.05 + ) + +plot_delta_comp( + pred_df, # provide the returned object from predict_delta_comps() + # x-axis can be converted from propotion of composition to meaningful units + comp_total = 24 * 60, # minutes available in the composition + units_lab = "min" # just a label for plotting +) +``` + + +### 5.1. Prediction for the mean composition + +The function `predict_delta_comps()` now outputs the predicted outcome value (with `100 * (1 - alpha)`% confidence interval). This data is printed to the console but also can be extracted from the output of `predict_delta_comps()` as per the below code: + +```{r} +# produces a 1 line data.frame that contains +# the (simplex/geometric) mean composition, +# the "average" covariates (the median of the factor variables in order of the levels are taken as default), +# the ilr coords of the (simplex/geometric) mean composition, and +# the predicted outcome value with 100*(1-alpha)% confidence interval +attr(pred_df, "mean_pred") + + +``` + + diff --git a/tests/testthat/test_create_seq_bin_part.R b/tests/testthat/test_create_seq_bin_part.R index 56d0551..9a1a3e1 100644 --- a/tests/testthat/test_create_seq_bin_part.R +++ b/tests/testthat/test_create_seq_bin_part.R @@ -1,8 +1,10 @@ context("create_seq_bin_part() checks") -test_that("create_seq_bin_part() states error if non-numerics or multiple values are used", { +test_that("create_seq_bin_part() throws error if wrong inputs", { expect_error(create_seq_bin_part("b")) expect_error(create_seq_bin_part(c(2,3))) }) + + From a42443a3b100c47d1c0cf2eb1895f051221c73f5 Mon Sep 17 00:00:00 2001 From: Charlotte Lund Rasmussen Date: Tue, 1 Jun 2021 11:42:54 +0200 Subject: [PATCH 4/6] Vignette Starting on vignette and editing description --- .RData | Bin 0 -> 2596 bytes DESCRIPTION | 2 + README.md | 152 ++---------------- .../Deltacomp vignette.Rmd | 21 ++- 4 files changed, 25 insertions(+), 150 deletions(-) create mode 100644 .RData rename Deltacomp vignette.Rmd => vignettes/Deltacomp vignette.Rmd (89%) diff --git a/.RData b/.RData new file mode 100644 index 0000000000000000000000000000000000000000..f1ef589b8e5234e71922986b2148157aabc701cf GIT binary patch literal 2596 zcmV+<3fuJ`iwFP!000001_2EU^7T?gSThP(3IG5A0{{d70ssRA00000218IWGBq*) z00aU6000311ON#D000awQekdnZ*4AfWo2Xl000dD00MFV04SpX000XAdLse)+GUd% zkiJ5@W`Xqk#M}3j|6lDQ2?!h|E*p*ul?swObl zZuCwPL7chp1X#<1WTkqpF&KOdFYLc7dMT9-QK76Rc~gSxv6)>w6PQ=?)lWV^)OUD_ zg`8VBYD>B7AG!!7dZ4z{2iNhAtb!v5)v9t)_^`yX_*REqHcnk?nlMy8y3%@C-s#1r zgBu@1wU(yF@CYz(-P+Si*Rb*O1iT*4|58ev{AR2J{9&)?stIM` zbQc_&+naJBVz=!CGq@)S&OlDz52UC&=*p|REq}=@>r>b`=aBHuX9E^V--MB|HCaP_Ky*^LwMOKfJOL+r_Hlj5ns{_4L%Let)9{&-Ji~m3z(Z?R|l=taB5#1XV3wJ7Ty@*VPTYwKCFiS-af!zEi z6zfui+^o&69E^v~AJ=ZS7pX{(Cyh(Cme8q+qmlU3l3^zC7=l4}CM(mDT-kyrPVKZm zbU8PCqbx0G85u-sDNbrn{ixLk6h?1LDwB2`^~9iY2;E~r_HF@}oGox=rL7KR0q=PL z#19KXp97u7VXcdWx1?)M zE$P~u9I~9cPRySxr@r;*?t_dFMiOF^Iwn2hj|jIhGWTAYnL3yV4k`N)4pW(~q%0_E zGu+mqW(iTKwkQMS1Fw=9lo|Zc7`w8-?1S*xm(j#7v&~rW;~{$B)={uv7-_spxjt0x zHkrZ%F=HS;E%Us0@$gXFB>UnSBp+z0QFlz|%r5+zJ2vtm@jU>}zHD@w>kbHVPvyFx z`1Q~anz!t5Jgby4iAd5l$wXjmbxlk($rB(D?3#jT$ARc4E1T?lWqv$?;s$b)Gz)Mo zk-a2nM4C854zZf+`fboN)#bdOeD0Lk7NUZyQoX>%ahE)_K9Z0DG@#55*TI6!kN2l=NOvFS0G^kj#$;!fv z=F;F>!~}d8M2ygxYm=hx4o)bvaG?z1IfuN&1Tiv*9I`AC0C>$ zN};#_@Vi=eNEDE9?^}F0xZf0f&7DF=pHBdAQroZwB=z*|fCh-zl>a)RBtuZ|R}^e| zy&04wxujC%U1{KypuEh?U2LHC!L@?RHel$ugI??_`K>&>E2d6yiirC^eQ zqUnI4LcSDJ!|y0_#8Nukhn3Ll#))jIDTA~&3J4M+aE;*eL;uY5H{jroJa{785y2== z2wn{N%bz@b*t_yd)(Y@PlqN(L4kB1el7BkqB$e>uRSvu`i&+#nUz)<3i%eju*|U6V zAP3MLY{4Qv0ZOQOBr}Wv73jRZzo#6}F3Hp3*m(3uml=X&Hmny>R@&h$Amk>4 zOJO7|b79qMNZo%h2;>;90}D352@S)b8w3TdH-Dm24%?7~mLEAG-wW%q4?Ns>%tZ?F zGz5dl74zF70lO^DT4g#AP}}dzLN0mPPB{)xx9Hq6=wD6NG0wLhHJm^? z(zPC1?62$S3e#=EzMV-eK;OYMM7>6o*35)* zrIIz+tQsF);JtVjp*&X3KfvRCamJ;HuWLd>kijr}%9&XyoZ8FrK*KzRkgICju}Pol z)qp9-LE65MiW{sDHE8|C%0x#OXrnL}aimU#e@J^wi_6`Jno1I@K1q>Z?+=5l z_aub-go3i()RqS&mR3=sAFb9QWdO9a!#u@`ivACkA@+zB{X3?*FLP6*I^4B~f*KNN zKKI}Y%xXytL|}UsjIm5X8zkCb+(gfG8IYM90nDxzB6+-}Z-OmkkTutV9$X-T&jEhX zVUJ7eEfr0vklT9XiG8@I+FxOb*Vhw@jBhl( - %\VignetteIndexEntry{Vignette Title} + %\VignetteIndexEntry{deltacomp vignette} %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} + \usepackage[UTF-8]{inputenc} --- ```{r setup, include = FALSE} @@ -18,7 +18,7 @@ knitr::opts_chunk$set( The goal of deltacomp is to provide ready-to-use functions enabling analysis of compositional data and produce predictions for relative increases and decreases in the compositional parts. -In the following, we provide examples of how to use the package functions `XX` and `XX`, provided in the package. +In the following, we provide examples of how to use the package main functions: `predict_delta_comps` and `plot_delta_comp`. ## 1. Background: compositional isotemporal substitution analysis @@ -34,7 +34,6 @@ For a starting point to learn about compositional data analysis please see [Aitc However the articles [Dumuid et al. (2017a)](https://doi.org/10.1177/0962280217710835), [Dumuid et al. (2017b)](https://doi.org/10.1177%2F0962280217737805), and [Dumuid et al. (2020)](https://doi.org/10.3390/ijerph17072220) may be more approachable introductions both to compositional data analysis and compositional isotemporal substitution analysis. - ## 2. Datasets in package Two datasets are supplied with the package: @@ -149,16 +148,16 @@ pred_df <- plot_delta_comp( pred_df, # provide the returned object from predict_delta_comps() - # x-axis can be converted from propotion of composition to meaningful units comp_total = 24 * 60, # minutes available in the composition units_lab = "min" # just a label for plotting ) ``` - +In this example we choose to to reallocate proportions of the time-use composition in minutes. +However, the x-axis can be converted from proportions of composition to meaningful units. ### 5.1. Prediction for the mean composition -The function `predict_delta_comps()` now outputs the predicted outcome value (with `100 * (1 - alpha)`% confidence interval). This data is printed to the console but also can be extracted from the output of `predict_delta_comps()` as per the below code: +It is possible to extract predictions for the mean composition from the output of `predict_delta_comps()` using the following code: ```{r} # produces a 1 line data.frame that contains @@ -170,5 +169,11 @@ attr(pred_df, "mean_pred") ``` +This will provide a 1 line `data frame` that contains +- the (geometric) mean composition, +- the ilr coordinates of the (geometric) mean composition, +- the "average" covariates (i.e. the median of the factor variables in order of the levels are taken as default), +- the predicted outcome value ("fit") +- the 100*(1-alpha)% confidence intervals related to the predicted outcome ("lwr" and "upr", respetively) From fd29e45753b0e2ebef7274dece38a272f20989ed Mon Sep 17 00:00:00 2001 From: Charlotte Lund Rasmussen Date: Wed, 16 Jun 2021 11:31:57 +0200 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 91b37b8..e2eb59e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ The functions in the `deltacomp` package produce predictions (with confidence intervals) for relative increases and decreases in the compositional parts. -The development of the package was initiated by Ty Stanford and Dorothea Dumuid in 2018 and but is still under development. Major changes and corrections are expected to be made in 2021. +The development of the package was initiated by Ty Stanford and Dorothea Dumuid in 2018 and is still under development. Changes and corrections are expected to be made during 2021. ## Installing `deltacomp` From 28cfbc4cc73ae10e47ed35f05870447752e17293 Mon Sep 17 00:00:00 2001 From: DrLundRasmussen <45944449+DrLundRasmussen@users.noreply.github.com> Date: Wed, 13 Apr 2022 14:02:56 +0200 Subject: [PATCH 6/6] update of vignette --- vignettes/Deltacomp vignette.Rmd | 58 ++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/vignettes/Deltacomp vignette.Rmd b/vignettes/Deltacomp vignette.Rmd index 8db35a0..5a45f85 100644 --- a/vignettes/Deltacomp vignette.Rmd +++ b/vignettes/Deltacomp vignette.Rmd @@ -16,10 +16,13 @@ knitr::opts_chunk$set( ) ``` +_ADD NAME EXPLANATION AND WHY THIS NAME_ +CLR likes this name: codarealloclm (coda = compositional data analysis, reallocation = what where doing, lm = model type) + The goal of deltacomp is to provide ready-to-use functions enabling analysis of compositional data and produce predictions for relative increases and decreases in the compositional parts. -In the following, we provide examples of how to use the package main functions: `predict_delta_comps` and `plot_delta_comp`. +In the following, we provide examples of how to use the package main functions: `predict_delta_comps` and `plot_delta_comp`. ## 1. Background: compositional isotemporal substitution analysis @@ -29,10 +32,9 @@ Y = b_0 + b_1 ilr_1 + ... + b_{D-1} ilr_{D-1} + a_1 z_1 + ... + a_C z_C + e where ilr_i are the D-1 isometric log ratio variables derived from the D compositional parts (x_1, ..., x_D), b_0, ..., b_{D-1}, a_1, ..., a_C are D+C parameters to be estimated and e ~ N(0, sigma) is the error. The package then makes predictions in alterations of the compositional variables (the linearly dependent set of compositional parts) based on this model. - For a starting point to learn about compositional data analysis please see [Aitchison (1982)](https://doi.org/10.1111/j.2517-6161.1982.tb01195.x) or [van den Boogaart and Tolosana-Delgado (2013)](https://link.springer.com/book/10.1007%2F978-3-642-36809-7). -However the articles [Dumuid et al. (2017a)](https://doi.org/10.1177/0962280217710835), [Dumuid et al. (2017b)](https://doi.org/10.1177%2F0962280217737805), and [Dumuid et al. (2020)](https://doi.org/10.3390/ijerph17072220) may be more approachable introductions both to compositional data analysis and compositional isotemporal substitution analysis. +However, the articles [Dumuid et al. (2017a)](https://doi.org/10.1177/0962280217710835), [Dumuid et al. (2017b)](https://doi.org/10.1177%2F0962280217737805), and [Dumuid et al. (2020)](https://doi.org/10.3390/ijerph17072220) may be more approachable introductions both to compositional data analysis and compositional isotemporal substitution analysis. ## 2. Datasets in package @@ -54,6 +56,8 @@ One-to-one reallocation enables time-use exchange between two compositional part For a detailed description of one-to-one time-use reallocation, please see [Dumuid et al. (2017b)](https://doi.org/10.1177%2F0962280217737805). +Note that the `predict_delta_comps()` function removes rows with `NA` values in the input dataset (as warned). + ### 3.1. Example of one-from-remaning realloction (`comparisons = "prop-realloc"` option) Suppose you have 3-part composition summing to 1 (e.g. a day) to predict an outcome variable. The three compositonal parts are time spent `active` `sedentary`, and `sleeping`. Let's assume the mean sampled composition is: @@ -92,13 +96,21 @@ If you wanted to predict the change in the outcome variable from the above mean ## 4. Example usage +The following code will install the package. + ```{r} library(devtools) # see https://www.r-project.org/nosvn/pandoc/devtools.html devtools::install_github('tystan/deltacomp') library(deltacomp) -### see help file to run example -?predict_delta_comps + +``` + + +The following code will run either a one-from-remaining realloction or a one-to-one reallocation. + +```{r} + #example of one-from-remaining reallocation @@ -126,10 +138,17 @@ predict_delta_comps( ) ``` +The following details are provided in the console output: +- quartiles of the summed composition +- details on 'average' case of the considered covariates used for prediction +- ilr transformation of the compositional parts +- summary of linear model results +- results of a statistical test for the ilrs being collectively significant in the model +- details on the input variables considered for the predictions (e.g. geometric mean compostion, 'average' covariates) as well as the predicted outcome variables. ## 5. Output and plotting results -Output is a `data.frame` that can be turned into the plot below using the following code. +Output of the `predict_delta_comp` is a `data.frame` that can be turned into the plot below using the following code. ```{r} @@ -153,27 +172,32 @@ plot_delta_comp( ) ``` In this example we choose to to reallocate proportions of the time-use composition in minutes. -However, the x-axis can be converted from proportions of composition to meaningful units. +However, the x-axis can be converted from proportions of composition to meaningful units. ### 5.1. Prediction for the mean composition -It is possible to extract predictions for the mean composition from the output of `predict_delta_comps()` using the following code: +It is also possible to extract predictions for the mean composition from the output of `predict_delta_comps()` using the following code: ```{r} -# produces a 1 line data.frame that contains -# the (simplex/geometric) mean composition, -# the "average" covariates (the median of the factor variables in order of the levels are taken as default), -# the ilr coords of the (simplex/geometric) mean composition, and -# the predicted outcome value with 100*(1-alpha)% confidence interval attr(pred_df, "mean_pred") - - ``` -This will provide a 1 line `data frame` that contains + +This will provide a one-line `data frame` that contains: - the (geometric) mean composition, - the ilr coordinates of the (geometric) mean composition, - the "average" covariates (i.e. the median of the factor variables in order of the levels are taken as default), - the predicted outcome value ("fit") -- the 100*(1-alpha)% confidence intervals related to the predicted outcome ("lwr" and "upr", respetively) +- the 100*(1-alpha)% confidence intervals related to the predicted outcome ("lwr" and "upr", respectively) + + +## 6. Future extensions + +We envision to build on the work done for developing the `deltacomp` package and aim for future extensions. + +These will include: +- modelling of with log-transformed outcomes +- modelling of binary outcomes +- non-linear modelling, and +- considerations of repeated measurements