diff --git a/.Rbuildignore b/.Rbuildignore index 6fdf189..f2cc340 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,12 +1,11 @@ -^renv$ -^renv\.lock$ ^.*\.Rproj$ ^\.Rproj\.user$ -^\.travis\.yml$ -^README\.Rmd$ -^README\.md$ -^NEWS\.md$ -^README-.*\.png$ -^_pkgdown.yml -^docs/ -^docker/ +^renv$ +^renv\.lock$ +README.Rmd +Makefile +LICENSE +^\.github$ +_pkgdown.yml +docs/ +docker/ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/Features.yaml b/.github/workflows/Features.yaml new file mode 100644 index 0000000..c2be57d --- /dev/null +++ b/.github/workflows/Features.yaml @@ -0,0 +1,73 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [feat/**] + paths: [DESCRIPTION, .Rbuildignore, R/**, tests/**, inst/**, .github/**] + + +name: Feature-branch-checks + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: true + matrix: + config: + - {os: ubuntu-latest, r: 'release'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: rcmdcheck, covr, tinytest, lintr, pkgdown + + # - name: Lint + # run: | + # library(tinytest) + # out <- lintr::lint_dir() + # if (0 < length(out)) stop("Linting failure") else print("Linting successful") + # shell: Rscript {0} + + - name: Coverage + run: | + library(tinytest) + roxygen2::roxygenize() + test_covr <- covr::percent_coverage(covr::package_coverage()) + if (test_covr < 90) stop(sprintf("Coverage of %s (<90) too low", lowest_covr_value)) + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_: false + run: | + options(crayon.enabled = TRUE) + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Check if pkgdown site can be build + run: make pkgdown + shell: bash + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..64a0a5c --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,60 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [master, development] + paths: [DESCRIPTION, .Rbuildignore, R/**, tests/**, inst/**, .github/**] + pull_request: + branches: [master, development] + paths: [DESCRIPTION, .Rbuildignore, R/**, tests/**, inst/**, .github/**] + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macOS-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: rcmdcheck + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_: false + run: | + options(crayon.enabled = TRUE) + roxygen2::roxygenize() + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.github/workflows/Test-coverage.yaml b/.github/workflows/Test-coverage.yaml new file mode 100644 index 0000000..385c291 --- /dev/null +++ b/.github/workflows/Test-coverage.yaml @@ -0,0 +1,46 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [master, development] + paths: [DESCRIPTION, .Rbuildignore, R/**, tests/**, inst/**, .github/**] + +name: Test coverage + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: true + matrix: + config: + - {os: ubuntu-latest, r: 'release'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: covr, tinytest + + - name: Coverage + run: | + library(tinytest) + roxygen2::roxygenize() + covr::codecov() + shell: Rscript {0} diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..2d6e98a --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,38 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [development] + +name: pkgdown + +jobs: + pkgdown: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.5.0 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.gitignore b/.gitignore index 7ccd857..89576df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,47 @@ -.Rproj.user +# History files .Rhistory +.Rapp.history + +# Session Data files .RData -.Rprofile -inst/doc -renv/ + +# User-specific files +.Ruserdata + +# Example code in package build process +*-Ex.R + +# Output files from R CMD build +/*.tar.gz + +# Output files from R CMD check +/*.Rcheck/ + +# RStudio files +.Rproj.user/ + +# produced vignettes +vignettes/*.html +vignettes/*.pdf + +# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 +.httr-oauth + +# knitr and R markdown default cache directories +*_cache/ +/cache/ + +# Temporary files created by R markdown +*.utf8.md +*.knit.md + +# R Environment Variables +.Renviron + +# Roxygen generated files +NAMESPACE +man/ + +# pkgdown generated files +docs/ +/docker/.env diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2c99855..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -# https://docs.travis-ci.com/user/languages/r/ - -language: r -sudo: false -warnings_are_errors: false - -r: -- oldrel -- release -- devel - -r_packages: - - covr - -after_success: -- Rscript -e 'covr::codecov()' diff --git a/DESCRIPTION b/DESCRIPTION index c5aea01..3562423 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: simTool Type: Package Title: Conduct Simulation Studies with a Minimal Amount of Source Code -Version: 1.1.7 +Version: 1.1.8 Authors@R: person("Marsel", "Scheer", role = c("aut", "cre"), email = "scheer@freescience.de") Maintainer: Marsel Scheer Description: Tool for statistical simulations that have two components. @@ -28,9 +28,12 @@ Suggests: boot, broom, rmarkdown, - tinytest + tinytest, + lintr, + roxygen2, + covr License: GPL-3 VignetteBuilder: knitr -RoxygenNote: 7.1.1 -URL: https://github.com/MarselScheer/simTool +RoxygenNote: 7.3.2 +URL: https://marselscheer.github.io/simTool/ BugReports: https://github.com/MarselScheer/simTool/issues diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fd44df8 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +SHELL := /bin/bash +PKGNAME=simTool + +help: + -@ echo "R-cmd-check: Builds and checks (--as-cran) the Rpkg" + -@ echo "test: Executes all unit-tests" + -@ echo "coverage: Calculates the test coverage of the unit-test" + -@ echo "lint: Starts linting" + -@ echo "README: Builds README.md" + -@ echo "pkgdown: Builds pkgdown site" + +NAMESPACE: R/* + Rscript -e "roxygen2::roxygenize()" + +R-cmd-check: NAMESPACE + Rscript -e "devtools::check(document=FALSE, args=c('--as-cran'))" + # R CMD build . + # R CMD check --as-cran --no-manual $(PKGNAME)*.tar.gz + # make clean-pkg-build-file + # make clean-cmd-check-files + +clean-pkg-build-file: + rm $(PKGNAME)*tar.gz + +clean-cmd-check-files: + rm -rf $(PKGNAME).Rcheck + +test: NAMESPACE + Rscript -e "pkgload::load_all(); tinytest::test_all()" + +coverage: NAMESPACE + Rscript -e "pkgload::load_all(); covr::package_coverage(type = 'tests')" + +lint: + Rscript -e "library(tinytest); pkgload::load_all(); lintr::lint_package()" + +pkgdown: NAMESPACE + Rscript -e "library(pkgdown); pkgdown::build_site()" + +README: + Rscript -e "pkgload::load_all(); rmarkdown::render(input='README.Rmd', output_format='md_document')" diff --git a/NEWS.md b/NEWS.md index dd69417..4b19ee0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ + +Version 1.1.8 +========================= + +* Upcoming R-version does not allow to apply attr() to primitives to assign values. Fix this by decorating primitives if they are used. + Version 1.1.7 ========================= diff --git a/R/expand_tibble.R b/R/expand_tibble.R index 241dc12..831cdc2 100644 --- a/R/expand_tibble.R +++ b/R/expand_tibble.R @@ -7,7 +7,7 @@ #' @param \dots vectors, factors or a list containing these. #' @return See \code{\link{expand.grid}} but instead of a #' \code{\link{data.frame}} -#' a \code{\link{tibble}} is returned. +#' a \code{\link[tibble:tibble]{tibble}} is returned. #' @author Marsel Scheer #' @seealso \code{\link{expand.grid}} #' @examples diff --git a/R/extract_fun_and_parameter.R b/R/extract_fun_and_parameter.R index 3ba195d..2d8c053 100644 --- a/R/extract_fun_and_parameter.R +++ b/R/extract_fun_and_parameter.R @@ -2,8 +2,17 @@ extract_fun_and_parameter <- function(row, envir) { idx_na <- which(is.na(row)) idx_gt <- which(names(row) == ".truth") + copy_primitives <- function(fun) { + # upcoming R-version will not support attr(fun, "xyz") <- sth if fun is + # a builtin function like mean, min, max, ... + # so we wrap it to have a non-primitive function + if (!is.primitive(fun)) { + return(fun) + } + return(function(...) fun(...)) + } ret <- list( - fun = get(unlist(row[1, 1]), envir = envir), + fun = copy_primitives(fun=get(unlist(row[1, 1]), envir = envir)), para = as.list(row[1, -c(1, idx_na, idx_gt), drop = FALSE]) ) diff --git a/R/print.eval_tibbles.R b/R/print.eval_tibbles.R index 8764486..953d0b2 100644 --- a/R/print.eval_tibbles.R +++ b/R/print.eval_tibbles.R @@ -7,6 +7,7 @@ #' @param ... not used. only necessary to define the function consistently #' with respect to \code{print(x, ...)} #' @author Marsel Scheer +#' @keywords internal #' @export print.eval_tibbles <- function(x, ...) { print(x$simulation) diff --git a/README.Rmd b/README.Rmd index 5bb879f..b019cdf 100644 --- a/README.Rmd +++ b/README.Rmd @@ -12,23 +12,18 @@ knitr::opts_chunk$set( ) ``` -```{r badges, results='asis', echo=FALSE} -suppressPackageStartupMessages(library(badgecreatr)) -acc <- "MarselScheer" -repo <- "simTool" -branch <- "master" -status <- "active" -lifecycle <- "Stable" -badges <- list( - badge_travis(ghaccount = acc, ghrepo = repo, branch = branch), - badge_lifecycle(lifecycle = lifecycle), - badge_projectstatus(status = status), - badge_cran_version_ago(packagename = repo), - badge_cran_downloads(packagename = repo), - badge_license() - ) -cat(paste(badges, collapse = " ")) -``` + +[![R build status](https://github.com/MarselScheer/simTool/workflows/R-CMD-check/badge.svg)](https://github.com/MarselScheer/simTool/actions) +[![Coverage Status](https://img.shields.io/codecov/c/github/MarselScheer/simTool/develop.svg)](https://codecov.io/github/MarselScheer/simTool?branch=develop) +[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html) +[![Project Status: Active – The project has reached a stable, usable +state and is being actively +developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) +[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/simTool)](https://cran.r-project.org/package=simTool) +[![metacran +downloads](https://cranlogs.r-pkg.org/badges/simTool)](https://cran.r-project.org/package=simTool) +[![license](https://img.shields.io/badge/license-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) + # simTool @@ -71,9 +66,7 @@ et You can install simTool from github with: ```{r gh-installation, eval = FALSE} -install.packages("simTool") -# install.packages("devtools") -devtools::install_github("MarselScheer/simTool") +remotes::install_github("MarselScheer/simTool") ``` Or from CRAN with: diff --git a/README.md b/README.md index 4706dfe..d1ee4b9 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ - -[![Build -Status](https://travis-ci.org/MarselScheer/simTool.svg?branch=master)](https://travis-ci.org/MarselScheer/simTool) -[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) +[![R build +status](https://github.com/MarselScheer/simTool/workflows/R-CMD-check/badge.svg)](https://github.com/MarselScheer/simTool/actions) +[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html) [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) -[![CRAN\_Status\_Badge\_version\_ago](https://www.r-pkg.org/badges/version-ago/simTool)](https://cran.r-project.org/package=simTool) +[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/simTool)](https://cran.r-project.org/package=simTool) [![metacran downloads](https://cranlogs.r-pkg.org/badges/simTool)](https://cran.r-project.org/package=simTool) [![license](https://img.shields.io/badge/license-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html) @@ -35,63 +34,52 @@ random variables of size 10, 50, 100, and 1000. Afterwards the *t.test* using confidence levels 0.8, 0.9, 0.95 are applied. This is repeated 1000 times to estimate the coverage: -``` r -library(simTool) -dg <- expand_tibble(fun = "rexp", rate = 10, n = c(10L, 50L, 100L, 1000L)) -pg <- expand_tibble(proc = "t.test", conf.level = c(0.8, 0.9, 0.95)) -et <- eval_tibbles(dg, pg, - ncpus = 4, - replications = 10^3, - post_analyze = function(ttest) tibble::tibble( - coverage = ttest$conf.int[1] <= 1 / 10 && 1 / 10 <= ttest$conf.int[2]), - summary_fun = list(mean = mean) -) -#> | | | 0% | |================== | 25% | |=================================== | 50% | |==================================================== | 75% | |======================================================================| 100% -et -#> # A tibble: 12 x 8 -#> fun rate n replications summary_fun proc conf.level coverage -#> -#> 1 rexp 10 10 1 mean t.test 0.8 0.754 -#> 2 rexp 10 10 1 mean t.test 0.9 0.855 -#> 3 rexp 10 10 1 mean t.test 0.95 0.905 -#> 4 rexp 10 50 1 mean t.test 0.8 0.808 -#> 5 rexp 10 50 1 mean t.test 0.9 0.905 -#> 6 rexp 10 50 1 mean t.test 0.95 0.945 -#> 7 rexp 10 100 1 mean t.test 0.8 0.792 -#> 8 rexp 10 100 1 mean t.test 0.9 0.895 -#> 9 rexp 10 100 1 mean t.test 0.95 0.936 -#> 10 rexp 10 1000 1 mean t.test 0.8 0.796 -#> 11 rexp 10 1000 1 mean t.test 0.9 0.897 -#> 12 rexp 10 1000 1 mean t.test 0.95 0.953 -#> Number of data generating functions: 4 -#> Number of analyzing procedures: 3 -#> Number of replications: 1000 -#> Estimated replications per hour: 614008 -#> Start of the simulation: 2020-09-16 19:53:05 -#> End of the simulation: 2020-09-16 19:53:11 -``` + library(simTool) + dg <- expand_tibble(fun = "rexp", rate = 10, n = c(10L, 50L, 100L, 1000L)) + pg <- expand_tibble(proc = "t.test", conf.level = c(0.8, 0.9, 0.95)) + et <- eval_tibbles(dg, pg, + ncpus = 4, + replications = 10^3, + post_analyze = function(ttest) tibble::tibble( + coverage = ttest$conf.int[1] <= 1 / 10 && 1 / 10 <= ttest$conf.int[2]), + summary_fun = list(mean = mean) + ) + et + #> # A tibble: 12 × 8 + #> fun rate n replications summary_fun proc conf.level coverage + #> + #> 1 rexp 10 10 1 mean t.test 0.8 0.754 + #> 2 rexp 10 10 1 mean t.test 0.9 0.855 + #> 3 rexp 10 10 1 mean t.test 0.95 0.905 + #> 4 rexp 10 50 1 mean t.test 0.8 0.808 + #> 5 rexp 10 50 1 mean t.test 0.9 0.905 + #> 6 rexp 10 50 1 mean t.test 0.95 0.945 + #> 7 rexp 10 100 1 mean t.test 0.8 0.792 + #> 8 rexp 10 100 1 mean t.test 0.9 0.895 + #> 9 rexp 10 100 1 mean t.test 0.95 0.936 + #> 10 rexp 10 1000 1 mean t.test 0.8 0.796 + #> 11 rexp 10 1000 1 mean t.test 0.9 0.897 + #> 12 rexp 10 1000 1 mean t.test 0.95 0.953 + #> Number of data generating functions: 4 + #> Number of analyzing procedures: 3 + #> Number of replications: 1000 + #> Estimated replications per hour: 1318457 + #> Start of the simulation: 2025-04-05 05:37:59.800157 + #> End of the simulation: 2025-04-05 05:38:02.530619 ## Installation You can install simTool from github with: -``` r -install.packages("simTool") -# install.packages("devtools") -devtools::install_github("MarselScheer/simTool") -``` + remotes::install_github("MarselScheer/simTool") Or from CRAN with: -``` r -install.packages("simTool") -``` + install.packages("simTool") ## Test suite With tinytest you can rerun the test for simTool by calling -``` r -# install.packages("tinytest") -tinytest::test_package("simTool") -``` + # install.packages("tinytest") + tinytest::test_package("simTool") diff --git a/_pkgdown.yml b/_pkgdown.yml index cd40c23..1f27537 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,6 +1,7 @@ title: simTool url: http://MarselScheer.github.io/simTool template: + bootstrap: 5 params: bootswatch: flatly diff --git a/docker/Dockerfile b/docker/Dockerfile index df259a9..4e6690f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,21 +1,30 @@ -FROM rocker/verse:4.0.2 +FROM rocker/verse:4.1.0 RUN apt-get update && apt-get install -y \ ranger \ git \ tig \ + htop \ emacs \ +# graphviz necessary for dot-programm for instance used +# by plantuml + graphviz \ # xdg-utils and ff necessary to display -# drake-network-graphs from doom-emacs +# drake-network-graphs from emacs xdg-utils \ firefox \ - && ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime \ - && git config --global user.email "scheer@freescience.de" \ - && git config --global user.name "Marsel Scheer" \ - && mv /root/.gitconfig /home/rstudio \ - && chown rstudio:rstudio /home/rstudio/.gitconfig \ - && usermod --shell /bin/bash rstudio \ -# create directory for mounting the host file system - && su -l rstudio -c "mkdir -p /tmp/hostfs" \ - && su -l rstudio -c "ln -s /tmp/hostfs /home/rstudio/hostfs" \ - && su -l rstudio -c "echo RENV_PATHS_ROOT=~/hostfs/renv/ > /home/rstudio/.Renviron" + && ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime + +USER rstudio +WORKDIR /home/rstudio +RUN mkdir -p /tmp/hostfs \ + && ln -s /tmp/hostfs \ + && ln -s /tmp/hostfs/.emacs.d \ + && ln -s /tmp/hostfs/.gitconfig \ + && ln -s /tmp/hostfs/.ssh \ + && echo "export DISPLAY=:0" > /home/rstudio/.bashrc \ + && echo RENV_PATHS_ROOT=~/hostfs/renv/ > /home/rstudio/.Renviron + +# last command MUST be USER root?!? +# otherwise container will directly stop +USER root diff --git a/docker/Dockerfile.doom b/docker/Dockerfile.doom deleted file mode 100644 index 53102c2..0000000 --- a/docker/Dockerfile.doom +++ /dev/null @@ -1,38 +0,0 @@ -FROM rstudio:4.0.2 - -USER rstudio - -# install and configure doom-emacs -RUN git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d \ - && yes | ~/.emacs.d/bin/doom install \ - && sed -i 's/;;ess/ess/g' ~/.doom.d/init.el \ - && ~/.emacs.d/bin/doom sync - -RUN sed -i "s/display-line-numbers-type t/display-line-numbers-type 'relative/g" ~/.doom.d/config.el \ - && sed -i "s/(setq doom-theme 'doom-one)/(setq doom-theme 'doom-peacock)/g" ~/.doom.d/config.el \ - && echo '(setq-default evil-escape-key-sequence "kj")' >> ~/.doom.d/config.el \ - && echo '(setq confirm-kill-emacs nil)' >> ~/.doom.d/config.el \ -# have no idea why this is the only way -# to add company-dabbrev-code to the -# backend. Just follow https://github.com/emacs-ess/ESS/issues/955 - && echo "(require 'company-dabbrev-code)\n\ -(add-to-list 'company-backends #'company-dabbrev-code)\n\ -(setq company-idle-delay 0)\n\ -(setq company-show-numbers t)\n\ -(after! ess-r-mode\n\ - (set-company-backend! 'ess-r-mode\n\ - '(:separate company-R-library company-R-args company-R-objects company-dabbrev-code)))" >> ~/.doom.d/config.el \ -# set general behaviour like indentation and evaluation - && echo "(after! ess-r-mode\n\ - (progn\n\ - (setq-default ess-style 'RStudio-)\n\ - (setq ess-eval-visibly 't)\n\ - )\n\ - )" >> ~/.doom.d/config.el \ -# set doom key-bindings -## save during insert mode - && echo "(map! :i \"C-x C-s\" #'save-buffer)" >> ~/.doom.d/config.el - -# root at the end is need, otherwise -# container stops directly after start?!? -USER root diff --git a/docker/Makefile b/docker/Makefile new file mode 100644 index 0000000..df2ca58 --- /dev/null +++ b/docker/Makefile @@ -0,0 +1,50 @@ +SHELL := /bin/bash +.ONESHELL: + +PARENT_NAME := sim-tool#$(shell basename $(dir $(PWD))) + +.PHONY: .env +.env: + @echo -------------------- $@ $$(date) -------------------- + echo "PARENT_NAME=$(PARENT_NAME)" > .env + +build-docker-context: + @echo -------------------- $@ $$(date) -------------------- + -rm -rf docker_context + mkdir docker_context + cp -r ide docker_context + echo + echo "Docker context created" + +build-docker: build-docker-context .env + @echo -------------------- $@ $$(date) -------------------- + sudo docker compose -f docker-compose.yaml -p $(PARENT_NAME) build || { exit 1; } + rm -rf docker_context + echo + echo "Docker image build" + +start-docker: .env + @echo -------------------- $@ $$(date) -------------------- + sudo docker compose -f docker-compose.yaml -p $(PARENT_NAME) up -d || { exit 1; } + echo + echo "Docker container is running..." + +shell-docker: + @echo -------------------- $@ $$(date) -------------------- + sudo docker exec -u rstudio -it ide /bin/sh -c "/bin/bash" || { exit 1; } + echo + echo "Docker container is running..." + +root-docker: + @echo -------------------- $@ $$(date) -------------------- + sudo docker exec -u root -it ide /bin/sh -c "/bin/bash" || { exit 1; } + echo + echo "Docker container is running..." + +stop-docker: + @echo -------------------- $@ $$(date) -------------------- + sudo docker compose -f docker-compose.yaml -p $(PARENT_NAME) stop || { exit 1; } + echo + echo "Docker container is stopped" + +rebuild-docker: stop-docker build-docker start-docker diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index 311c86f..0000000 --- a/docker/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -sudo docker build -t rstudio:4.0.2 . diff --git a/docker/build_doom.sh b/docker/build_doom.sh deleted file mode 100755 index 5b9fb79..0000000 --- a/docker/build_doom.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -./build.sh -sudo docker build -t doom_r:4.0.2 -f Dockerfile.doom . diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 0000000..d867a53 --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,38 @@ +services: + ide: + container_name: ide + build: + context: ./docker_context + dockerfile: ide/Dockerfile + args: + DOCKER_BUILDKIT: 1 + USER_ID: 1000 + GROUP_ID: 1000 + BASE_IMAGE: rocker/verse:4 + shm_size: 8gb + volumes: + - /home/m/docker_fs/repos/simTool:/home/rstudio/simTool + - /home/m/docker_fs/repos/orgfiles/:/home/rstudio/docker_fs/repos/orgfiles/ + - /home/m/docker_fs/dots/.emacs.d.lean:/home/rstudio/.emacs.d + - /home/m/docker_fs/dots/.ssh:/home/rstudio/.ssh + - /tmp/.X11-unix:/tmp/.X11-unix + environment: + - DISPLAY=:0 + - RUNNING_HOST=local + - DISABLE_AUTH=true + ports: + - 8787:8787 + ollama: + container_name: ollama + image: ollama/ollama:0.6.4 + ports: + - 11434:11434 + volumes: + - /home/m/docker_fs/ollama-cache:/root/.ollama + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] diff --git a/docker/ide/Dockerfile b/docker/ide/Dockerfile new file mode 100644 index 0000000..da007fa --- /dev/null +++ b/docker/ide/Dockerfile @@ -0,0 +1,31 @@ +ARG BASE_IMAGE= +FROM ${BASE_IMAGE} + +ARG USER_ID= +ARG GROUP_ID= + +RUN apt-get update && apt-get install -y \ + ranger \ + git \ + tig \ + htop \ + emacs \ +# graphviz necessary for dot-programm for instance used +# by plantuml + graphviz \ +# xdg-utils and ff necessary to display +# drake-network-graphs from emacs + xdg-utils \ + firefox \ + && ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime + +USER rstudio +WORKDIR /home/rstudio + +RUN git config --global user.email "scheer@freescience.de" \ + && git config --global user.name "Marsel Scheer" +# last command MUST be USER root?!? +# otherwise container RStudio is not available +USER root + + diff --git a/docker/start.sh b/docker/start.sh deleted file mode 100755 index 1aeabde..0000000 --- a/docker/start.sh +++ /dev/null @@ -1,5 +0,0 @@ -sudo docker run --rm -d -p 8787:8787 -e DISABLE_AUTH=true \ - -v ~/docker_fs:/tmp/hostfs \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - rstudio:4.0.2 - diff --git a/docker/start_doom.sh b/docker/start_doom.sh deleted file mode 100755 index 1b2e4a1..0000000 --- a/docker/start_doom.sh +++ /dev/null @@ -1,15 +0,0 @@ -sudo docker run --rm -d -p 8787:8787 -e DISABLE_AUTH=true \ - -v ~/docker_fs:/tmp/hostfs \ - -v /tmp/.X11-unix:/tmp/.X11-unix \ - doom_r:4.0.2 - -# in order to display doom-emacs on the host: -# echo $DISPLAY -# xhost +local:'containerID' -# docker exec -it containerID /bin/bash -# su -l rstudio -# export DISPLAY= -# emacs - - - diff --git a/docs/404.html b/docs/404.html deleted file mode 100644 index e1c703d..0000000 --- a/docs/404.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - -Page not found (404) • simTool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- -
-
- - -Content not found. Please use links in the navbar. - -
- - - -
- - - -
- - -
-

Site built with pkgdown 1.5.1.

-
- -
-
- - - - - - - - diff --git a/docs/articles/index.html b/docs/articles/index.html deleted file mode 100644 index dc0990f..0000000 --- a/docs/articles/index.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - -Articles • simTool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- -
-
- - -
-

All vignettes

-

- -
-
The simTool package: Facilitate simulations
-
-
-
-
-
- - -
- - -
-

Site built with pkgdown 1.5.1.

-
- -
-
- - - - - - - - diff --git a/docs/articles/simTool.html b/docs/articles/simTool.html deleted file mode 100644 index 2c4af71..0000000 --- a/docs/articles/simTool.html +++ /dev/null @@ -1,941 +0,0 @@ - - - - - - - -The simTool package: Facilitate simulations • simTool - - - - - - - - - - -
-
- - - - -
-
- - - - - -
-

-A first example

-
    -
  1. Generate data
  2. -
  3. Fit different models
  4. -
  5. Repeat step 1 and 2 three times
  6. -
  7. Summarize the results with respect to the different data generating functions and models by calculating mean and standard deviation for the corresponding model terms
  8. -
-
regData <- function(n, SD) {
-  x <- seq(0, 1, length = n)
-  y <- 10 + 2 * x + rnorm(n, sd = SD)
-  tibble(x = x, y = y)
-}
-
-eval_tibbles(
-  expand_tibble(fun = "regData", n = 5L, SD = 1:2),
-  expand_tibble(proc = "lm", formula = c("y~x", "y~I(x^2)")),
-  post_analyze = broom::tidy,
-  summary_fun = list(mean = mean, sd = sd),
-  group_for_summary = "term",
-  replications = 3
-)
-
# A tibble: 16 x 12
-   fun       n    SD replications summary_fun proc  formula term  estimate std.error statistic
-   <chr> <int> <int>        <int> <chr>       <chr> <chr>   <chr>    <dbl>     <dbl>     <dbl>
- 1 regD…     5     1            1 mean        lm    y~x     (Int…   10.1      0.692     16.5  
- 2 regD…     5     1            1 mean        lm    y~x     x        2.92     1.13       3.59 
- 3 regD…     5     1            1 mean        lm    y~I(x^… (Int…   10.5      0.544     20.2  
- 4 regD…     5     1            1 mean        lm    y~I(x^… I(x^…    2.71     1.04       3.20 
- 5 regD…     5     1            1 sd          lm    y~x     (Int…    1.45     0.288      6.89 
- 6 regD…     5     1            1 sd          lm    y~x     x        1.84     0.471      3.71 
- 7 regD…     5     1            1 sd          lm    y~I(x^… (Int…    1.32     0.185      4.38 
- 8 regD…     5     1            1 sd          lm    y~I(x^… I(x^…    2.15     0.352      2.62 
- 9 regD…     5     2            1 mean        lm    y~x     (Int…    9.86     1.26       7.85 
-10 regD…     5     2            1 mean        lm    y~x     x        3.42     2.05       1.66 
-11 regD…     5     2            1 mean        lm    y~I(x^… (Int…   10.6      1.18       8.99 
-12 regD…     5     2            1 mean        lm    y~I(x^… I(x^…    2.65     2.24       1.17 
-13 regD…     5     2            1 sd          lm    y~x     (Int…    0.209    0.0374     0.393
-14 regD…     5     2            1 sd          lm    y~x     x        1.17     0.0610     0.515
-15 regD…     5     2            1 sd          lm    y~I(x^… (Int…    0.128    0.0488     0.436
-16 regD…     5     2            1 sd          lm    y~I(x^… I(x^…    1.32     0.0927     0.542
-# … with 1 more variable: p.value <dbl>
-Number of data generating functions: 2
-Number of analyzing procedures: 2
-Number of replications: 3
-Estimated replications per hour: 66584
-Start of the simulation: 2020-09-23 18:15:30
-End of the simulation: 2020-09-23 18:15:30
-
-
-

-Introduction

-

The purpose of the simTool package is to disengage the research from any kind of administrative source code which is usually an annoying necessity of a simulation study.

-

This vignette will give an introduction into the simTool package mainly by examples of growing complexity. The workhorse is the function eval_tibbles. Every parameter of this function will be discussed briefly and the functionality is illustrated by at least one example.

-
-
-

-Workflow

-

The workflow is quite easy and natural. One defines two data.frames (or tibbles), the first one represents the functions that generate the data sets and the second one represents the functions that analyze the data. These two data.frames are passed to eval_tibbles which conducts the simulation. Afterwards, the results can nicely be displayed as a data.frame.

-
-
-

-Defining the data.frames for data generation and analysis

-

There are 3 rules:

-
    -
  • the first column ( a character vector) defines the functions to be called
  • -
  • the other columns are the parameters that are passed to function specified in the first column
  • -
  • The entry NA will not be passed to the function specified in the first column.
  • -
-

The function expand_tibble is a convenient function for defining such data.frames.

-

We now define the data generation functions for our first simulation.

-
print(dg <- dplyr::bind_rows(
-  expand_tibble(fun = "rexp", n = c(10L, 20L), rate = 1:2),
-  expand_tibble(fun = "rnorm", n = c(10L, 20L), mean = 1:2)
-))
-
# A tibble: 8 x 4
-  fun       n  rate  mean
-  <chr> <int> <int> <int>
-1 rexp     10     1    NA
-2 rexp     20     1    NA
-3 rexp     10     2    NA
-4 rexp     20     2    NA
-5 rnorm    10    NA     1
-6 rnorm    20    NA     1
-7 rnorm    10    NA     2
-8 rnorm    20    NA     2
-

This data.frame represents 8 R-functions. For instance, the second row represents a function that generates 20 exponential distributed random variables with rate 1. Since mean=NA in the second row, this parameter is not passed to rexp.

-

Similar, we define the data.frame for data analyzing functions.

-
print(pg <- dplyr::bind_rows(
-  expand_tibble(proc = "min"),
-  expand_tibble(proc = "mean", trim = c(0.1, 0.2))
-))
-
# A tibble: 3 x 2
-  proc   trim
-  <chr> <dbl>
-1 min    NA  
-2 mean    0.1
-3 mean    0.2
-

Hence, this data.frame represents 3 R-functions i.e. calculating the minimum and the arithmetic mean with trim=0.1 and trim=0.2.

-
-
-

-The workhorse eval_tibbles -

-

The workhorse eval_tibbles has the following simplified pseudo code:

-
1.  convert dg to R-functions  {g_1, ..., g_k} 
-2.  convert pg to R-functions  {f_1, ..., f_L} 
-3.  initialize result object 
-4.  append dg and pg to the result object 
-5.  t1 = current.time() 
-6.  for g in  {g_1, ..., g_k} 
-7.      for r in 1:replications (optionally in a parallel manner) 
-8.          data = g() 
-9.          for f in  {f_1, \ldots, f_L} 
-10.             append f(data) to the result object (optionally apply a post-analyze-function)
-11.         optionally append data to the result object 
-12.      optionally summarize the result object over all  
-         replications but separately for f_1, ..., f_L (and optional group variables)
-13. t2 = current.time() 
-14. Estimate the number of replications per hour from t1 and t2 
-

The object returned by eval_tibbles is a list of class eval_tibbles.

-
dg <- expand_tibble(fun = "rnorm", n = 10, mean = 1:2)
-pg <- expand_tibble(proc = "min")
-eg <- eval_tibbles(data_grid = dg, proc_grid = pg, replications = 2)
-eg
-
# A tibble: 4 x 6
-  fun       n  mean replications proc  results
-  <chr> <dbl> <int>        <int> <chr>   <dbl>
-1 rnorm    10     1            1 min    -1.75 
-2 rnorm    10     1            2 min    -0.212
-3 rnorm    10     2            1 min     0.232
-4 rnorm    10     2            2 min     1.16 
-Number of data generating functions: 2
-Number of analyzing procedures: 1
-Number of replications: 2
-Estimated replications per hour: 51446318
-Start of the simulation: 2020-09-23 18:15:31
-End of the simulation: 2020-09-23 18:15:31
-

As you can see, the function always estimates the number of replications that can be done in one hour.

-
-

-Parameter replications -

-

Of course, this parameter controls the number of replications conducted.

-
eg <- eval_tibbles(data_grid = dg, proc_grid = pg, replications = 3)
-eg
-
# A tibble: 6 x 6
-  fun       n  mean replications proc  results
-  <chr> <dbl> <int>        <int> <chr>   <dbl>
-1 rnorm    10     1            1 min    -1.30 
-2 rnorm    10     1            2 min    -0.574
-3 rnorm    10     1            3 min     0.503
-4 rnorm    10     2            1 min     0.729
-5 rnorm    10     2            2 min     1.06 
-6 rnorm    10     2            3 min    -0.272
-Number of data generating functions: 2
-Number of analyzing procedures: 1
-Number of replications: 3
-Estimated replications per hour: 56693971
-Start of the simulation: 2020-09-23 18:15:31
-End of the simulation: 2020-09-23 18:15:31
-
-
-

-Parameter discard_generated_data -

-

eval_tibbles saves ALL generated data sets.

-
eg <- eval_tibbles(data_grid = dg, proc_grid = pg, replications = 1)
-eg$simulation
-
# A tibble: 2 x 6
-  fun       n  mean replications proc   results
-  <chr> <dbl> <int>        <int> <chr>    <dbl>
-1 rnorm    10     1            1 min   -0.554  
-2 rnorm    10     2            1 min    0.00499
-
eg$generated_data
-
[[1]]
- [1]  1.04382239 -0.02157836  1.79342772  1.50162446 -0.55447035  1.88349784  0.79223220  2.83137401
- [9]  1.17726438  0.19415935
-
-[[2]]
- [1] 3.947932470 2.121197052 1.645050873 3.052866250 3.163113962 1.201167182 2.775455294 0.004992648
- [9] 1.649437807 2.380864742
-

In general, it is sometimes very handy to have the data sets in order to investigate unusual or unexpected results. But saving the generated data sets can be very memory consuming. Stop saving the generated data sets can be obtained by setting discardGeneratedData = TRUE. See command line 11 in the pseudo code.

-
-
-

-Parameter summary_fun -

-

As stated in command line 12 we can summarize the result objects over all replications but separately for all data analyzing functions.

-
dg <- expand_tibble(fun = "runif", n = c(10, 20, 30))
-pg <- expand_tibble(proc = c("min", "max"))
-eval_tibbles(
-  data_grid = dg, proc_grid = pg, replications = 1000,
-  summary_fun = list(mean = mean)
-)
-
# A tibble: 6 x 6
-  fun       n replications summary_fun proc   value
-  <chr> <dbl>        <int> <chr>       <chr>  <dbl>
-1 runif    10            1 mean        min   0.0904
-2 runif    10            1 mean        max   0.910 
-3 runif    20            1 mean        min   0.0486
-4 runif    20            1 mean        max   0.953 
-5 runif    30            1 mean        min   0.0314
-6 runif    30            1 mean        max   0.967 
-Number of data generating functions: 3
-Number of analyzing procedures: 2
-Number of replications: 1000
-Estimated replications per hour: 22712598
-Start of the simulation: 2020-09-23 18:15:31
-End of the simulation: 2020-09-23 18:15:31
-
eval_tibbles(
-  data_grid = dg, proc_grid = pg, replications = 1000,
-  summary_fun = list(mean = mean, sd = sd)
-)
-
# A tibble: 12 x 6
-   fun       n replications summary_fun proc   value
-   <chr> <dbl>        <int> <chr>       <chr>  <dbl>
- 1 runif    10            1 mean        min   0.0930
- 2 runif    10            1 mean        max   0.907 
- 3 runif    10            1 sd          min   0.0865
- 4 runif    10            1 sd          max   0.0860
- 5 runif    20            1 mean        min   0.0463
- 6 runif    20            1 mean        max   0.952 
- 7 runif    20            1 sd          min   0.0425
- 8 runif    20            1 sd          max   0.0468
- 9 runif    30            1 mean        min   0.0325
-10 runif    30            1 mean        max   0.966 
-11 runif    30            1 sd          min   0.0323
-12 runif    30            1 sd          max   0.0311
-Number of data generating functions: 3
-Number of analyzing procedures: 2
-Number of replications: 1000
-Estimated replications per hour: 22522507
-Start of the simulation: 2020-09-23 18:15:31
-End of the simulation: 2020-09-23 18:15:31
-

Note, by specifying the parameter summary_fun the generated data sets and all individual result objects are discarded. In this example we discard \(3 \times 1000\) data sets and \(3 \times 1000 \times 2\) individual result objects.

-
-
-

-Parameter post_analyze -

-

Sometimes the analyzing functions return quite complicated objects like in the Section A first example.

-
eval_tibbles(
-  expand_tibble(fun = "regData", n = 5L, SD = 1:2),
-  expand_tibble(proc = "lm", formula = c("y~x", "y~I(x^2)")),
-  replications = 2
-)
-
# A tibble: 8 x 7
-  fun         n    SD replications proc  formula  results
-  <chr>   <int> <int>        <int> <chr> <chr>    <list> 
-1 regData     5     1            1 lm    y~x      <lm>   
-2 regData     5     1            1 lm    y~I(x^2) <lm>   
-3 regData     5     1            2 lm    y~x      <lm>   
-4 regData     5     1            2 lm    y~I(x^2) <lm>   
-5 regData     5     2            1 lm    y~x      <lm>   
-6 regData     5     2            1 lm    y~I(x^2) <lm>   
-7 regData     5     2            2 lm    y~x      <lm>   
-8 regData     5     2            2 lm    y~I(x^2) <lm>   
-Number of data generating functions: 2
-Number of analyzing procedures: 2
-Number of replications: 2
-Estimated replications per hour: 481596
-Start of the simulation: 2020-09-23 18:15:31
-End of the simulation: 2020-09-23 18:15:31
-

The parameter post_analyze (if specified) is applied directly after the result was generated (see command line 10). Note, purrr::compose can be very handy if your post-analyzing-function can be defined by a few single functions:

-
eval_tibbles(
-  expand_tibble(fun = "regData", n = 5L, SD = 1:2),
-  expand_tibble(proc = "lm", formula = c("y~x", "y~I(x^2)")),
-  post_analyze = purrr::compose(function(mat) mat["(Intercept)", "Estimate"], coef, summary.lm),
-  replications = 2
-)
-
# A tibble: 8 x 7
-  fun         n    SD replications proc  formula  results
-  <chr>   <int> <int>        <int> <chr> <chr>      <dbl>
-1 regData     5     1            1 lm    y~x        10.3 
-2 regData     5     1            1 lm    y~I(x^2)   10.2 
-3 regData     5     1            2 lm    y~x         9.43
-4 regData     5     1            2 lm    y~I(x^2)    9.95
-5 regData     5     2            1 lm    y~x        13.5 
-6 regData     5     2            1 lm    y~I(x^2)   13.3 
-7 regData     5     2            2 lm    y~x         9.27
-8 regData     5     2            2 lm    y~I(x^2)    9.25
-Number of data generating functions: 2
-Number of analyzing procedures: 2
-Number of replications: 2
-Estimated replications per hour: 332602
-Start of the simulation: 2020-09-23 18:15:31
-End of the simulation: 2020-09-23 18:15:31
-
-
-

-Parameter group_for_summary -

-

When the result object is a data.frame itself, for instance

-
presever_rownames <- function(mat) {
-  rn <- rownames(mat)
-  ret <- tibble::as_tibble(mat)
-  ret$term <- rn
-  ret
-}
-
-eval_tibbles(
-  expand_tibble(fun = "regData", n = 5L, SD = 1:2),
-  expand_tibble(proc = "lm", formula = c("y~x", "y~I(x^2)")),
-  post_analyze = purrr::compose(presever_rownames, coef, summary),
-  replications = 3
-)
-
# A tibble: 24 x 11
-   fun        n    SD replications proc  formula  Estimate `Std. Error` `t value` `Pr(>|t|)` term   
-   <chr>  <int> <int>        <int> <chr> <chr>       <dbl>        <dbl>     <dbl>      <dbl> <chr>  
- 1 regDa…     5     1            1 lm    y~x          9.91        0.670    14.8     0.000671 (Inter…
- 2 regDa…     5     1            1 lm    y~x          2.80        1.09      2.56    0.0831   x      
- 3 regDa…     5     1            1 lm    y~I(x^2)    10.3         0.577    17.9     0.000381 (Inter…
- 4 regDa…     5     1            1 lm    y~I(x^2)     2.63        1.10      2.40    0.0961   I(x^2) 
- 5 regDa…     5     1            2 lm    y~x          9.32        0.537    17.3     0.000419 (Inter…
- 6 regDa…     5     1            2 lm    y~x          2.11        0.878     2.40    0.0960   x      
- 7 regDa…     5     1            2 lm    y~I(x^2)     9.78        0.590    16.6     0.000478 (Inter…
- 8 regDa…     5     1            2 lm    y~I(x^2)     1.56        1.12      1.39    0.259    I(x^2) 
- 9 regDa…     5     1            3 lm    y~x          9.64        1.16      8.28    0.00369  (Inter…
-10 regDa…     5     1            3 lm    y~x          1.83        1.90      0.965   0.406    x      
-# … with 14 more rows
-Number of data generating functions: 2
-Number of analyzing procedures: 2
-Number of replications: 3
-Estimated replications per hour: 338682
-Start of the simulation: 2020-09-23 18:15:31
-End of the simulation: 2020-09-23 18:15:32
-

In order to summarize the replications it is necessary to additional group the calculations with respect to another variable. This variable can be passed to group_for_summary

-
eval_tibbles(
-  expand_tibble(fun = "regData", n = 5L, SD = 1:2),
-  expand_tibble(proc = "lm", formula = c("y~x", "y~I(x^2)")),
-  post_analyze = purrr::compose(presever_rownames, coef, summary),
-  summary_fun = list(mean = mean, sd = sd),
-  group_for_summary = "term",
-  replications = 3
-)
-
# A tibble: 16 x 12
-   fun       n    SD replications summary_fun proc  formula term  Estimate `Std. Error` `t value`
-   <chr> <int> <int>        <int> <chr>       <chr> <chr>   <chr>    <dbl>        <dbl>     <dbl>
- 1 regD…     5     1            1 mean        lm    y~x     (Int…    9.95         0.500     53.5 
- 2 regD…     5     1            1 mean        lm    y~x     x        2.04         0.817      6.86
- 3 regD…     5     1            1 mean        lm    y~I(x^… (Int…   10.3          0.444     28.5 
- 4 regD…     5     1            1 mean        lm    y~I(x^… I(x^…    1.93         0.845      2.80
- 5 regD…     5     1            1 sd          lm    y~x     (Int…    0.505        0.404     66.9 
- 6 regD…     5     1            1 sd          lm    y~x     x        0.382        0.660      8.87
- 7 regD…     5     1            1 sd          lm    y~I(x^… (Int…    0.608        0.202     17.8 
- 8 regD…     5     1            1 sd          lm    y~I(x^… I(x^…    0.759        0.385      1.87
- 9 regD…     5     2            1 mean        lm    y~x     (Int…    9.38         0.787     13.6 
-10 regD…     5     2            1 mean        lm    y~x     x        3.28         1.28       2.80
-11 regD…     5     2            1 mean        lm    y~I(x^… (Int…    9.99         0.823     14.1 
-12 regD…     5     2            1 mean        lm    y~I(x^… I(x^…    2.74         1.57       1.79
-13 regD…     5     2            1 sd          lm    y~x     (Int…    1.06         0.271      7.18
-14 regD…     5     2            1 sd          lm    y~x     x        3.14         0.443      2.41
-15 regD…     5     2            1 sd          lm    y~I(x^… (Int…    0.862        0.365      6.91
-16 regD…     5     2            1 sd          lm    y~I(x^… I(x^…    2.74         0.694      1.73
-# … with 1 more variable: `Pr(>|t|)` <dbl>
-Number of data generating functions: 2
-Number of analyzing procedures: 2
-Number of replications: 3
-Estimated replications per hour: 118069
-Start of the simulation: 2020-09-23 18:15:32
-End of the simulation: 2020-09-23 18:15:32
-
-
-

-Parameter ncpus and cluster_seed -

-

By specifying ncpus larger than 1 a cluster objected is created for the user and passed to the parameter cluster discussed in the next section.

-
eval_tibbles(
-  data_grid = dg, proc_grid = pg, replications = 10,
-  ncpus = 2, summary_fun = list(mean = mean)
-)
-
# A tibble: 6 x 6
-  fun       n replications summary_fun proc   value
-  <chr> <dbl>        <int> <chr>       <chr>  <dbl>
-1 runif    10            1 mean        min   0.0884
-2 runif    10            1 mean        max   0.912 
-3 runif    20            1 mean        min   0.0656
-4 runif    20            1 mean        max   0.947 
-5 runif    30            1 mean        min   0.0362
-6 runif    30            1 mean        max   0.969 
-Number of data generating functions: 3
-Number of analyzing procedures: 2
-Number of replications: 10
-Estimated replications per hour: 16571
-Start of the simulation: 2020-09-23 18:15:32
-End of the simulation: 2020-09-23 18:15:34
-

As it is stated in command line 7, the replications are parallelized. In our case, this means that roughly every CPU conducts 5 replications.

-

The parameter cluster_seed must be an integer vector of length 6 and serves the same purpose as the function set.seed. By default, cluster_seed equals rep(12345, 6). Note, in order to reproduce the simulation study it is also necessary that ncpus does not change.

-
-
-

-Parameter cluster -

-

The user can create a cluster on its own. This also enables the user to distribute the replications over different computers in a network.

-
library(parallel)
-cl <- makeCluster(rep("localhost", 2), type = "PSOCK")
-eval_tibbles(
-  data_grid = dg, proc_grid = pg, replications = 10,
-  cluster = cl, summary_fun = list(mean = mean)
-)
-
# A tibble: 6 x 6
-  fun       n replications summary_fun proc   value
-  <chr> <dbl>        <int> <chr>       <chr>  <dbl>
-1 runif    10            1 mean        min   0.0884
-2 runif    10            1 mean        max   0.912 
-3 runif    20            1 mean        min   0.0656
-4 runif    20            1 mean        max   0.947 
-5 runif    30            1 mean        min   0.0362
-6 runif    30            1 mean        max   0.969 
-Number of data generating functions: 3
-Number of analyzing procedures: 2
-Number of replications: 10
-Estimated replications per hour: 74036
-Start of the simulation: 2020-09-23 18:15:34
-End of the simulation: 2020-09-23 18:15:35
- -

As you can see our cluster consists of 3 workers. Hence, this reproduces the results from the last code chunk above. Further note, if the user starts the cluster, the user also has to stop the cluster. A cluster that is created within eval_tibbles by specifying ncpus is also stop within eval_tibbles.

-
-
-

-Parameter cluster_libraries and cluster_global_objects -

-

A newly created cluster is ``empty’’. Hence, if the simulation study requires libraries or objects from the global environment, they must be transferred to the cluster.

-

Lets look at standard example from the boot package.

-
library(boot)
-ratio <- function(d, w) sum(d$x * w) / sum(d$u * w)
-city.boot <- boot(city, ratio,
-  R = 999, stype = "w",
-  sim = "ordinary"
-)
-boot.ci(city.boot,
-  conf = c(0.90, 0.95),
-  type = c("norm", "basic", "perc", "bca")
-)
-
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
-Based on 999 bootstrap replicates
-
-CALL : 
-boot.ci(boot.out = city.boot, conf = c(0.9, 0.95), type = c("norm", 
-    "basic", "perc", "bca"))
-
-Intervals : 
-Level      Normal              Basic         
-90%   ( 1.098,  1.861 )   ( 1.047,  1.772 )   
-95%   ( 1.026,  1.934 )   ( 0.860,  1.799 )  
-
-Level     Percentile            BCa          
-90%   ( 1.268,  1.994 )   ( 1.271,  2.002 )   
-95%   ( 1.241,  2.180 )   ( 1.242,  2.195 )  
-Calculations and Intervals on Original Scale
-

The following data generating function is extremely boring because it always returns the data set city from the library boot.

-
returnCity <- function() {
-  city
-}
-bootConfInt <- function(data) {
-  city.boot <- boot(data, ratio,
-    R = 999, stype = "w",
-    sim = "ordinary"
-  )
-  boot.ci(city.boot,
-    conf = c(0.90, 0.95),
-    type = c("norm", "basic", "perc", "bca")
-  )
-}
-

The function ratio exists at the moment only in our global environment. Further we had to load the boot package. Hence, we load the boot package by setting cluster_libraries = c(“boot”) and transfer the function ratio by setting cluster_global_objects = c(“ratio”).

-
dg <- expand_tibble(fun = "returnCity")
-pg <- expand_tibble(proc = "bootConfInt")
-eval_tibbles(dg, pg,
-  replications = 10, ncpus = 2,
-  cluster_libraries = c("boot"),
-  cluster_global_objects = c("ratio")
-)
-
# A tibble: 10 x 4
-   fun        replications proc        results 
-   <chr>             <int> <chr>       <list>  
- 1 returnCity            1 bootConfInt <bootci>
- 2 returnCity            2 bootConfInt <bootci>
- 3 returnCity            3 bootConfInt <bootci>
- 4 returnCity            4 bootConfInt <bootci>
- 5 returnCity            5 bootConfInt <bootci>
- 6 returnCity            6 bootConfInt <bootci>
- 7 returnCity            7 bootConfInt <bootci>
- 8 returnCity            8 bootConfInt <bootci>
- 9 returnCity            9 bootConfInt <bootci>
-10 returnCity           10 bootConfInt <bootci>
-Number of data generating functions: 1
-Number of analyzing procedures: 1
-Number of replications: 10
-Estimated replications per hour: 152858
-Start of the simulation: 2020-09-23 18:15:36
-End of the simulation: 2020-09-23 18:15:36
-

Of course, it is possible to set cluster_global_objects=ls(), but then all objects from the global environment are transferred to all workers.

-
-
-

-Parameter envir -

-

The function eval_tibbles generates in a first step function calls from data_grid and proc_grid. This is achieved by applying the R-function get. By default, envir=globalenv() and thus get searches the global environment of the current R session. An example shows how to use the parameter envir.

-
# masking summary from the base package
-summary <- function(x) tibble(sd = sd(x))
-g <- function(x) tibble(q0.1 = quantile(x, 0.1))
-someFunc <- function() {
-  summary <- function(x) tibble(sd = sd(x), mean = mean(x))
-
-  dg <- expand_tibble(fun = "runif", n = 100)
-  pg <- expand_tibble(proc = c("summary", "g"))
-
-  # the standard is to use the global
-  # environment, hence summary defined outside
-  # of someFunc() will be used
-  print(eval_tibbles(dg, pg))
-  cat("--------------------------------------------------\n")
-  # will use the local defined summary, but g
-  # from the global environment, because
-  # g is not locally defined.
-  print(eval_tibbles(dg, pg, envir = environment()))
-}
-someFunc()
-
# A tibble: 2 x 6
-  fun       n replications proc        sd   q0.1
-  <chr> <dbl>        <int> <chr>    <dbl>  <dbl>
-1 runif   100            1 summary  0.260 NA    
-2 runif   100            1 g       NA      0.123
-Number of data generating functions: 1
-Number of analyzing procedures: 2
-Number of replications: 1
-Estimated replications per hour: 1662024
-Start of the simulation: 2020-09-23 18:15:36
-End of the simulation: 2020-09-23 18:15:36
---------------------------------------------------
-# A tibble: 2 x 7
-  fun       n replications proc        sd   mean   q0.1
-  <chr> <dbl>        <int> <chr>    <dbl>  <dbl>  <dbl>
-1 runif   100            1 summary  0.282  0.512 NA    
-2 runif   100            1 g       NA     NA      0.147
-Number of data generating functions: 1
-Number of analyzing procedures: 2
-Number of replications: 1
-Estimated replications per hour: 1910119
-Start of the simulation: 2020-09-23 18:15:36
-End of the simulation: 2020-09-23 18:15:36
-
-
-

-.truth-functionality

-

Sometimes it is handy to access the parameter constellation that was used during the data generation in the (post) data analyzing phase. Of course, one could write wrapper functions for every data generating function and append the parameter constellation from the data generation as attributes to the data set, but the purpose of this package is to reduce such administrative source code. Hence if the (post) data analyzing function has an argument .truth, then eval_tibbles will manage that hand-over. A brief example should explain this. Suppose we want to estimate the bias of the empirical quantile estimator if the data is normal distributed.

-
dg <- expand_tibble(fun = c("rnorm"), mean = c(1,1000), sd = c(1,10), n = c(10L, 100L))
-pg <- expand_tibble(proc = "quantile", probs = 0.975)
-post_ana <- function(q_est, .truth){
-  tibble::tibble(bias = q_est - stats::qnorm(0.975, mean = .truth$mean, sd = .truth$sd))
-}
-eval_tibbles(dg, pg, replications = 10^3, discard_generated_data = TRUE,
-                   ncpus = 2,
-                   post_analyze = post_ana,
-                   summary_fun = list(mean = mean))
-
# A tibble: 8 x 9
-  fun    mean    sd     n replications summary_fun proc     probs    bias
-  <chr> <dbl> <dbl> <int>        <int> <chr>       <chr>    <dbl>   <dbl>
-1 rnorm     1     1    10            1 mean        quantile 0.975 -0.573 
-2 rnorm  1000     1    10            1 mean        quantile 0.975 -0.550 
-3 rnorm     1    10    10            1 mean        quantile 0.975 -5.58  
-4 rnorm  1000    10    10            1 mean        quantile 0.975 -5.34  
-5 rnorm     1     1   100            1 mean        quantile 0.975 -0.0760
-6 rnorm  1000     1   100            1 mean        quantile 0.975 -0.0879
-7 rnorm     1    10   100            1 mean        quantile 0.975 -0.685 
-8 rnorm  1000    10   100            1 mean        quantile 0.975 -0.695 
-Number of data generating functions: 8
-Number of analyzing procedures: 1
-Number of replications: 1000
-Estimated replications per hour: 848756
-Start of the simulation: 2020-09-23 18:15:36
-End of the simulation: 2020-09-23 18:15:41
-

If we want to do the analysis for different distrubtions we could modify our post data analyzing function, but we can also simply add a .truth-column to the data generating grid. In this case, the information from the .truth-column is directly passed to the .truth-parameter:

-
dg <- dplyr::bind_rows(
-  expand_tibble(fun = c("rnorm"), mean = 0, n = c(10L, 100L), .truth = qnorm(0.975)),
-  expand_tibble(fun = c("rexp"), rate = 1, n = c(10L, 100L), .truth = qexp(0.975, rate = 1)),
-  expand_tibble(fun = c("runif"), max = 2, n = c(10L, 100L), .truth = qunif(0.975, max = 2))
-)
-pg <- expand_tibble(proc = "quantile", probs = 0.975)
-post_ana <- function(q_est, .truth){
-  ret <- q_est - .truth
-  names(ret) <- "bias"
-  ret
-}
-eval_tibbles(dg, pg, replications = 10^3, discard_generated_data = TRUE,
-                   ncpus = 2,
-                   post_analyze = post_ana,
-                   summary_fun = list(mean = mean))
-
# A tibble: 6 x 11
-  fun    mean     n .truth  rate   max replications summary_fun proc     probs    bias
-  <chr> <dbl> <int>  <dbl> <dbl> <dbl>        <int> <chr>       <chr>    <dbl>   <dbl>
-1 rnorm     0    10   1.96    NA    NA            1 mean        quantile 0.975 -0.573 
-2 rnorm     0   100   1.96    NA    NA            1 mean        quantile 0.975 -0.0818
-3 rexp     NA    10   3.69     1    NA            1 mean        quantile 0.975 -0.917 
-4 rexp     NA   100   3.69     1    NA            1 mean        quantile 0.975 -0.175 
-5 runif    NA    10   1.95    NA     2            1 mean        quantile 0.975 -0.174 
-6 runif    NA   100   1.95    NA     2            1 mean        quantile 0.975 -0.0183
-Number of data generating functions: 6
-Number of analyzing procedures: 1
-Number of replications: 1000
-Estimated replications per hour: 763125
-Start of the simulation: 2020-09-23 18:15:41
-End of the simulation: 2020-09-23 18:15:46
-

In the same fashion one could write a data analyzing function with a parameter .truth. To go even a step further, we store the analytic quantile function in the .truth column:

-
dg <- dplyr::bind_rows(
-  expand_tibble(fun = c("rnorm"), mean = 0, n = c(10L, 1000L),
-                .truth = list(function(prob) qnorm(prob, mean = 0))),
-  expand_tibble(fun = c("rexp"), rate = 1, n = c(10L, 1000L),
-                .truth = list(function(prob) qexp(prob, rate = 1))),
-  expand_tibble(fun = c("runif"), max = 2, n = c(10L, 1000L),
-                .truth = list(function(prob) qunif(prob, max = 2)))
-)
-bias_quantile <- function(x, prob, .truth) {
-  est <- quantile(x, probs = prob)
-  ret <- est - .truth[[1]](prob)
-  names(ret) <- "bias"
-  ret
-}
-pg <- expand_tibble(proc = "bias_quantile", prob = c(0.9, 0.975))
-eval_tibbles(dg, pg, replications = 10^3, discard_generated_data = TRUE,
-                   ncpus = 1,
-                   summary_fun = list(mean = mean))
-
# A tibble: 12 x 11
-   fun    mean     n .truth  rate   max replications summary_fun proc           prob      bias
-   <chr> <dbl> <int> <list> <dbl> <dbl>        <int> <chr>       <chr>         <dbl>     <dbl>
- 1 rnorm     0    10 <fn>      NA    NA            1 mean        bias_quantile 0.9   -0.218   
- 2 rnorm     0    10 <fn>      NA    NA            1 mean        bias_quantile 0.975 -0.530   
- 3 rnorm     0  1000 <fn>      NA    NA            1 mean        bias_quantile 0.9   -0.00626 
- 4 rnorm     0  1000 <fn>      NA    NA            1 mean        bias_quantile 0.975 -0.0106  
- 5 rexp     NA    10 <fn>       1    NA            1 mean        bias_quantile 0.9   -0.275   
- 6 rexp     NA    10 <fn>       1    NA            1 mean        bias_quantile 0.975 -0.983   
- 7 rexp     NA  1000 <fn>       1    NA            1 mean        bias_quantile 0.9   -0.00226 
- 8 rexp     NA  1000 <fn>       1    NA            1 mean        bias_quantile 0.975 -0.0217  
- 9 runif    NA    10 <fn>      NA     2            1 mean        bias_quantile 0.9   -0.150   
-10 runif    NA    10 <fn>      NA     2            1 mean        bias_quantile 0.975 -0.173   
-11 runif    NA  1000 <fn>      NA     2            1 mean        bias_quantile 0.9   -0.000524
-12 runif    NA  1000 <fn>      NA     2            1 mean        bias_quantile 0.975 -0.00201 
-Number of data generating functions: 6
-Number of analyzing procedures: 2
-Number of replications: 1000
-Estimated replications per hour: 386468
-Start of the simulation: 2020-09-23 18:15:46
-End of the simulation: 2020-09-23 18:15:55
-

But one should keep in mind that if one calculates the quantile during the (post) analyzing phase that this is happens on replication level. To be more precise lets look at an excerpt of the pseudo code from the beginning of the vignette:

-
6.  for g in  {g_1, ..., g_k} 
-7.      for r in 1:replications (optionally in a parallel manner) 
-8.          data = g() 
-9.          for f in  {f_1, \ldots, f_L} 
-10.             append f(data) to the result object (optionally apply a post-analyze-function)
-

No matter if one extend the data analyzing function f_1, … f_L or the post-analyze-function with an argument .truth the calculation are made for every single replication during step 10. Hence, the operations are not vectorized!

-
-
-
-

-Some Examples

-

Note, the following code examples will use more computational resources. In order to prevent that these are checked/executed on the CRAN check farm, they are only evaluated if the environment variable NOT_CRAN is set to “true”

-
EVAL <- FALSE
-if (Sys.getenv("NOT_CRAN") == "true") {
-  EVAL <- TRUE
-}
-
-

-Sampling distribution of mean and median for normal and exponential distributed data

-

First we define how the data is generated, where the sample size should be 10 and 100:

-
dg <- dplyr::bind_rows(
-  expand_tibble(fun = c("rnorm"), mean = 1, n = c(10L, 100L)),
-  expand_tibble(fun = c("rexp"), rate = 1, n = c(10L, 100L))
-)
-dg
-

Afterwards we define how we want to analyze the data:

-
pg <- expand_tibble(proc = c("mean", "median"))
-pg
-

Finally, we conduct the simulation and visualize the results

-
et <- eval_tibbles(dg, pg, replications = 10^4, ncpus = 2)
-
-et$simulation %>%
-  ggplot(aes(x = results, color = interaction(fun, n), fill = interaction(fun, n))) +
-  geom_density(alpha = 0.3) +
-  facet_wrap(~ proc)
-
-
-

-Comparing bootstrap confidence intervals with classical studentized interval

-

We want to compare the confidence intervals that are generated by boot::boot.ci() and stats::t.test(). Unfortunately, boot::boot.ci() cannot be applied directly to the generated data sets. Therefore, we write a new function:

-
bootstrap_ci <- function(x, conf.level, R = 999) {
-  b <- boot::boot(x, function(d, i) {
-    n <- length(i)
-    c(
-      mean = mean(d[i]),
-      variance = (n - 1) * var(d[i]) / n^2
-    )
-  }, R = R)
-  boot::boot.ci(b, conf = conf.level, type = "all")
-}
-

Furthermore, boot::boot.ci() returns in general more than one confidence interval and the structures returned by boot::boot.ci() and stats::t.test() are also very different. One solution could be to write a function t_test() that calls stats::t.test(), modifies the returned object and additionally modify the function bootstrap_ci so that both function return objects with a unified structure. But instead of that we will implement a function that is later on passed to the argument post_analyze of eval_tibbles:

-
post_analyze <- function(o, .truth) {
-  if (class(o) == "htest") {
-  #post-process the object returned by t.test
-    ci <- o$conf.int
-    return(tibble::tibble(
-      type = "t.test",
-      aspect = c("covered", "ci_length"),
-      value = c(ci[1] <= .truth && .truth <= ci[2], ci[2] - ci[1])
-    ))
-  } else if (class(o) == "bootci") {
-  #post-process the object returned by boot.ci
-    method = c("normal", "basic", "student", "percent", "bca")
-    ret = o[method]
-    lower = unlist(purrr::map(ret, ~dplyr::nth(.x, -2)))
-    upper = sapply(ret, dplyr::last)
-    type = paste("boot", method, sep = "_")
-
-    return(
-      dplyr::bind_rows(
-      tibble::tibble(
-        type = type,
-        aspect = "covered",
-        value = as.integer(lower <= .truth & .truth <= upper)),
-      tibble::tibble(
-        type = type,
-        aspect = "ci_length",
-        value = upper - lower))
-    )
-  }
-}
-

As you can see, the objects returned are tibbles with more than one row. Summarizing the data over all replications will in general use the variable type and aspect as grouping variables. This can be achieved by using the parameter group_for_summary of eval_tibbles.

-
-

-Define and run the simulation

-

We want to generate normal-, uniform-, and exponential distributed data:

-
dg <- dplyr::bind_rows(
-  simTool::expand_tibble(fun = "rnorm", n = 10L, mean = 0, sd = sqrt(3), .truth = 0),
-  simTool::expand_tibble(fun = "runif", n = 10L, max = 6, .truth = 3),
-  simTool::expand_tibble(fun = "rexp", n = 10L, rate = 1 / sqrt(3), .truth = sqrt(3))
-)
-dg
-

and apply our functions that calculate the confidence intervals to it using two different confidence levels.

-
pg <- simTool::expand_tibble(
-  proc = c("t.test","bootstrap_ci"),
-  conf.level = c(0.9, 0.95)
-)
-pg
-

Note, that the structure of the objects returned are quite different which addressed by our function post_analyze. The variables type and aspect that are created by post_analyze are to distinguish the different confidence intervals. Since these variables are part of the result objects, eval_tibbles assumes that these variables are results. In order to summarize the results (calculating the mean) over all replications correctly we need to tell eval_tibbles that additional group variables are type and aspect:

-
et <- eval_tibbles(dg, pg,
-  replications = 10^3, ncpus = 2,
-  cluster_global_objects = "post_analyze",
-  post_analyze = post_analyze,
-  summary_fun = list(mean = mean),
-  group_for_summary = c("aspect", "type")
-)
-et
-

Finally, we can visualize the summarized results:

-
et$simulation %>%
-  ggplot(aes(x = fun, y = value, group = type, fill = type, label = round(value, 2))) +
-  geom_col(position = "dodge") +
-  geom_label(position = position_dodge(0.9), size = 3) +
-  theme(legend.position = "bottom") +
-  facet_grid(aspect ~ conf.level, scales = "free")
-
-
-

-A different implementation

-

Here we briefly realize the simulation differently by leveraging data analyzing functions with unified return-objects:

-
t_test = function(x, conf.level){
-  tt <- t.test(x, conf.level = conf.level)
-
-  # unify return
-  tibble::tibble(type = "t.test", lower = tt$conf.int[1], upper = tt$conf.int[2])
-}
-
-bootstrap_ci <- function(x, conf.level, R = 999) {
-  b <- boot::boot(x, function(d, i) {
-    n <- length(i)
-    c(
-      mean = mean(d[i]),
-      variance = (n - 1) * var(d[i]) / n^2
-    )
-  }, R = R)
-  ci <- boot::boot.ci(b, conf = conf.level, type = "all")
-  method = c("normal", "basic", "student", "percent", "bca")
-  ret = ci[method]
-  lower = unlist(purrr::map(ret, ~dplyr::nth(.x, -2)))
-  upper = sapply(ret, dplyr::last)
-  type = paste("boot", method, sep = "_")
-
-  # unify return
-  tibble::tibble(type = type, lower = lower, upper = upper)
-}
-
-dg <- dplyr::bind_rows(
-  simTool::expand_tibble(fun = "rnorm", n = 10L, mean = 0, sd = sqrt(3), .truth = 0),
-  simTool::expand_tibble(fun = "runif", n = 10L, max = 6, .truth = 3),
-  simTool::expand_tibble(fun = "rexp", n = 10L, rate = 1 / sqrt(3), .truth = sqrt(3))
-)
-
-pg <- simTool::expand_tibble(
-  proc = c("t_test","bootstrap_ci"),
-  conf.level = c(0.9, 0.95)
-) %>%
-  mutate(R = ifelse(proc == "bootstrap_ci", 100, NA))
-
-et <- eval_tibbles(dg, pg,
-  replications = 10^2, ncpus = 2
-)
-et
-
grps <- et$simulation %>%
-  select(-replications) %>%
-  select(fun:type) %>%
-  names
-
-et$simulation %>%
-  mutate(covered = lower <= .truth & .truth <= upper,
-         ci_length = upper - lower) %>%
-  group_by(.dots = grps) %>%
-  summarise(coverage = mean(covered),
-            ci_length = mean(ci_length))
-
-
-
-
- - - -
- - - -
- -
-

Site built with pkgdown 1.5.1.

-
- -
-
- - - - - - diff --git a/docs/authors.html b/docs/authors.html deleted file mode 100644 index 12ba60b..0000000 --- a/docs/authors.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - -Authors • simTool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- -
-
- - -
    -
  • -

    Marsel Scheer. Author, maintainer. -

    -
  • -
- -
- -
- - - -
- - -
-

Site built with pkgdown 1.5.1.

-
- -
-
- - - - - - - - diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css deleted file mode 100644 index 5a85941..0000000 --- a/docs/bootstrap-toc.css +++ /dev/null @@ -1,60 +0,0 @@ -/*! - * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) - * Copyright 2015 Aidan Feldman - * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ - -/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ - -/* All levels of nav */ -nav[data-toggle='toc'] .nav > li > a { - display: block; - padding: 4px 20px; - font-size: 13px; - font-weight: 500; - color: #767676; -} -nav[data-toggle='toc'] .nav > li > a:hover, -nav[data-toggle='toc'] .nav > li > a:focus { - padding-left: 19px; - color: #563d7c; - text-decoration: none; - background-color: transparent; - border-left: 1px solid #563d7c; -} -nav[data-toggle='toc'] .nav > .active > a, -nav[data-toggle='toc'] .nav > .active:hover > a, -nav[data-toggle='toc'] .nav > .active:focus > a { - padding-left: 18px; - font-weight: bold; - color: #563d7c; - background-color: transparent; - border-left: 2px solid #563d7c; -} - -/* Nav: second level (shown on .active) */ -nav[data-toggle='toc'] .nav .nav { - display: none; /* Hide by default, but at >768px, show it */ - padding-bottom: 10px; -} -nav[data-toggle='toc'] .nav .nav > li > a { - padding-top: 1px; - padding-bottom: 1px; - padding-left: 30px; - font-size: 12px; - font-weight: normal; -} -nav[data-toggle='toc'] .nav .nav > li > a:hover, -nav[data-toggle='toc'] .nav .nav > li > a:focus { - padding-left: 29px; -} -nav[data-toggle='toc'] .nav .nav > .active > a, -nav[data-toggle='toc'] .nav .nav > .active:hover > a, -nav[data-toggle='toc'] .nav .nav > .active:focus > a { - padding-left: 28px; - font-weight: 500; -} - -/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ -nav[data-toggle='toc'] .nav > .active > ul { - display: block; -} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js deleted file mode 100644 index 1cdd573..0000000 --- a/docs/bootstrap-toc.js +++ /dev/null @@ -1,159 +0,0 @@ -/*! - * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) - * Copyright 2015 Aidan Feldman - * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ -(function() { - 'use strict'; - - window.Toc = { - helpers: { - // return all matching elements in the set, or their descendants - findOrFilter: function($el, selector) { - // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ - // http://stackoverflow.com/a/12731439/358804 - var $descendants = $el.find(selector); - return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); - }, - - generateUniqueIdBase: function(el) { - var text = $(el).text(); - var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); - return anchor || el.tagName.toLowerCase(); - }, - - generateUniqueId: function(el) { - var anchorBase = this.generateUniqueIdBase(el); - for (var i = 0; ; i++) { - var anchor = anchorBase; - if (i > 0) { - // add suffix - anchor += '-' + i; - } - // check if ID already exists - if (!document.getElementById(anchor)) { - return anchor; - } - } - }, - - generateAnchor: function(el) { - if (el.id) { - return el.id; - } else { - var anchor = this.generateUniqueId(el); - el.id = anchor; - return anchor; - } - }, - - createNavList: function() { - return $(''); - }, - - createChildNavList: function($parent) { - var $childList = this.createNavList(); - $parent.append($childList); - return $childList; - }, - - generateNavEl: function(anchor, text) { - var $a = $(''); - $a.attr('href', '#' + anchor); - $a.text(text); - var $li = $('
  • '); - $li.append($a); - return $li; - }, - - generateNavItem: function(headingEl) { - var anchor = this.generateAnchor(headingEl); - var $heading = $(headingEl); - var text = $heading.data('toc-text') || $heading.text(); - return this.generateNavEl(anchor, text); - }, - - // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). - getTopLevel: function($scope) { - for (var i = 1; i <= 6; i++) { - var $headings = this.findOrFilter($scope, 'h' + i); - if ($headings.length > 1) { - return i; - } - } - - return 1; - }, - - // returns the elements for the top level, and the next below it - getHeadings: function($scope, topLevel) { - var topSelector = 'h' + topLevel; - - var secondaryLevel = topLevel + 1; - var secondarySelector = 'h' + secondaryLevel; - - return this.findOrFilter($scope, topSelector + ',' + secondarySelector); - }, - - getNavLevel: function(el) { - return parseInt(el.tagName.charAt(1), 10); - }, - - populateNav: function($topContext, topLevel, $headings) { - var $context = $topContext; - var $prevNav; - - var helpers = this; - $headings.each(function(i, el) { - var $newNav = helpers.generateNavItem(el); - var navLevel = helpers.getNavLevel(el); - - // determine the proper $context - if (navLevel === topLevel) { - // use top level - $context = $topContext; - } else if ($prevNav && $context === $topContext) { - // create a new level of the tree and switch to it - $context = helpers.createChildNavList($prevNav); - } // else use the current $context - - $context.append($newNav); - - $prevNav = $newNav; - }); - }, - - parseOps: function(arg) { - var opts; - if (arg.jquery) { - opts = { - $nav: arg - }; - } else { - opts = arg; - } - opts.$scope = opts.$scope || $(document.body); - return opts; - } - }, - - // accepts a jQuery object, or an options object - init: function(opts) { - opts = this.helpers.parseOps(opts); - - // ensure that the data attribute is in place for styling - opts.$nav.attr('data-toggle', 'toc'); - - var $topContext = this.helpers.createChildNavList(opts.$nav); - var topLevel = this.helpers.getTopLevel(opts.$scope); - var $headings = this.helpers.getHeadings(opts.$scope, topLevel); - this.helpers.populateNav($topContext, topLevel, $headings); - } - }; - - $(function() { - $('nav[data-toggle="toc"]').each(function(i, el) { - var $nav = $(el); - Toc.init($nav); - }); - }); -})(); diff --git a/docs/docsearch.css b/docs/docsearch.css deleted file mode 100644 index e5f1fe1..0000000 --- a/docs/docsearch.css +++ /dev/null @@ -1,148 +0,0 @@ -/* Docsearch -------------------------------------------------------------- */ -/* - Source: https://github.com/algolia/docsearch/ - License: MIT -*/ - -.algolia-autocomplete { - display: block; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1 -} - -.algolia-autocomplete .ds-dropdown-menu { - width: 100%; - min-width: none; - max-width: none; - padding: .75rem 0; - background-color: #fff; - background-clip: padding-box; - border: 1px solid rgba(0, 0, 0, .1); - box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); -} - -@media (min-width:768px) { - .algolia-autocomplete .ds-dropdown-menu { - width: 175% - } -} - -.algolia-autocomplete .ds-dropdown-menu::before { - display: none -} - -.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { - padding: 0; - background-color: rgb(255,255,255); - border: 0; - max-height: 80vh; -} - -.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { - margin-top: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion { - padding: 0; - overflow: visible -} - -.algolia-autocomplete .algolia-docsearch-suggestion--category-header { - padding: .125rem 1rem; - margin-top: 0; - font-size: 1.3em; - font-weight: 500; - color: #00008B; - border-bottom: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { - float: none; - padding-top: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { - float: none; - width: auto; - padding: 0; - text-align: left -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content { - float: none; - width: auto; - padding: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content::before { - display: none -} - -.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { - padding-top: .75rem; - margin-top: .75rem; - border-top: 1px solid rgba(0, 0, 0, .1) -} - -.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { - display: block; - padding: .1rem 1rem; - margin-bottom: 0.1; - font-size: 1.0em; - font-weight: 400 - /* display: none */ -} - -.algolia-autocomplete .algolia-docsearch-suggestion--title { - display: block; - padding: .25rem 1rem; - margin-bottom: 0; - font-size: 0.9em; - font-weight: 400 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--text { - padding: 0 1rem .5rem; - margin-top: -.25rem; - font-size: 0.8em; - font-weight: 400; - line-height: 1.25 -} - -.algolia-autocomplete .algolia-docsearch-footer { - width: 110px; - height: 20px; - z-index: 3; - margin-top: 10.66667px; - float: right; - font-size: 0; - line-height: 0; -} - -.algolia-autocomplete .algolia-docsearch-footer--logo { - background-image: url("data:image/svg+xml;utf8,"); - background-repeat: no-repeat; - background-position: 50%; - background-size: 100%; - overflow: hidden; - text-indent: -9000px; - width: 100%; - height: 100%; - display: block; - transform: translate(-8px); -} - -.algolia-autocomplete .algolia-docsearch-suggestion--highlight { - color: #FF8C00; - background: rgba(232, 189, 54, 0.1) -} - - -.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { - box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) -} - -.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { - background-color: rgba(192, 192, 192, .15) -} diff --git a/docs/docsearch.js b/docs/docsearch.js deleted file mode 100644 index b35504c..0000000 --- a/docs/docsearch.js +++ /dev/null @@ -1,85 +0,0 @@ -$(function() { - - // register a handler to move the focus to the search bar - // upon pressing shift + "/" (i.e. "?") - $(document).on('keydown', function(e) { - if (e.shiftKey && e.keyCode == 191) { - e.preventDefault(); - $("#search-input").focus(); - } - }); - - $(document).ready(function() { - // do keyword highlighting - /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ - var mark = function() { - - var referrer = document.URL ; - var paramKey = "q" ; - - if (referrer.indexOf("?") !== -1) { - var qs = referrer.substr(referrer.indexOf('?') + 1); - var qs_noanchor = qs.split('#')[0]; - var qsa = qs_noanchor.split('&'); - var keyword = ""; - - for (var i = 0; i < qsa.length; i++) { - var currentParam = qsa[i].split('='); - - if (currentParam.length !== 2) { - continue; - } - - if (currentParam[0] == paramKey) { - keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); - } - } - - if (keyword !== "") { - $(".contents").unmark({ - done: function() { - $(".contents").mark(keyword); - } - }); - } - } - }; - - mark(); - }); -}); - -/* Search term highlighting ------------------------------*/ - -function matchedWords(hit) { - var words = []; - - var hierarchy = hit._highlightResult.hierarchy; - // loop to fetch from lvl0, lvl1, etc. - for (var idx in hierarchy) { - words = words.concat(hierarchy[idx].matchedWords); - } - - var content = hit._highlightResult.content; - if (content) { - words = words.concat(content.matchedWords); - } - - // return unique words - var words_uniq = [...new Set(words)]; - return words_uniq; -} - -function updateHitURL(hit) { - - var words = matchedWords(hit); - var url = ""; - - if (hit.anchor) { - url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; - } else { - url = hit.url + '?q=' + escape(words.join(" ")); - } - - return url; -} diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index c48cbaf..0000000 --- a/docs/index.html +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - -Conduct Simulation Studies with a Minimal Amount of Source Code • simTool - - - - - - - - - - -
    -
    - - - - -
    -
    - - -
    - -

    An R-Package that facilitates simulation studies. It disengages the researcher from administrative source code.

    -

    The simTool package is designed for statistical simulations that have two components. One component generates the data and the other one analyzes the data. The main aims of the simTool package are the reduction of the administrative source code (mainly loops and management code for the results) and a simple applicability of the package that allows the user to quickly learn how to work with the simTool package. Parallel computing is also supported. Finally, convenient functions are provided to summarize the simulation results.

    -
    -

    -Example

    -

    This small simulation (using 4 cores) illustrates how the confidence interval based on the t-distribution performs on exponential distributed random variables. The following lines generate exponential distributed random variables of size 10, 50, 100, and 1000. Afterwards the t.test using confidence levels 0.8, 0.9, 0.95 are applied. This is repeated 1000 times to estimate the coverage:

    -
    library(simTool)
    -dg <- expand_tibble(fun = "rexp", rate = 10, n = c(10L, 50L, 100L, 1000L))
    -pg <- expand_tibble(proc = "t.test", conf.level = c(0.8, 0.9, 0.95))
    -et <- eval_tibbles(dg, pg,
    -  ncpus = 4,
    -  replications = 10^3,
    -  post_analyze = function(ttest) tibble::tibble(
    -    coverage = ttest$conf.int[1] <= 1 / 10 && 1 / 10 <= ttest$conf.int[2]),
    -  summary_fun = list(mean = mean)
    -)
    -#>   |                                                                              |                                                                      |   0%  |                                                                              |==================                                                    |  25%  |                                                                              |===================================                                   |  50%  |                                                                              |====================================================                  |  75%  |                                                                              |======================================================================| 100%
    -et
    -#> # A tibble: 12 x 8
    -#>    fun    rate     n replications summary_fun proc   conf.level coverage
    -#>    <chr> <dbl> <int>        <int> <chr>       <chr>       <dbl>    <dbl>
    -#>  1 rexp     10    10            1 mean        t.test       0.8     0.754
    -#>  2 rexp     10    10            1 mean        t.test       0.9     0.855
    -#>  3 rexp     10    10            1 mean        t.test       0.95    0.905
    -#>  4 rexp     10    50            1 mean        t.test       0.8     0.808
    -#>  5 rexp     10    50            1 mean        t.test       0.9     0.905
    -#>  6 rexp     10    50            1 mean        t.test       0.95    0.945
    -#>  7 rexp     10   100            1 mean        t.test       0.8     0.792
    -#>  8 rexp     10   100            1 mean        t.test       0.9     0.895
    -#>  9 rexp     10   100            1 mean        t.test       0.95    0.936
    -#> 10 rexp     10  1000            1 mean        t.test       0.8     0.796
    -#> 11 rexp     10  1000            1 mean        t.test       0.9     0.897
    -#> 12 rexp     10  1000            1 mean        t.test       0.95    0.953
    -#> Number of data generating functions: 4
    -#> Number of analyzing procedures: 3
    -#> Number of replications: 1000
    -#> Estimated replications per hour: 614008
    -#> Start of the simulation: 2020-09-16 19:53:05
    -#> End of the simulation: 2020-09-16 19:53:11
    -
    -
    -

    -Installation

    -

    You can install simTool from github with:

    -
    install.packages("simTool")
    -# install.packages("devtools")
    -devtools::install_github("MarselScheer/simTool")
    -

    Or from CRAN with:

    -
    install.packages("simTool")
    -
    -
    -

    -Test suite

    -

    With tinytest you can rerun the test for simTool by calling

    -
    # install.packages("tinytest")
    -tinytest::test_package("simTool")
    -
    -
    - -
    - - -
    - - -
    - -
    -

    Site built with pkgdown 1.5.1.

    -
    - -
    -
    - - - - - - diff --git a/docs/link.svg b/docs/link.svg deleted file mode 100644 index 88ad827..0000000 --- a/docs/link.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/docs/news/index.html b/docs/news/index.html deleted file mode 100644 index 86658e8..0000000 --- a/docs/news/index.html +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - - - -Changelog • simTool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    -Version 1.1.7 2020-09-22 -

    -
      -
    • During a replication data is generated once and then used by all data analyzing functions. This was already the case under the default setting where the generated data sets are stored by eval_tibbles() and is now also the case were the generated data is discarded by the eval_tibbles() function.
    • -
    -
    -
    -

    -Version 1.1.6 2020-05-17 -

    -

    Misc:

    -
      -
    • internal updated for dplyr 1.0.0 and vctrs 0.3.0
    • -
    • internal correction based on lintr-findings
    • -
    -
    -
    -

    -Version 1.1.5 2020-03-15 -

    -

    Misc:

    -
      -
    • removing functions expandGrid() and evalGrid() (which were marked as deprecated in version 1.1.0) and the corresponding dependencies with reshape and plyr
    • -
    • retrieve the RNG kind after parallel computation
    • -
    -
    -
    -

    -Version 1.1.4 2019-09-14 -

    -

    Misc:

    -
      -
    • adaptions to address the new release of tidyr 1.0.0
    • -
    -

    Note:

    -
      -
    • due to https://github.com/r-lib/vctrs/issues/530 reshaping the simulation results can be extremely slow. That costly reshaping will not happen if the parameter simplify is set to FALSE in simTool::eval_tibbles.
    • -
    -
    -
    -

    -Version 1.1.3 2019-03-22 -

    -

    Misc:

    -
      -
    • test cases update to address the new release of dplyr 0.8.0
    • -
    -
    -
    -

    -Version 1.1.2 2019-02-02 -

    -

    Misc:

    - -
    -
    -

    -Version 1.1.1 2019-01-13 -

    -

    Misc:

    -
      -
    • .truth-functionality added, i.e. the parameters of the data generation (or alternatively a column of the data generating matrix with the name .truth) is passed to the the data analyzing functions, see the vignette for details
    • -
    • Unnesting of the simulation results improved
    • -
    -
    -
    -

    -Version 1.1.0 2018-03-26 -

    -

    Misc:

    -
      -
    • Refactoring in order to remove the dependency on reshape and plyr
    • -
    • The simulation itself is now a tibble instead of a list of lists
    • -
    -
    -
    -

    -Version 1.0.3 2014-10-25 -

    -

    Misc:

    -
      -
    • Adapted how libraries are loaded onto the cluster
    • -
    -
    -
    -

    -Version 1.0.2 2014-10-15 -

    -

    New Features:

    -
      -
    • The convenient function meanAndNormCI added
    • -
    -

    Misc:

    -
      -
    • Two parameter renamed (post.proc to summary.fun and value.fun to convert.result.fun). Of course, renaming parameters is one of the worst things one can do. On the other hand, only very few users will be affected by these changes.
    • -
    -
    -
    -

    -Version 1.0.1 Unreleased -

    -

    New Features:

    -
      -
    • summarizing functions process also logical results (not only numeric)
    • -
    -

    Misc:

    -
      -
    • HTML vignette (LaTeX not necessary anymore)
    • -
    • additional documentation (static pdf in JSS style)
    • -
    -
    -
    -

    -Version 1.0 2014-07-08 -

    -

    Initial release

    -
      -
    • parallel computing via parallel and the ideas of L’Ecuyer 1999, 2002 for random numbers
    • -
    • fallback capability
    • -
    • text progress bar
    • -
    • estimation of the number of replications per hour
    • -
    -
    -
    - - - -
    - - -
    - - -
    -

    Site built with pkgdown 1.5.1.

    -
    - -
    -
    - - - - - - - - diff --git a/docs/pkgdown.css b/docs/pkgdown.css deleted file mode 100644 index c01e592..0000000 --- a/docs/pkgdown.css +++ /dev/null @@ -1,367 +0,0 @@ -/* Sticky footer */ - -/** - * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ - * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css - * - * .Site -> body > .container - * .Site-content -> body > .container .row - * .footer -> footer - * - * Key idea seems to be to ensure that .container and __all its parents__ - * have height set to 100% - * - */ - -html, body { - height: 100%; -} - -body { - position: relative; -} - -body > .container { - display: flex; - height: 100%; - flex-direction: column; -} - -body > .container .row { - flex: 1 0 auto; -} - -footer { - margin-top: 45px; - padding: 35px 0 36px; - border-top: 1px solid #e5e5e5; - color: #666; - display: flex; - flex-shrink: 0; -} -footer p { - margin-bottom: 0; -} -footer div { - flex: 1; -} -footer .pkgdown { - text-align: right; -} -footer p { - margin-bottom: 0; -} - -img.icon { - float: right; -} - -img { - max-width: 100%; -} - -/* Fix bug in bootstrap (only seen in firefox) */ -summary { - display: list-item; -} - -/* Typographic tweaking ---------------------------------*/ - -.contents .page-header { - margin-top: calc(-60px + 1em); -} - -dd { - margin-left: 3em; -} - -/* Section anchors ---------------------------------*/ - -a.anchor { - margin-left: -30px; - display:inline-block; - width: 30px; - height: 30px; - visibility: hidden; - - background-image: url(./link.svg); - background-repeat: no-repeat; - background-size: 20px 20px; - background-position: center center; -} - -.hasAnchor:hover a.anchor { - visibility: visible; -} - -@media (max-width: 767px) { - .hasAnchor:hover a.anchor { - visibility: hidden; - } -} - - -/* Fixes for fixed navbar --------------------------*/ - -.contents h1, .contents h2, .contents h3, .contents h4 { - padding-top: 60px; - margin-top: -40px; -} - -/* Navbar submenu --------------------------*/ - -.dropdown-submenu { - position: relative; -} - -.dropdown-submenu>.dropdown-menu { - top: 0; - left: 100%; - margin-top: -6px; - margin-left: -1px; - border-radius: 0 6px 6px 6px; -} - -.dropdown-submenu:hover>.dropdown-menu { - display: block; -} - -.dropdown-submenu>a:after { - display: block; - content: " "; - float: right; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; - border-width: 5px 0 5px 5px; - border-left-color: #cccccc; - margin-top: 5px; - margin-right: -10px; -} - -.dropdown-submenu:hover>a:after { - border-left-color: #ffffff; -} - -.dropdown-submenu.pull-left { - float: none; -} - -.dropdown-submenu.pull-left>.dropdown-menu { - left: -100%; - margin-left: 10px; - border-radius: 6px 0 6px 6px; -} - -/* Sidebar --------------------------*/ - -#pkgdown-sidebar { - margin-top: 30px; - position: -webkit-sticky; - position: sticky; - top: 70px; -} - -#pkgdown-sidebar h2 { - font-size: 1.5em; - margin-top: 1em; -} - -#pkgdown-sidebar h2:first-child { - margin-top: 0; -} - -#pkgdown-sidebar .list-unstyled li { - margin-bottom: 0.5em; -} - -/* bootstrap-toc tweaks ------------------------------------------------------*/ - -/* All levels of nav */ - -nav[data-toggle='toc'] .nav > li > a { - padding: 4px 20px 4px 6px; - font-size: 1.5rem; - font-weight: 400; - color: inherit; -} - -nav[data-toggle='toc'] .nav > li > a:hover, -nav[data-toggle='toc'] .nav > li > a:focus { - padding-left: 5px; - color: inherit; - border-left: 1px solid #878787; -} - -nav[data-toggle='toc'] .nav > .active > a, -nav[data-toggle='toc'] .nav > .active:hover > a, -nav[data-toggle='toc'] .nav > .active:focus > a { - padding-left: 5px; - font-size: 1.5rem; - font-weight: 400; - color: inherit; - border-left: 2px solid #878787; -} - -/* Nav: second level (shown on .active) */ - -nav[data-toggle='toc'] .nav .nav { - display: none; /* Hide by default, but at >768px, show it */ - padding-bottom: 10px; -} - -nav[data-toggle='toc'] .nav .nav > li > a { - padding-left: 16px; - font-size: 1.35rem; -} - -nav[data-toggle='toc'] .nav .nav > li > a:hover, -nav[data-toggle='toc'] .nav .nav > li > a:focus { - padding-left: 15px; -} - -nav[data-toggle='toc'] .nav .nav > .active > a, -nav[data-toggle='toc'] .nav .nav > .active:hover > a, -nav[data-toggle='toc'] .nav .nav > .active:focus > a { - padding-left: 15px; - font-weight: 500; - font-size: 1.35rem; -} - -/* orcid ------------------------------------------------------------------- */ - -.orcid { - font-size: 16px; - color: #A6CE39; - /* margins are required by official ORCID trademark and display guidelines */ - margin-left:4px; - margin-right:4px; - vertical-align: middle; -} - -/* Reference index & topics ----------------------------------------------- */ - -.ref-index th {font-weight: normal;} - -.ref-index td {vertical-align: top;} -.ref-index .icon {width: 40px;} -.ref-index .alias {width: 40%;} -.ref-index-icons .alias {width: calc(40% - 40px);} -.ref-index .title {width: 60%;} - -.ref-arguments th {text-align: right; padding-right: 10px;} -.ref-arguments th, .ref-arguments td {vertical-align: top;} -.ref-arguments .name {width: 20%;} -.ref-arguments .desc {width: 80%;} - -/* Nice scrolling for wide elements --------------------------------------- */ - -table { - display: block; - overflow: auto; -} - -/* Syntax highlighting ---------------------------------------------------- */ - -pre { - word-wrap: normal; - word-break: normal; - border: 1px solid #eee; -} - -pre, code { - background-color: #f8f8f8; - color: #333; -} - -pre code { - overflow: auto; - word-wrap: normal; - white-space: pre; -} - -pre .img { - margin: 5px 0; -} - -pre .img img { - background-color: #fff; - display: block; - height: auto; -} - -code a, pre a { - color: #375f84; -} - -a.sourceLine:hover { - text-decoration: none; -} - -.fl {color: #1514b5;} -.fu {color: #000000;} /* function */ -.ch,.st {color: #036a07;} /* string */ -.kw {color: #264D66;} /* keyword */ -.co {color: #888888;} /* comment */ - -.message { color: black; font-weight: bolder;} -.error { color: orange; font-weight: bolder;} -.warning { color: #6A0366; font-weight: bolder;} - -/* Clipboard --------------------------*/ - -.hasCopyButton { - position: relative; -} - -.btn-copy-ex { - position: absolute; - right: 0; - top: 0; - visibility: hidden; -} - -.hasCopyButton:hover button.btn-copy-ex { - visibility: visible; -} - -/* headroom.js ------------------------ */ - -.headroom { - will-change: transform; - transition: transform 200ms linear; -} -.headroom--pinned { - transform: translateY(0%); -} -.headroom--unpinned { - transform: translateY(-100%); -} - -/* mark.js ----------------------------*/ - -mark { - background-color: rgba(255, 255, 51, 0.5); - border-bottom: 2px solid rgba(255, 153, 51, 0.3); - padding: 1px; -} - -/* vertical spacing after htmlwidgets */ -.html-widget { - margin-bottom: 10px; -} - -/* fontawesome ------------------------ */ - -.fab { - font-family: "Font Awesome 5 Brands" !important; -} - -/* don't display links in code chunks when printing */ -/* source: https://stackoverflow.com/a/10781533 */ -@media print { - code a:link:after, code a:visited:after { - content: ""; - } -} diff --git a/docs/pkgdown.js b/docs/pkgdown.js deleted file mode 100644 index 7e7048f..0000000 --- a/docs/pkgdown.js +++ /dev/null @@ -1,108 +0,0 @@ -/* http://gregfranko.com/blog/jquery-best-practices/ */ -(function($) { - $(function() { - - $('.navbar-fixed-top').headroom(); - - $('body').css('padding-top', $('.navbar').height() + 10); - $(window).resize(function(){ - $('body').css('padding-top', $('.navbar').height() + 10); - }); - - $('[data-toggle="tooltip"]').tooltip(); - - var cur_path = paths(location.pathname); - var links = $("#navbar ul li a"); - var max_length = -1; - var pos = -1; - for (var i = 0; i < links.length; i++) { - if (links[i].getAttribute("href") === "#") - continue; - // Ignore external links - if (links[i].host !== location.host) - continue; - - var nav_path = paths(links[i].pathname); - - var length = prefix_length(nav_path, cur_path); - if (length > max_length) { - max_length = length; - pos = i; - } - } - - // Add class to parent
  • , and enclosing
  • if in dropdown - if (pos >= 0) { - var menu_anchor = $(links[pos]); - menu_anchor.parent().addClass("active"); - menu_anchor.closest("li.dropdown").addClass("active"); - } - }); - - function paths(pathname) { - var pieces = pathname.split("/"); - pieces.shift(); // always starts with / - - var end = pieces[pieces.length - 1]; - if (end === "index.html" || end === "") - pieces.pop(); - return(pieces); - } - - // Returns -1 if not found - function prefix_length(needle, haystack) { - if (needle.length > haystack.length) - return(-1); - - // Special case for length-0 haystack, since for loop won't run - if (haystack.length === 0) { - return(needle.length === 0 ? 0 : -1); - } - - for (var i = 0; i < haystack.length; i++) { - if (needle[i] != haystack[i]) - return(i); - } - - return(haystack.length); - } - - /* Clipboard --------------------------*/ - - function changeTooltipMessage(element, msg) { - var tooltipOriginalTitle=element.getAttribute('data-original-title'); - element.setAttribute('data-original-title', msg); - $(element).tooltip('show'); - element.setAttribute('data-original-title', tooltipOriginalTitle); - } - - if(ClipboardJS.isSupported()) { - $(document).ready(function() { - var copyButton = ""; - - $(".examples, div.sourceCode").addClass("hasCopyButton"); - - // Insert copy buttons: - $(copyButton).prependTo(".hasCopyButton"); - - // Initialize tooltips: - $('.btn-copy-ex').tooltip({container: 'body'}); - - // Initialize clipboard: - var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { - text: function(trigger) { - return trigger.parentNode.textContent; - } - }); - - clipboardBtnCopies.on('success', function(e) { - changeTooltipMessage(e.trigger, 'Copied!'); - e.clearSelection(); - }); - - clipboardBtnCopies.on('error', function() { - changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); - }); - }); - } -})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml deleted file mode 100644 index 4548ee5..0000000 --- a/docs/pkgdown.yml +++ /dev/null @@ -1,10 +0,0 @@ -pandoc: 2.7.3 -pkgdown: 1.5.1 -pkgdown_sha: ~ -articles: - simTool: simTool.html -last_built: 2020-09-23T16:15Z -urls: - reference: http://MarselScheer.github.io/simTool/reference - article: http://MarselScheer.github.io/simTool/articles - diff --git a/docs/reference/eval_tibbles.html b/docs/reference/eval_tibbles.html deleted file mode 100644 index 5c9450c..0000000 --- a/docs/reference/eval_tibbles.html +++ /dev/null @@ -1,549 +0,0 @@ - - - - - - - - -Workhorse for simulation studies — eval_tibbles • simTool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    Generates data according to all provided - constellations in data_tibble and applies - all provided constellations in proc_tibble - to them.

    -
    - -
    eval_tibbles(
    -  data_grid,
    -  proc_grid = expand_tibble(proc = "length"),
    -  replications = 1,
    -  discard_generated_data = FALSE,
    -  post_analyze = identity,
    -  summary_fun = NULL,
    -  group_for_summary = NULL,
    -  ncpus = 1L,
    -  cluster = NULL,
    -  cluster_seed = rep(12345, 6),
    -  cluster_libraries = NULL,
    -  cluster_global_objects = NULL,
    -  envir = globalenv(),
    -  simplify = TRUE
    -)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    data_grid

    a data.frame or tibble where the first column -is a character vector with function names. The other -columns contain parameters for the functions specified -in the first column. Parameters with NA are ignored. If a column with name -.truth exist, then the corresponding entry is passed to functions - generated from -proc_grid and the function specified in post_analyze.

    proc_grid

    similar as data_grid the first -column must contain function names. The other columns -contain parameters for the functions specified in the -first column. The data generated according to -data_grid will always be passed to the first -unspecified argument of the functions specified in the first -column of proc_grid. If a function specified in -proc_grid has an argument .truth, then the corresponding -entry in the -.truth column from data_grid is passed to the -.truth parameter or if no column .truth exist in -data_grid, then all parameters used -for the data generation are passed to the .truth parameter.

    replications

    number of replications for the simulation

    discard_generated_data

    if TRUE the generated -data is deleted after all function constellations in -proc_grid have been applied. Otherwise, ALL -generated data sets will be part of the returned object.

    post_analyze

    this is a convenience function, that is applied -directly after the data analyzing function. If this function has an -argument .truth, then the corresponding entry in the -.truth column from data_grid is passed to the .truth -parameter or if no column .truth exist in data_grid, -then all parameters used for the data generation are passed to the -.truth parameter.

    summary_fun

    named list of univariate function to summarize the -results (numeric or logical) over the replications, e.g. -list(mean = mean, sd = sd).

    group_for_summary

    if the result returned by the data analyzing -function or post_analyze -is a data.frame with more than one row, one usually is interested -in summarizing the results while grouping for some variables. This group -variables can be passed as a character vector into group_for_summary

    ncpus

    a cluster of ncpus workers (R-processes) -is created on the local machine to conduct the -simulation. If ncpus -equals one no cluster is created and the simulation -is conducted by the current R-process.

    cluster

    a cluster generated by the parallel -package that will be used to conduct the simulation. -If cluster is specified, then ncpus will -be ignored.

    cluster_seed

    if the simulation is done in parallel -manner, then the combined multiple-recursive generator from L'Ecuyer (1999) -is used to generate random numbers. Thus cluster_seed must be a -(signed) integer vector of length 6. -The 6 elements of the seed are internally regarded as -32-bit unsigned integers. Neither the first three nor the last three -should be all zero, and they are limited to less than 4294967087 and -4294944443 respectively.

    cluster_libraries

    a character vector specifying -the packages that should be loaded by the workers.

    cluster_global_objects

    a character vector specifying -the names of R objects in the global environment that should -be exported to the global environment of every worker.

    envir

    must be provided if the functions specified -in data_grid or proc_grid are not part -of the global environment.

    simplify

    usually the result column is nested, by default it is -tried to unnest it.

    - -

    Value

    - -

    The returned object list of the class - eval_tibbles, where the element simulations contain - the results of the simulation.

    -

    Note

    - -

    If cluster is provided by the user the - function eval_tibbles will NOT stop the cluster. - This has to be done by the user. Conducting parallel - simulations by specifying ncpus will internally - create a cluster and stop it after the simulation - is done.

    - -

    Examples

    -
    rng <- function(data, ...) { - ret <- range(data) - names(ret) <- c("min", "max") - ret -} - -### The following line is only necessary -### if the examples are not executed in the global -### environment, which for instance is the case when -### the oneline-documentation -### http://marselscheer.github.io/simTool/reference/eval_tibbles.html -### is build. In such case eval_tibble() would search the -### above defined function rng() in the global environment where -### it does not exist! -eval_tibbles <- purrr::partial(eval_tibbles, envir = environment()) - -dg <- expand_tibble(fun = "rnorm", n = c(5L, 10L)) -pg <- expand_tibble(proc = c("rng", "median", "length")) - -eval_tibbles(dg, pg, rep = 2, simplify = FALSE)
    #> # A tibble: 12 x 5 -#> fun n replications proc results -#> <chr> <int> <int> <chr> <list> -#> 1 rnorm 5 1 rng <dbl [2]> -#> 2 rnorm 5 1 median <dbl [1]> -#> 3 rnorm 5 1 length <int [1]> -#> 4 rnorm 5 2 rng <dbl [2]> -#> 5 rnorm 5 2 median <dbl [1]> -#> 6 rnorm 5 2 length <int [1]> -#> 7 rnorm 10 1 rng <dbl [2]> -#> 8 rnorm 10 1 median <dbl [1]> -#> 9 rnorm 10 1 length <int [1]> -#> 10 rnorm 10 2 rng <dbl [2]> -#> 11 rnorm 10 2 median <dbl [1]> -#> 12 rnorm 10 2 length <int [1]> -#> Number of data generating functions: 2 -#> Number of analyzing procedures: 3 -#> Number of replications: 2 -#> Estimated replications per hour: 4781347 -#> Start of the simulation: 2020-09-23 18:15:25 -#> End of the simulation: 2020-09-23 18:15:25
    eval_tibbles(dg, pg, rep = 2)
    #> # A tibble: 16 x 5 -#> fun n replications proc results -#> <chr> <int> <int> <chr> <dbl> -#> 1 rnorm 5 1 rng 0.112 -#> 2 rnorm 5 1 rng 1.62 -#> 3 rnorm 5 1 median 0.244 -#> 4 rnorm 5 1 length 5 -#> 5 rnorm 5 2 rng -1.91 -#> 6 rnorm 5 2 rng 1.07 -#> 7 rnorm 5 2 median -0.279 -#> 8 rnorm 5 2 length 5 -#> 9 rnorm 10 1 rng -1.91 -#> 10 rnorm 10 1 rng 2.76 -#> 11 rnorm 10 1 median 0.0583 -#> 12 rnorm 10 1 length 10 -#> 13 rnorm 10 2 rng -2.27 -#> 14 rnorm 10 2 rng 2.68 -#> 15 rnorm 10 2 median 0.0244 -#> 16 rnorm 10 2 length 10 -#> Number of data generating functions: 2 -#> Number of analyzing procedures: 3 -#> Number of replications: 2 -#> Estimated replications per hour: 14624207 -#> Start of the simulation: 2020-09-23 18:15:25 -#> End of the simulation: 2020-09-23 18:15:25
    eval_tibbles(dg, pg, - rep = 2, - post_analyze = purrr::compose(as.data.frame, t) -)
    #> # A tibble: 12 x 7 -#> fun n replications proc min max V1 -#> <chr> <int> <int> <chr> <dbl> <dbl> <dbl> -#> 1 rnorm 5 1 rng -1.18 1.11 NA -#> 2 rnorm 5 1 median NA NA -0.246 -#> 3 rnorm 5 1 length NA NA 5 -#> 4 rnorm 5 2 rng -1.70 1.07 NA -#> 5 rnorm 5 2 median NA NA 0.132 -#> 6 rnorm 5 2 length NA NA 5 -#> 7 rnorm 10 1 rng -1.47 1.34 NA -#> 8 rnorm 10 1 median NA NA 0.260 -#> 9 rnorm 10 1 length NA NA 10 -#> 10 rnorm 10 2 rng -2.61 1.92 NA -#> 11 rnorm 10 2 median NA NA 0.495 -#> 12 rnorm 10 2 length NA NA 10 -#> Number of data generating functions: 2 -#> Number of analyzing procedures: 3 -#> Number of replications: 2 -#> Estimated replications per hour: 830760 -#> Start of the simulation: 2020-09-23 18:15:25 -#> End of the simulation: 2020-09-23 18:15:25
    eval_tibbles(dg, pg, rep = 2, summary_fun = list(mean = mean, sd = sd))
    #> # A tibble: 12 x 8 -#> fun n replications summary_fun proc min max value -#> <chr> <int> <int> <chr> <chr> <dbl> <dbl> <dbl> -#> 1 rnorm 5 1 mean rng -0.196 1.37 NA -#> 2 rnorm 5 1 mean median NA NA 0.716 -#> 3 rnorm 5 1 mean length NA NA 5 -#> 4 rnorm 5 1 sd rng 0.224 0.431 NA -#> 5 rnorm 5 1 sd median NA NA 0.325 -#> 6 rnorm 5 1 sd length NA NA 0 -#> 7 rnorm 10 1 mean rng -1.72 1.55 NA -#> 8 rnorm 10 1 mean median NA NA -0.185 -#> 9 rnorm 10 1 mean length NA NA 10 -#> 10 rnorm 10 1 sd rng 0.0509 0.812 NA -#> 11 rnorm 10 1 sd median NA NA 0.621 -#> 12 rnorm 10 1 sd length NA NA 0 -#> Number of data generating functions: 2 -#> Number of analyzing procedures: 3 -#> Number of replications: 2 -#> Estimated replications per hour: 87096 -#> Start of the simulation: 2020-09-23 18:15:25 -#> End of the simulation: 2020-09-23 18:15:25
    -regData <- function(n, SD) { - data.frame( - x = seq(0, 1, length = n), - y = rnorm(n, sd = SD) - ) -} - -eg <- eval_tibbles( - expand_tibble(fun = "regData", n = 5L, SD = 1:2), - expand_tibble(proc = "lm", formula = c("y~x", "y~I(x^2)")), - replications = 3 -) -eg
    #> # A tibble: 12 x 7 -#> fun n SD replications proc formula results -#> <chr> <int> <int> <int> <chr> <chr> <list> -#> 1 regData 5 1 1 lm y~x <lm> -#> 2 regData 5 1 1 lm y~I(x^2) <lm> -#> 3 regData 5 1 2 lm y~x <lm> -#> 4 regData 5 1 2 lm y~I(x^2) <lm> -#> 5 regData 5 1 3 lm y~x <lm> -#> 6 regData 5 1 3 lm y~I(x^2) <lm> -#> 7 regData 5 2 1 lm y~x <lm> -#> 8 regData 5 2 1 lm y~I(x^2) <lm> -#> 9 regData 5 2 2 lm y~x <lm> -#> 10 regData 5 2 2 lm y~I(x^2) <lm> -#> 11 regData 5 2 3 lm y~x <lm> -#> 12 regData 5 2 3 lm y~I(x^2) <lm> -#> Number of data generating functions: 2 -#> Number of analyzing procedures: 2 -#> Number of replications: 3 -#> Estimated replications per hour: 505056 -#> Start of the simulation: 2020-09-23 18:15:25 -#> End of the simulation: 2020-09-23 18:15:26
    -presever_rownames <- function(mat) { - rn <- rownames(mat) - ret <- tibble::as_tibble(mat) - ret$term <- rn - ret -} - -eg <- eval_tibbles( - expand_tibble(fun = "regData", n = 5L, SD = 1:2), - expand_tibble(proc = "lm", formula = c("y~x", "y~I(x^2)")), - post_analyze = purrr::compose(presever_rownames, coef, summary), - # post_analyze = broom::tidy, # is a nice out of the box alternative - summary_fun = list(mean = mean, sd = sd), - group_for_summary = "term", - replications = 3 -) -eg$simulation
    #> # A tibble: 16 x 12 -#> fun n SD replications summary_fun proc formula term Estimate -#> <chr> <int> <int> <int> <chr> <chr> <chr> <chr> <dbl> -#> 1 regD… 5 1 1 mean lm y~x (Int… -0.137 -#> 2 regD… 5 1 1 mean lm y~x x 0.148 -#> 3 regD… 5 1 1 mean lm y~I(x^… (Int… -0.121 -#> 4 regD… 5 1 1 mean lm y~I(x^… I(x^… 0.154 -#> 5 regD… 5 1 1 sd lm y~x (Int… 0.330 -#> 6 regD… 5 1 1 sd lm y~x x 0.298 -#> 7 regD… 5 1 1 sd lm y~I(x^… (Int… 0.240 -#> 8 regD… 5 1 1 sd lm y~I(x^… I(x^… 0.913 -#> 9 regD… 5 2 1 mean lm y~x (Int… -1.05 -#> 10 regD… 5 2 1 mean lm y~x x 2.58 -#> 11 regD… 5 2 1 mean lm y~I(x^… (Int… -0.851 -#> 12 regD… 5 2 1 mean lm y~I(x^… I(x^… 2.91 -#> 13 regD… 5 2 1 sd lm y~x (Int… 0.754 -#> 14 regD… 5 2 1 sd lm y~x x 0.492 -#> 15 regD… 5 2 1 sd lm y~I(x^… (Int… 0.667 -#> 16 regD… 5 2 1 sd lm y~I(x^… I(x^… 0.655 -#> # … with 3 more variables: `Std. Error` <dbl>, `t value` <dbl>, -#> # `Pr(>|t|)` <dbl>
    -dg <- expand_tibble(fun = "rexp", rate = c(10, 100), n = c(50L, 100L)) -pg <- expand_tibble(proc = c("t.test"), conf.level = c(0.8, 0.9, 0.95)) -et <- eval_tibbles(dg, pg, - ncpus = 1, - replications = 10^1, - post_analyze = function(ttest, .truth) { - mu <- 1 / .truth$rate - ttest$conf.int[1] <= mu && mu <= ttest$conf.int[2] - }, - summary_fun = list(mean = mean, sd = sd) -) -et
    #> # A tibble: 24 x 8 -#> fun rate n replications summary_fun proc conf.level value -#> <chr> <dbl> <int> <int> <chr> <chr> <dbl> <dbl> -#> 1 rexp 10 50 1 mean t.test 0.8 0.9 -#> 2 rexp 10 50 1 mean t.test 0.9 0.9 -#> 3 rexp 10 50 1 mean t.test 0.95 0.9 -#> 4 rexp 10 50 1 sd t.test 0.8 0.316 -#> 5 rexp 10 50 1 sd t.test 0.9 0.316 -#> 6 rexp 10 50 1 sd t.test 0.95 0.316 -#> 7 rexp 100 50 1 mean t.test 0.8 0.6 -#> 8 rexp 100 50 1 mean t.test 0.9 0.7 -#> 9 rexp 100 50 1 mean t.test 0.95 0.7 -#> 10 rexp 100 50 1 sd t.test 0.8 0.516 -#> # … with 14 more rows -#> Number of data generating functions: 4 -#> Number of analyzing procedures: 3 -#> Number of replications: 10 -#> Estimated replications per hour: 247445 -#> Start of the simulation: 2020-09-23 18:15:26 -#> End of the simulation: 2020-09-23 18:15:26
    -dg <- dplyr::bind_rows( - expand_tibble(fun = "rexp", rate = 10, .truth = 1 / 10, n = c(50L, 100L)), - expand_tibble(fun = "rnorm", .truth = 0, n = c(50L, 100L)) -) -pg <- expand_tibble(proc = c("t.test"), conf.level = c(0.8, 0.9, 0.95)) -et <- eval_tibbles(dg, pg, - ncpus = 1, - replications = 10^1, - post_analyze = function(ttest, .truth) { - ttest$conf.int[1] <= .truth && .truth <= ttest$conf.int[2] - }, - summary_fun = list(mean = mean, sd = sd) -) -et
    #> # A tibble: 24 x 9 -#> fun rate .truth n replications summary_fun proc conf.level value -#> <chr> <dbl> <dbl> <int> <int> <chr> <chr> <dbl> <dbl> -#> 1 rexp 10 0.1 50 1 mean t.test 0.8 0.9 -#> 2 rexp 10 0.1 50 1 mean t.test 0.9 0.9 -#> 3 rexp 10 0.1 50 1 mean t.test 0.95 1 -#> 4 rexp 10 0.1 50 1 sd t.test 0.8 0.316 -#> 5 rexp 10 0.1 50 1 sd t.test 0.9 0.316 -#> 6 rexp 10 0.1 50 1 sd t.test 0.95 0 -#> 7 rexp 10 0.1 100 1 mean t.test 0.8 0.6 -#> 8 rexp 10 0.1 100 1 mean t.test 0.9 0.7 -#> 9 rexp 10 0.1 100 1 mean t.test 0.95 0.8 -#> 10 rexp 10 0.1 100 1 sd t.test 0.8 0.516 -#> # … with 14 more rows -#> Number of data generating functions: 4 -#> Number of analyzing procedures: 3 -#> Number of replications: 10 -#> Estimated replications per hour: 249072 -#> Start of the simulation: 2020-09-23 18:15:26 -#> End of the simulation: 2020-09-23 18:15:26
    ### need to remove the locally adapted eval_tibbles() -### otherwise executing the examples would mask -### eval_tibbles from simTool-namespace. -rm(eval_tibbles)
    -
    - -
    - - -
    - - -
    -

    Site built with pkgdown 1.5.1.

    -
    - -
    -
    - - - - - - - - diff --git a/docs/reference/expand_tibble.html b/docs/reference/expand_tibble.html deleted file mode 100644 index 5274430..0000000 --- a/docs/reference/expand_tibble.html +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - -Creates a <code>tibble</code> from All Combinations — expand_tibble • simTool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    Actually a wrapper for expand.grid, but - character vectors will stay as characters.

    -
    - -
    expand_tibble(...)
    - -

    Arguments

    - - - - - - -
    ...

    vectors, factors or a list containing these.

    - -

    Value

    - -

    See expand.grid but instead of a - data.frame - a tibble is returned.

    -

    See also

    - - - -

    Examples

    -
    -expand_tibble(fun = "rnorm", mean = 1:4, sd = 2:5)
    #> # A tibble: 16 x 3 -#> fun mean sd -#> <chr> <int> <int> -#> 1 rnorm 1 2 -#> 2 rnorm 2 2 -#> 3 rnorm 3 2 -#> 4 rnorm 4 2 -#> 5 rnorm 1 3 -#> 6 rnorm 2 3 -#> 7 rnorm 3 3 -#> 8 rnorm 4 3 -#> 9 rnorm 1 4 -#> 10 rnorm 2 4 -#> 11 rnorm 3 4 -#> 12 rnorm 4 4 -#> 13 rnorm 1 5 -#> 14 rnorm 2 5 -#> 15 rnorm 3 5 -#> 16 rnorm 4 5
    -
    - -
    - - -
    - - -
    -

    Site built with pkgdown 1.5.1.

    -
    - -
    -
    - - - - - - - - diff --git a/docs/reference/index.html b/docs/reference/index.html deleted file mode 100644 index 3ff5d81..0000000 --- a/docs/reference/index.html +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - -Function reference • simTool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    Define functions for generating and analyzing data

    -

    -
    -

    expand_tibble()

    -

    Creates a tibble from All Combinations

    -

    Perfom the simulation (on more than one CPU or a cluster)

    -

    -
    -

    eval_tibbles()

    -

    Workhorse for simulation studies

    -
    - - -
    - - -
    - - -
    -

    Site built with pkgdown 1.5.1.

    -
    - -
    -
    - - - - - - - - diff --git a/docs/reference/print.eval_tibbles.html b/docs/reference/print.eval_tibbles.html deleted file mode 100644 index cad9192..0000000 --- a/docs/reference/print.eval_tibbles.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - - -Printing simulation results — print.eval_tibbles • simTool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    Prints objects created by eval_tibbles()

    -
    - -
    # S3 method for eval_tibbles
    -print(x, ...)
    - -

    Arguments

    - - - - - - - - - - -
    x

    object of class eval_tibbles

    ...

    not used. only necessary to define the function consistently -with respect to print(x, ...)

    - - -
    - -
    - - -
    - - -
    -

    Site built with pkgdown 1.5.1.

    -
    - -
    -
    - - - - - - - - diff --git a/docs/reference/simTool-package.html b/docs/reference/simTool-package.html deleted file mode 100644 index 49ee17c..0000000 --- a/docs/reference/simTool-package.html +++ /dev/null @@ -1,243 +0,0 @@ - - - - - - - - -Conduct Simulation Studies with a Minimal Amount of Source Code — simTool-package • simTool - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - -
    - -
    -
    - - -
    -

    The simTool package is designed for statistical simulations that -have two components. One component generates the data and the other one -analyzes the data. The main aims of the simTool package are the -reduction -of the administrative source code (mainly loops and management code for the -results) and a simple applicability of the package that allows the user to -quickly learn how to work with the simTool package. Parallel -computing is -also supported. Finally, convenient functions are provided to summarize the -simulation results.

    -
    - - - -

    Details

    - - - - - - - - -
    Package:simTool
    Type:Package
    Version:1.0.3
    Date:2013-02-21
    License:GPL-3
    -

    evalGrids is the workhorse. as.data.frame is function - coercing the result object of evalGrids to - a data.frame. expandGrid is only a convenient function

    - -

    Examples

    -
    -dg <- expand_tibble(fun = "rexp", n = c(10, 20), rate = 1:2) -pg <- expand_tibble(proc = "summary") -eval_tibbles(dg, pg, replications = 3)
    #> # A tibble: 12 x 6 -#> fun n rate replications proc results -#> <chr> <dbl> <int> <int> <chr> <list> -#> 1 rexp 10 1 1 summary <table [6]> -#> 2 rexp 10 1 2 summary <table [6]> -#> 3 rexp 10 1 3 summary <table [6]> -#> 4 rexp 20 1 1 summary <table [6]> -#> 5 rexp 20 1 2 summary <table [6]> -#> 6 rexp 20 1 3 summary <table [6]> -#> 7 rexp 10 2 1 summary <table [6]> -#> 8 rexp 10 2 2 summary <table [6]> -#> 9 rexp 10 2 3 summary <table [6]> -#> 10 rexp 20 2 1 summary <table [6]> -#> 11 rexp 20 2 2 summary <table [6]> -#> 12 rexp 20 2 3 summary <table [6]> -#> Number of data generating functions: 4 -#> Number of analyzing procedures: 1 -#> Number of replications: 3 -#> Estimated replications per hour: 2080202 -#> Start of the simulation: 2020-05-16 19:03:17 -#> End of the simulation: 2020-05-16 19:03:17
    eval_tibbles(dg, pg, replications = 3, summary_fun = list(mean = mean))
    #> # A tibble: 4 x 12 -#> fun n rate replications summary_fun proc Min. `1st Qu.` Median Mean -#> <chr> <dbl> <int> <int> <chr> <chr> <dbl> <dbl> <dbl> <dbl> -#> 1 rexp 10 1 1 mean summ… 0.0735 0.307 0.593 0.757 -#> 2 rexp 20 1 1 mean summ… 0.0255 0.458 0.724 0.906 -#> 3 rexp 10 2 1 mean summ… 0.0240 0.125 0.243 0.538 -#> 4 rexp 20 2 1 mean summ… 0.0115 0.184 0.423 0.520 -#> # … with 2 more variables: `3rd Qu.` <dbl>, Max. <dbl> -#> Number of data generating functions: 4 -#> Number of analyzing procedures: 1 -#> Number of replications: 3 -#> Estimated replications per hour: 622796 -#> Start of the simulation: 2020-05-16 19:03:17 -#> End of the simulation: 2020-05-16 19:03:17
    eval_tibbles(dg, pg, replications = 3, - summary_fun = list(mean = mean, sd = sd))
    #> # A tibble: 8 x 12 -#> fun n rate replications summary_fun proc Min. `1st Qu.` Median Mean -#> <chr> <dbl> <int> <int> <chr> <chr> <dbl> <dbl> <dbl> <dbl> -#> 1 rexp 10 1 1 mean summ… 0.0612 0.331 0.697 0.934 -#> 2 rexp 10 1 1 sd summ… 0.0517 0.0561 0.224 0.255 -#> 3 rexp 20 1 1 mean summ… 0.0439 0.282 0.694 0.876 -#> 4 rexp 20 1 1 sd summ… 0.0388 0.0239 0.264 0.278 -#> 5 rexp 10 2 1 mean summ… 0.0289 0.0998 0.430 0.529 -#> 6 rexp 10 2 1 sd summ… 0.0206 0.0279 0.406 0.289 -#> 7 rexp 20 2 1 mean summ… 0.0132 0.187 0.392 0.492 -#> 8 rexp 20 2 1 sd summ… 0.0101 0.0648 0.161 0.176 -#> # … with 2 more variables: `3rd Qu.` <dbl>, Max. <dbl> -#> Number of data generating functions: 4 -#> Number of analyzing procedures: 1 -#> Number of replications: 3 -#> Estimated replications per hour: 430229 -#> Start of the simulation: 2020-05-16 19:03:17 -#> End of the simulation: 2020-05-16 19:03:17
    -
    - -
    - - -
    - - -
    -

    Site built with pkgdown 1.5.1.

    -
    - -
    -
    - - - - - - - - diff --git a/docs/sitemap.xml b/docs/sitemap.xml deleted file mode 100644 index e1af83e..0000000 --- a/docs/sitemap.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - http://MarselScheer.github.io/simTool/index.html - - - http://MarselScheer.github.io/simTool/reference/eval_tibbles.html - - - http://MarselScheer.github.io/simTool/reference/expand_tibble.html - - - http://MarselScheer.github.io/simTool/reference/print.eval_tibbles.html - - - http://MarselScheer.github.io/simTool/articles/simTool.html - - diff --git a/man/expand_tibble.Rd b/man/expand_tibble.Rd index 157cc0d..be6c7e9 100644 --- a/man/expand_tibble.Rd +++ b/man/expand_tibble.Rd @@ -12,7 +12,7 @@ expand_tibble(...) \value{ See \code{\link{expand.grid}} but instead of a \code{\link{data.frame}} - a \code{\link{tibble}} is returned. + a \code{\link[tibble:tibble]{tibble}} is returned. } \description{ Actually a wrapper for \code{\link{expand.grid}}, but diff --git a/man/print.eval_tibbles.Rd b/man/print.eval_tibbles.Rd index d16ef8b..d9461e2 100644 --- a/man/print.eval_tibbles.Rd +++ b/man/print.eval_tibbles.Rd @@ -18,3 +18,4 @@ Prints objects created by \code{eval_tibbles()} \author{ Marsel Scheer } +\keyword{internal} diff --git a/renv.lock b/renv.lock index 93e7e1b..b53ce07 100644 --- a/renv.lock +++ b/renv.lock @@ -1,6 +1,6 @@ { "R": { - "Version": "4.0.2", + "Version": "4.1.0", "Repositories": [ { "Name": "CRAN", @@ -11,24 +11,24 @@ "Packages": { "MASS": { "Package": "MASS", - "Version": "7.3-51.5", + "Version": "7.3-54", "Source": "Repository", "Repository": "CRAN", - "Hash": "9efe80472b21189ebab1b74169808c26" + "Hash": "0e59129db205112e3963904db67fd0dc" }, "Matrix": { "Package": "Matrix", - "Version": "1.2-18", + "Version": "1.3-4", "Source": "Repository", - "Repository": "CRAN", - "Hash": "08588806cba69f04797dab50627428ed" + "Repository": "RSPM", + "Hash": "4ed05e9c9726267e4a5872e09c04587c" }, "R6": { "Package": "R6", - "Version": "2.4.1", + "Version": "2.5.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "292b54f8f4b94669b08f94e5acce6be2" + "Hash": "470851b6d5d0ac559e9d01bb352b4021" }, "RColorBrewer": { "Package": "RColorBrewer", @@ -37,13 +37,6 @@ "Repository": "CRAN", "Hash": "e031418365a7f7a766181ab5a41a5716" }, - "Rcpp": { - "Package": "Rcpp", - "Version": "1.0.4.6", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "e652f23d8b1807cc975c51410d05b72f" - }, "askpass": { "Package": "askpass", "Version": "1.1", @@ -51,26 +44,12 @@ "Repository": "CRAN", "Hash": "e8a22846fff485f0be3770c2da758713" }, - "assertthat": { - "Package": "assertthat", - "Version": "0.2.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "50c838a310445e954bc13f26f26a6ecf" - }, "backports": { "Package": "backports", - "Version": "1.1.7", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "e9c8188eb82b137301493492d767a1ac" - }, - "badgecreatr": { - "Package": "badgecreatr", - "Version": "0.2.0", + "Version": "1.2.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "5db59479f84ad4a0650e74a8d8edac70" + "Hash": "644043219fc24e190c2f620c1a380a69" }, "base64enc": { "Package": "base64enc", @@ -81,80 +60,136 @@ }, "boot": { "Package": "boot", - "Version": "1.3-24", + "Version": "1.3-28", "Source": "Repository", "Repository": "CRAN", - "Hash": "72557d88b5f42f01221dfa436de99301" + "Hash": "0baa960e3b49c6176a4f42addcbacc59" + }, + "brio": { + "Package": "brio", + "Version": "1.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2f01e16ff9571fe70381c7b9ae560dc4" }, "broom": { "Package": "broom", - "Version": "0.5.6", + "Version": "0.7.9", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "9b1e2c1f75b349e3ffa7e9c69eec0c52" + }, + "cachem": { + "Package": "cachem", + "Version": "1.0.6", "Source": "Repository", "Repository": "CRAN", - "Hash": "754fdb4d17d4ae871343ff2909728ca3" + "Hash": "648c5b3d71e6a37e3043617489a0a0e9" }, "callr": { "Package": "callr", - "Version": "3.4.3", + "Version": "3.7.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "643163a00cb536454c624883a10ae0bc" + "Hash": "461aa75a11ce2400245190ef5d3995df" }, "cli": { "Package": "cli", - "Version": "2.0.2", + "Version": "3.0.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "ff0becff7bfdfe3f75d29aff8f3172dd" + "Hash": "e3ae5d68dea0c55a12ea12a9fda02e61" + }, + "codetools": { + "Package": "codetools", + "Version": "0.2-18", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "019388fc48e48b3da0d3a76ff94608a8" }, "colorspace": { "Package": "colorspace", - "Version": "1.4-1", + "Version": "2.0-2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6baccb763ee83c0bd313460fdb8b8a84" + }, + "covr": { + "Package": "covr", + "Version": "3.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6d80a9fc3c0c8473153b54fa54719dfd" + }, + "cpp11": { + "Package": "cpp11", + "Version": "0.3.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "6b436e95723d1f0e861224dd9b094dfb" + "Hash": "e02edab2bc389c5e4b12949b13df44f2" }, "crayon": { "Package": "crayon", - "Version": "1.3.4", + "Version": "1.4.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "0d57bc8e27b7ba9e45dba825ebc0de6b" + "Hash": "e75525c55c70e5f4f78c9960a4b402e9" }, "curl": { "Package": "curl", - "Version": "4.3", + "Version": "4.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "022c42d49c28e95d69ca60446dbabf88" + }, + "cyclocomp": { + "Package": "cyclocomp", + "Version": "1.1.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "2b7d10581cc730804e9ed178c8374bd6" + "Hash": "53cbed70a2f7472d48fb6aef08442f25" }, "desc": { "Package": "desc", - "Version": "1.2.0", + "Version": "1.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b6963166f7f10b970af1006c462ce6cd" + }, + "diffobj": { + "Package": "diffobj", + "Version": "0.3.4", "Source": "Repository", "Repository": "CRAN", - "Hash": "6c8fe8fa26a23b79949375d372c7b395" + "Hash": "feb5b7455eba422a2c110bb89852e6a3" }, "digest": { "Package": "digest", - "Version": "0.6.25", + "Version": "0.6.27", "Source": "Repository", "Repository": "CRAN", - "Hash": "f697db7d92b7028c4b3436e9603fb636" + "Hash": "a0cbe758a531d054b537d16dff4d58a1" + }, + "downlit": { + "Package": "downlit", + "Version": "0.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f24f1e44320a978c03050b8403a83793" }, "dplyr": { "Package": "dplyr", - "Version": "1.0.0", + "Version": "1.0.7", "Source": "Repository", "Repository": "CRAN", - "Hash": "4011f62581a34080e44105d4aa05a97f" + "Hash": "36f1ae62f026c8ba9f9b5c9a08c03297" }, "ellipsis": { "Package": "ellipsis", - "Version": "0.3.1", + "Version": "0.3.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "fd2844b3a43ae2d27e70ece2df1b4e2a" + "Hash": "bb0eec2fe32e88d9e2836c2f73ea2077" }, "evaluate": { "Package": "evaluate", @@ -165,52 +200,52 @@ }, "fansi": { "Package": "fansi", - "Version": "0.4.1", + "Version": "0.5.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "7fce217eaaf8016e72065e85c73027b5" + "Hash": "d447b40982c576a72b779f0a3b3da227" }, "farver": { "Package": "farver", - "Version": "2.0.3", + "Version": "2.1.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "dad6793a5a1f73c8e91f1a1e3e834b05" + "Hash": "c98eb5133d9cb9e1622b8691487f11bb" + }, + "fastmap": { + "Package": "fastmap", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "77bd60a6157420d4ffa93b27cf6a58b8" }, "fs": { "Package": "fs", - "Version": "1.4.1", + "Version": "1.5.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "780713bd2f53156fae001443dcdbdcd5" + "Hash": "44594a07a42e5f91fac9f93fda6d0109" }, "generics": { "Package": "generics", - "Version": "0.0.2", + "Version": "0.1.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "b8cff1d1391fd1ad8b65877f4c7f2e53" + "Hash": "4d243a9c10b00589889fe32314ffd902" }, "ggplot2": { "Package": "ggplot2", - "Version": "3.3.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "dd6dc5b9ef202cef18c5200d76e1634c" - }, - "git2r": { - "Package": "git2r", - "Version": "0.27.1", + "Version": "3.3.5", "Source": "Repository", "Repository": "CRAN", - "Hash": "531a82d1beed1f545beb25f4f5945bf7" + "Hash": "d7566c471c7b17e095dd023b9ef155ad" }, "glue": { "Package": "glue", - "Version": "1.4.1", + "Version": "1.4.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "f43e0d5e85ccb0a4045670c0607ee504" + "Hash": "6efd734b14c6471cfe443345f3e35e29" }, "gtable": { "Package": "gtable", @@ -219,82 +254,89 @@ "Repository": "CRAN", "Hash": "ac5c6baf7822ce8732b343f14c072c4d" }, - "highlight": { - "Package": "highlight", - "Version": "0.5.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "88eee986f41177f688ffd11189cb3aec" - }, "highr": { "Package": "highr", - "Version": "0.8", + "Version": "0.9", "Source": "Repository", "Repository": "CRAN", - "Hash": "4dc5bb88961e347a0f4d8aad597cbfac" + "Hash": "8eb36c8125038e648e5d111c0d7b2ed4" }, "htmltools": { "Package": "htmltools", - "Version": "0.4.0", + "Version": "0.5.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "2d7691222f82f41e93f6d30f169bd5e1" + "Hash": "526c484233f42522278ab06fb185cb26" }, "httr": { "Package": "httr", - "Version": "1.4.1", + "Version": "1.4.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "7146fea4685b4252ebf478978c75f597" + "Hash": "a525aba14184fec243f9eaec62fbed43" }, "isoband": { "Package": "isoband", - "Version": "0.2.1", + "Version": "0.2.5", "Source": "Repository", "Repository": "CRAN", - "Hash": "9b2f7cf1899f583a36d367702ecf49a3" + "Hash": "7ab57a6de7f48a8dc84910d1eca42883" }, "jsonlite": { "Package": "jsonlite", - "Version": "1.6.1", + "Version": "1.7.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "84b0ee361e2f78d6b7d670db9471c0c5" + "Hash": "98138e0994d41508c7a6b84a0600cfcb" }, "knitr": { "Package": "knitr", - "Version": "1.28", + "Version": "1.33", "Source": "Repository", "Repository": "CRAN", - "Hash": "915a6f0134cdbdf016d7778bc80b2eda" + "Hash": "0bc1b5da1b0eb07cd4b727e95e9ff0b8" }, "labeling": { "Package": "labeling", - "Version": "0.3", + "Version": "0.4.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "73832978c1de350df58108c745ed0e3e" + "Hash": "3d5108641f47470611a32d0bdf357a72" }, "lattice": { "Package": "lattice", - "Version": "0.20-41", + "Version": "0.20-44", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f36bf1a849d9106dc2af72e501f9de41" + }, + "lazyeval": { + "Package": "lazyeval", + "Version": "0.2.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "fbd9285028b0263d76d18c95ae51a53d" + "Hash": "d908914ae53b04d4c0c0fd72ecc35370" }, "lifecycle": { "Package": "lifecycle", - "Version": "0.2.0", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3471fb65971f1a7b2d4ae7848cf2db8d" + }, + "lintr": { + "Package": "lintr", + "Version": "2.0.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "361811f31f71f8a617a9a68bf63f1f42" + "Hash": "023cecbdc0a32f86ad3cb1734c018d2e" }, "magrittr": { "Package": "magrittr", - "Version": "1.5", + "Version": "2.0.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "1bb58822a20301cee84a41678e25d9b7" + "Hash": "41287f1ac7d28a92f0a286ed507928d3" }, "markdown": { "Package": "markdown", @@ -305,24 +347,31 @@ }, "memoise": { "Package": "memoise", - "Version": "1.1.0", + "Version": "2.0.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "58baa74e4603fcfb9a94401c58c8f9b1" + "Hash": "a0bc51650201a56d00a4798523cc91b3" }, "mgcv": { "Package": "mgcv", - "Version": "1.8-31", + "Version": "1.8-36", + "Source": "Repository", + "Repository": "RSPM", + "Hash": "93cc747b0e1ad882a4570463c3575c23" + }, + "microbenchmark": { + "Package": "microbenchmark", + "Version": "1.4-7", "Source": "Repository", "Repository": "CRAN", - "Hash": "4bb7e0c4f3557583e1e8d3c9ffb8ba5c" + "Hash": "9ffe05828082333ec03d1669e5ca47b9" }, "mime": { "Package": "mime", - "Version": "0.9", + "Version": "0.11", "Source": "Repository", "Repository": "CRAN", - "Hash": "e87a35ec73b157552814869f45a63aa3" + "Hash": "8974a907200fc9948d636fe7d85ca9fb" }, "munsell": { "Package": "munsell", @@ -333,31 +382,24 @@ }, "nlme": { "Package": "nlme", - "Version": "3.1-147", + "Version": "3.1-152", "Source": "Repository", "Repository": "CRAN", - "Hash": "dd4a1423f1472a2a8e05dd2c8945c3af" + "Hash": "35de1ce639f20b5e10f7f46260730c65" }, "openssl": { "Package": "openssl", - "Version": "1.4.1", + "Version": "1.4.5", "Source": "Repository", "Repository": "CRAN", - "Hash": "49f7258fd86ebeaea1df24d9ded00478" + "Hash": "5406fd37ef0bf9b88c8a4f264d6ec220" }, "pillar": { "Package": "pillar", - "Version": "1.4.4", + "Version": "1.6.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "b01d2494d0e2b6b02fae40e1543fbcb0" - }, - "pkgbuild": { - "Package": "pkgbuild", - "Version": "1.0.8", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "8d8b5e29223aabb829246397299f0592" + "Hash": "43f228eb4b49093d1c8a5c93cae9efe9" }, "pkgconfig": { "Package": "pkgconfig", @@ -368,24 +410,17 @@ }, "pkgdown": { "Package": "pkgdown", - "Version": "1.5.1", + "Version": "1.6.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "df386e7004001a999d1494cb4538c9bc" + "Hash": "8896076540d9e9b556a2ec658c81f916" }, "pkgload": { "Package": "pkgload", - "Version": "1.1.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "b6b150cd4709e0c0c9b5d51ac4376282" - }, - "plyr": { - "Package": "plyr", - "Version": "1.8.6", + "Version": "1.2.1", "Source": "Repository", - "Repository": "CRAN", - "Hash": "ec0e5ab4e5f851f6ef32cd1d1984957f" + "Repository": "RSPM", + "Hash": "463642747f81879e6752485aefb831cf" }, "praise": { "Package": "praise", @@ -394,26 +429,19 @@ "Repository": "CRAN", "Hash": "a555924add98c99d2f411e37e7d25e9f" }, - "prettyunits": { - "Package": "prettyunits", - "Version": "1.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "95ef9167b75dde9d2ccc3c7528393e7e" - }, "processx": { "Package": "processx", - "Version": "3.4.2", + "Version": "3.5.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "20a082f2bde0ffcd8755779fd476a274" + "Hash": "0cbca2bc4d16525d009c4dbba156b37c" }, "ps": { "Package": "ps", - "Version": "1.3.3", + "Version": "1.6.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "425d938eb9c02906a8ac98c0c2a306b5" + "Hash": "32620e2001c1dce1af49c49dccbb9420" }, "purrr": { "Package": "purrr", @@ -422,6 +450,13 @@ "Repository": "CRAN", "Hash": "97def703420c8ab10d8f0e6c72101e02" }, + "ragg": { + "Package": "ragg", + "Version": "1.1.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "663065eff8c6c08eaa9955c6f478ee7a" + }, "rematch2": { "Package": "rematch2", "Version": "2.1.2", @@ -429,47 +464,54 @@ "Repository": "CRAN", "Hash": "76c9e04c712a05848ae7a23d2f170a40" }, + "remotes": { + "Package": "remotes", + "Version": "2.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a85ebb35721573b196317b49ddd2dfe4" + }, "renv": { "Package": "renv", - "Version": "0.11.0", + "Version": "0.14.0", "Source": "Repository", - "Repository": "RSPM", - "Hash": "1c3ef87cbb81c23ac96797781ec7aecc" + "Repository": "CRAN", + "Hash": "30e5eba91b67f7f4d75d31de14bbfbdc" }, - "reshape2": { - "Package": "reshape2", - "Version": "1.4.4", + "rex": { + "Package": "rex", + "Version": "1.2.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "bb5996d0bd962d214a11140d77589917" + "Hash": "093584b944440c5cd07a696b3c8e0e4c" }, "rlang": { "Package": "rlang", - "Version": "0.4.6", + "Version": "0.4.11", "Source": "Repository", - "Repository": "CRAN", - "Hash": "aa263e3ce17b177c49e0daade2ee3cdc" + "Repository": "RSPM", + "Hash": "515f341d3affe0de9e4a7f762efb0456" }, "rmarkdown": { "Package": "rmarkdown", - "Version": "2.2", + "Version": "2.10", "Source": "Repository", "Repository": "CRAN", - "Hash": "aa82ab08b203d5a32a5b5f404e80c399" + "Hash": "1fb097f233ee98968f8e5d0bcd42df6d" }, "rprojroot": { "Package": "rprojroot", - "Version": "1.3-2", + "Version": "2.0.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "f6a407ae5dd21f6f80a6708bbb6eb3ae" + "Hash": "249d8cd1e74a8f6a26194a91b47f21d1" }, "rstudioapi": { "Package": "rstudioapi", - "Version": "0.11", + "Version": "0.13", "Source": "Repository", "Repository": "CRAN", - "Hash": "33a5b27a03da82ac4b1d43268f80088a" + "Hash": "06c85365a03fdaf699966cc1d3cf53ea" }, "scales": { "Package": "scales", @@ -480,10 +522,10 @@ }, "stringi": { "Package": "stringi", - "Version": "1.4.6", + "Version": "1.7.4", "Source": "Repository", "Repository": "CRAN", - "Hash": "e99d8d656980d2dd416a962ae55aec90" + "Hash": "ebaccb577da50829a3bb1b8296f318a5" }, "stringr": { "Package": "stringr", @@ -494,73 +536,94 @@ }, "sys": { "Package": "sys", - "Version": "3.3", + "Version": "3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b227d13e29222b4574486cfcbde077fa" + }, + "systemfonts": { + "Package": "systemfonts", + "Version": "1.0.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "507f3116a38d37ad330a038b3be07b66" + "Hash": "f2e17ba09737e2e7e2ec40fc1f9b6e08" }, "testthat": { "Package": "testthat", - "Version": "2.3.2", + "Version": "3.0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "575216c9946ca70016c3ffb9c31709ba" + }, + "textshaping": { + "Package": "textshaping", + "Version": "0.3.5", "Source": "Repository", "Repository": "CRAN", - "Hash": "0829b987b8961fb07f3b1b64a2fbc495" + "Hash": "6bb7e974b464fe72f192e51b4dab67f2" }, "tibble": { "Package": "tibble", - "Version": "3.0.1", + "Version": "3.1.4", "Source": "Repository", "Repository": "CRAN", - "Hash": "1c61e4cad000e03b1bd687db16a75926" + "Hash": "5e8ad5621e5c94b24ec07b88eee13df8" }, "tidyr": { "Package": "tidyr", - "Version": "1.1.0", + "Version": "1.1.3", "Source": "Repository", "Repository": "CRAN", - "Hash": "7395a05640bf91502dd475a84008d87e" + "Hash": "450d7dfaedde58e28586b854eeece4fa" }, "tidyselect": { "Package": "tidyselect", - "Version": "1.1.0", + "Version": "1.1.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "6ea435c354e8448819627cf686f66e0a" + "Hash": "7243004a708d06d4716717fa1ff5b2fe" }, "tinytest": { "Package": "tinytest", - "Version": "1.2.2", + "Version": "1.3.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "fb91119d9a21bf9897241fe74dad1a6b" + "Hash": "05d12b67ef20dd1043b4d4fd24d3cd73" }, "tinytex": { "Package": "tinytex", - "Version": "0.23", + "Version": "0.33", "Source": "Repository", "Repository": "CRAN", - "Hash": "a8c653ef8ce67683f588e6088ed45572" + "Hash": "6e0ad90ac5669e35d5456cb61b295acb" }, "utf8": { "Package": "utf8", - "Version": "1.1.4", + "Version": "1.2.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "4a5081acfb7b81a572e4384a7aaf2af1" + "Hash": "c9c462b759a5cc844ae25b5942654d13" }, "vctrs": { "Package": "vctrs", - "Version": "0.3.1", + "Version": "0.3.8", "Source": "Repository", "Repository": "CRAN", - "Hash": "1739235995f08583db4095a28c357207" + "Hash": "ecf749a1b39ea72bd9b51b76292261f1" }, "viridisLite": { "Package": "viridisLite", + "Version": "0.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "55e157e2aa88161bdb0754218470d204" + }, + "waldo": { + "Package": "waldo", "Version": "0.3.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "ce4f6271baa94776db692f1cb2055bee" + "Hash": "312b264fae22fdba83b7a74187a24da8" }, "whisker": { "Package": "whisker", @@ -571,17 +634,17 @@ }, "withr": { "Package": "withr", - "Version": "2.2.0", + "Version": "2.4.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "ecd17882a0b4419545691e095b74ee89" + "Hash": "ad03909b44677f930fa156d47d7a3aeb" }, "xfun": { "Package": "xfun", - "Version": "0.14", + "Version": "0.25", "Source": "Repository", "Repository": "CRAN", - "Hash": "60e146e3aba37a547e12306dc3da77a6" + "Hash": "853d45ffff0a9af1e0af017cd359f75e" }, "xml2": { "Package": "xml2", @@ -590,6 +653,13 @@ "Repository": "CRAN", "Hash": "d4d71a75dd3ea9eb5fa28cc21f9585e2" }, + "xmlparsedata": { + "Package": "xmlparsedata", + "Version": "1.0.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "45e4bf3c46476896e821fc0a408fb4fc" + }, "yaml": { "Package": "yaml", "Version": "2.2.1", diff --git a/vignettes/simTool.Rmd b/vignettes/simTool.Rmd index 7bc6d66..903b8fb 100644 --- a/vignettes/simTool.Rmd +++ b/vignettes/simTool.Rmd @@ -559,8 +559,8 @@ post_analyze <- function(o, .truth) { #post-process the object returned by boot.ci method = c("normal", "basic", "student", "percent", "bca") ret = o[method] - lower = unlist(purrr::map(ret, ~dplyr::nth(.x, -2))) - upper = sapply(ret, dplyr::last) + lower = unlist(purrr::map(ret, ~dplyr::nth(.x[1,], -2))) + upper = unlist(purrr::map(ret, ~dplyr::nth(.x[1,], -1))) type = paste("boot", method, sep = "_") return( @@ -657,8 +657,8 @@ bootstrap_ci <- function(x, conf.level, R = 999) { ci <- boot::boot.ci(b, conf = conf.level, type = "all") method = c("normal", "basic", "student", "percent", "bca") ret = ci[method] - lower = unlist(purrr::map(ret, ~dplyr::nth(.x, -2))) - upper = sapply(ret, dplyr::last) + lower = unlist(purrr::map(ret, ~dplyr::nth(.x[1,], -2))) + upper = unlist(purrr::map(ret, ~dplyr::nth(.x[1,], -1))) type = paste("boot", method, sep = "_") # unify return