├── .Rbuildignore ├── .github └── workflows │ └── draft-pdf.yml ├── .gitignore ├── CRAN-RELEASE ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── NEWS.Rmd ├── NEWS.md ├── R ├── RcppExports.R ├── data.R ├── plot_multiverse.R ├── splithalf.R ├── splithalf_multiverse.R ├── testretest_multiverse.R ├── threshold.R └── zzz.R ├── README.Rmd ├── README.md ├── cran-comments.md ├── data └── speedtestdata.rda ├── inst ├── CITATION ├── book.bib └── hexlogo │ └── splithalf_logo.png ├── man ├── figures │ ├── README-multiverse_plot-1.png │ ├── README-plotting_distribution-1.png │ └── README-speedtest-1.png ├── multiverse.plot.Rd ├── speedtestdata.Rd ├── splithalf.Rd ├── splithalf.multiverse.Rd └── testretest.multiverse.Rd ├── paper.md ├── r-references.bib ├── splithalf.Rproj ├── src ├── .gitignore ├── RcppExports.cpp ├── Speedloop.cpp └── splithalf_init.c └── vignettes ├── .gitignore └── sim-validation.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^README\.Rmd$ 4 | ^README-.*\.png$ 5 | ^cran-comments\.md$ 6 | ^NEWS\.Rmd$ 7 | ^testing$ 8 | ^depreciated$ 9 | ^CRAN-RELEASE$ 10 | plans/ 11 | book.bib 12 | READMEfigures/ 13 | paper.md 14 | r-references.bib 15 | LICENSE 16 | .github/ 17 | -------------------------------------------------------------------------------- /.github/workflows/draft-pdf.yml: -------------------------------------------------------------------------------- 1 | on: [push] 2 | 3 | jobs: 4 | paper: 5 | runs-on: ubuntu-latest 6 | name: Paper Draft 7 | steps: 8 | - name: Checkout 9 | uses: actions/checkout@v2 10 | - name: Build draft PDF 11 | uses: openjournals/openjournals-draft-action@master 12 | with: 13 | journal: joss 14 | # This should be the path to the paper within your repo. 15 | paper-path: paper.md 16 | - name: Upload 17 | uses: actions/upload-artifact@v1 18 | with: 19 | name: paper 20 | # This is the output path where Pandoc will write the compiled 21 | # PDF. Note, this should be the same directory as the input 22 | # paper.md 23 | path: paper.pdf 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | inst/doc 6 | testing/ 7 | depreciated/ 8 | R/ICC.R 9 | plans/ 10 | validation/ 11 | ^testing$ 12 | -------------------------------------------------------------------------------- /CRAN-RELEASE: -------------------------------------------------------------------------------- 1 | This package was submitted to CRAN on 2021-01-08. 2 | Once it is accepted, delete this file and tag the release (commit 0ce1828476). 3 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: splithalf 2 | Type: Package 3 | Title: Calculate Task Split Half Reliability Estimates 4 | Version: 0.8.2 5 | Authors@R: person("Sam", "Parsons", email = "sam.parsons@radboudumc.nl", 6 | role = c("aut", "cre")) 7 | Maintainer: Sam Parsons 8 | Description: Estimate the internal consistency of your tasks with a permutation based split-half reliability approach. 9 | Unofficial release name: "I eat stickers all the time, dude!". 10 | Depends: R (>= 3.5) 11 | Imports: 12 | tidyr, 13 | dplyr, 14 | stats, 15 | Rcpp, 16 | robustbase, 17 | ggplot2, 18 | plyr, 19 | grid, 20 | patchwork, 21 | psych, 22 | lme4, 23 | methods 24 | LinkingTo: Rcpp 25 | Suggests: 26 | knitr, 27 | rmarkdown, 28 | tools, 29 | License: GPL-3 30 | Encoding: UTF-8 31 | LazyData: true 32 | RoxygenNote: 7.1.1 33 | URL: https://github.com/sdparsons/splithalf 34 | BugReports: https://github.com/sdparsons/splithalf 35 | VignetteBuilder: knitr 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(multiverse.plot) 4 | export(splithalf) 5 | export(splithalf.multiverse) 6 | export(testretest.multiverse) 7 | export(threshold) 8 | import(Rcpp) 9 | import(ggplot2) 10 | import(grid) 11 | import(lme4) 12 | import(patchwork) 13 | import(tidyr) 14 | importFrom(Rcpp,sourceCpp) 15 | importFrom(dplyr,count) 16 | importFrom(dplyr,filter) 17 | importFrom(dplyr,group_by) 18 | importFrom(dplyr,mutate) 19 | importFrom(dplyr,n) 20 | importFrom(dplyr,n_distinct) 21 | importFrom(dplyr,select) 22 | importFrom(dplyr,summarise) 23 | importFrom(dplyr,ungroup) 24 | importFrom(methods,is) 25 | importFrom(plyr,arrange) 26 | importFrom(psych,ICC) 27 | importFrom(robustbase,colMedians) 28 | importFrom(stats,complete.cases) 29 | importFrom(stats,cor) 30 | importFrom(stats,cor.test) 31 | importFrom(stats,median) 32 | importFrom(stats,na.omit) 33 | importFrom(stats,quantile) 34 | importFrom(stats,sd) 35 | importFrom(tidyr,complete) 36 | importFrom(tidyr,gather) 37 | importFrom(utils,capture.output) 38 | importFrom(utils,setTxtProgressBar) 39 | importFrom(utils,txtProgressBar) 40 | useDynLib(splithalf, .registration = TRUE) 41 | -------------------------------------------------------------------------------- /NEWS.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, echo = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "NEWS-" 12 | ) 13 | ``` 14 | 15 | 16 | UPCOMING: splithalf v0.8.2 [Unofficial version name: I eat stickers all the time, dude!] 17 | ============== 18 | changes: 19 | * added error checks for common issues - too few trials and missing conditions 20 | 21 | 22 | splithalf v0.8.1 [unofficial version name: Rum Ham] 23 | ============== 24 | changes: 25 | * added examples in the function help and improved function documentation 26 | * added validation vignette (tests many combinations of options within splithalf functions, incluing the multiverse functions) 27 | * fixed minor bugs in some combinations of options within splithalf (typically within the difference_of_difference or multiverse functions) 28 | * fixed some documentation 29 | * fixed plotting issue with score = "difference_of_difference" 30 | * minor improvements to documentation 31 | 32 | 33 | splithalf v0.7.2 [unofficial version name: Kitten Mittens] 34 | ============== 35 | changes: 36 | * minor updates: reworked documentation and README 37 | * added hexlogo 38 | * bug fixes to splithalf.multiverse 39 | 40 | 41 | splithalf v0.7.1 [unofficial version name: Kitten Mittens] 42 | ============== 43 | changes: 44 | * added multiverse analyses to package. Functions _splithalf.multiverse_, _testretest.multiverse_, _plot.multiverse_, and _threshold_ now available! 45 | 46 | 47 | splithalf v0.6.2 [unofficial version name: the Golden God] 48 | ============== 49 | changes: 50 | * added "sum" option to the average input. average = "sum" can now be used to calculate the sum score for accuracy (binary 0/1 values) 51 | 52 | 53 | splithalf v0.6.1 [unofficial version name: the Golden God] 54 | ============== 55 | changes: 56 | * added DPrime option, this is still under development 57 | * the structure of splithalf has changed to include additional elements in the output list - intended to make the future reliability multiverse add-on easier to use 58 | * added a basic plotting functionality, setting plot = TRUE will now give a raincloud plot of all estimates (based on code from Allen et al. https://wellcomeopenresearch.org/articles/4-63/v1) 59 | * added a 'round.to' option to specify the number of decimal points to round the estimates to 60 | 61 | 62 | splithalf v0.5.3 [unofficial version name: Fight Milk - rebrand] 63 | ============== 64 | changes: 65 | * updated code to allow for estimation of splithalf reliability of accuracy rates. (beta testing needed) 66 | * minor bug checks, fixed using spearman over pearson correlation. 67 | 68 | 69 | 70 | splithalf v0.5.2 [unofficial version name: Fight Milk - rebrand] 71 | ============== 72 | changes: 73 | * a guide to the package can be found here https://sdparsons.github.io/splithalf_documentation/ 74 | * bug fix to the spearman-brown correction, it now deals with negative splithalf estimates properly. 75 | * fixed error in splitting the sample in the halfs type of split (Thanks to Anne-Wil Kruijt for pointing out) 76 | * updated documentation 77 | 78 | 79 | splithalf v0.5.1 [unofficial version name: Fight Milk] 80 | ============== 81 | 82 | Changes: 83 | * all functions compressed into a single function "splithalf" 84 | * added utilities such as RT trimming have been removed, the function requires you use data that has been processed 85 | * added C++ code with Rcpp to massively speed up the function. 86 | 87 | 88 | 89 | splithalf v0.4.1 [unofficial version name: The nightman commeth] 90 | ============== 91 | I forgot to record changes because I am awful - lots of improvements mainly to speed things up 92 | 93 | 94 | 95 | splithalf v0.3.1 96 | ============== 97 | 98 | Changes: 99 | * added dplyr to dependencies 100 | * added splithalf functions for accuracy (currently development version) 101 | 102 | 103 | 104 | splithalf v0.3.0 105 | ============== 106 | 107 | Changes: 108 | 109 | * reworked the package into three main functions 110 | * more options added for flexibility to many RT tasks 111 | * progress bars added 112 | 113 | 114 | splithalf v0.2.0 (current development version) 115 | ============== 116 | 117 | Changes: 118 | 119 | * Added the TSTsplithalf function 120 | * Some minor bug fixes 121 | * Output for all functions now includes two-part alpha 122 | 123 | 124 | splithalf v0.2.0 (Release data: 07/04/2017) 125 | ============== 126 | 127 | Changes: 128 | 129 | * Submitted to CRAN 130 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # UPCOMING: splithalf v0.8.2 \[Unofficial version name: I eat stickers all the time, dude!\] 5 | 6 | changes: \*added error checks for common issues - too few trials and missing conditions 7 | 8 | 9 | # UPCOMING: splithalf v0.8.1 \[unofficial version name: Rum Ham\] 10 | 11 | changes: \* added examples in the function help and improved function 12 | documentation \* added validation vignette (tests many combinations of 13 | options within splithalf functions, incluing the multiverse functions) 14 | \* fixed minor bugs in some combinations of options within splithalf 15 | (typically within the ) \* fixed some documentation \* fixed plotting 16 | issue with score = “difference\_of\_difference” \* minor improvements to 17 | documentation 18 | 19 | # splithalf v0.7.2 \[unofficial version name: Kitten Mittens\] 20 | 21 | changes: \* minor updates: reworked documentation and README \* added 22 | hexlogo \* bug fixes to splithalf.multiverse 23 | 24 | # splithalf v0.7.1 \[unofficial version name: Kitten Mittens\] 25 | 26 | changes: \* added multiverse analyses to package. Functions 27 | *splithalf.multiverse*, *testretest.multiverse*, *plot.multiverse*, and 28 | *threshold* now available! 29 | 30 | # splithalf v0.6.2 \[unofficial version name: the Golden God\] 31 | 32 | changes: \* added “sum” option to the average input. average = “sum” can 33 | now be used to calculate the sum score for accuracy (binary 0/1 values) 34 | 35 | # splithalf v0.6.1 \[unofficial version name: the Golden God\] 36 | 37 | changes: \* added DPrime option, this is still under development \* the 38 | structure of splithalf has changed to include additional elements in the 39 | output list - intended to make the future reliability multiverse add-on 40 | easier to use \* added a basic plotting functionality, setting plot = 41 | TRUE will now give a raincloud plot of all estimates (based on code from 42 | Allen et al. ) \* 43 | added a ‘round.to’ option to specify the number of decimal points to 44 | round the estimates to 45 | 46 | # splithalf v0.5.3 \[unofficial version name: Fight Milk - rebrand\] 47 | 48 | changes: \* updated code to allow for estimation of splithalf 49 | reliability of accuracy rates. (beta testing needed) \* minor bug 50 | checks, fixed using spearman over pearson correlation. 51 | 52 | # splithalf v0.5.2 \[unofficial version name: Fight Milk - rebrand\] 53 | 54 | changes: \* a guide to the package can be found here 55 | \* bug fix to the 56 | spearman-brown correction, it now deals with negative splithalf 57 | estimates properly. \* fixed error in splitting the sample in the halfs 58 | type of split (Thanks to Anne-Wil Kruijt for pointing out) \* updated 59 | documentation 60 | 61 | # splithalf v0.5.1 \[unofficial version name: Fight Milk\] 62 | 63 | Changes: \* all functions compressed into a single function “splithalf” 64 | \* added utilities such as RT trimming have been removed, the function 65 | requires you use data that has been processed \* added C++ code with 66 | Rcpp to massively speed up the function. 67 | 68 | # splithalf v0.4.1 \[unofficial version name: The nightman commeth\] 69 | 70 | I forgot to record changes because I am awful - lots of improvements 71 | mainly to speed things up 72 | 73 | # splithalf v0.3.1 74 | 75 | Changes: \* added dplyr to dependencies \* added splithalf functions for 76 | accuracy (currently development version) 77 | 78 | # splithalf v0.3.0 79 | 80 | Changes: 81 | 82 | - reworked the package into three main functions 83 | - more options added for flexibility to many RT tasks 84 | - progress bars added 85 | 86 | # splithalf v0.2.0 (current development version) 87 | 88 | Changes: 89 | 90 | - Added the TSTsplithalf function 91 | - Some minor bug fixes 92 | - Output for all functions now includes two-part alpha 93 | 94 | # splithalf v0.2.0 (Release data: 07/04/2017) 95 | 96 | Changes: 97 | 98 | - Submitted to CRAN 99 | -------------------------------------------------------------------------------- /R/RcppExports.R: -------------------------------------------------------------------------------- 1 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | Speedloop <- function(A, x, y) { 5 | .Call(`_splithalf_Speedloop`, A, x, y) 6 | } 7 | 8 | -------------------------------------------------------------------------------- /R/data.R: -------------------------------------------------------------------------------- 1 | #' Simulated data for runtime of splithalf package 2 | #' 3 | #' This simulation was run to estimate the relative runtimes for different possible combinations of sample sizes and trial numbers etc. 4 | #' 5 | #' \itemize{ 6 | #' \item{Sim}{codes for the simulation number} 7 | #' \item{sample_size}{codes for the sample size} 8 | #' \item{Number_of_conditions}{codes for the number of conditions run} 9 | #' \item{trials}{codes for the number of trials} 10 | #' \item{permutations}{codes for the number of permutations} 11 | #' \item{runtime}{codes for the runtime in seconds} 12 | #' } 13 | #' 14 | #' @docType data 15 | #' @name speedtestdata 16 | #' @usage data(speedtestdata) 17 | #' @format A data frame with 225 rows and 6 variables 18 | NULL 19 | -------------------------------------------------------------------------------- /R/plot_multiverse.R: -------------------------------------------------------------------------------- 1 | #' Visualising reliability multiverses 2 | #' 3 | #' This function allows the user to plot the output from splithalf_multiverse or testretest_multiverse. The plot includes an upper panel with all reliability estimates (and CIs) and a lower panel that indicates the data processing specifications corresponding to that reliability estimate. 4 | #' The (unofficial) function version name is "This function will make you a master in bird law" 5 | #' @param multiverse multiverse object or list of multiverse objects from splithalf.multiverse() 6 | #' @param title string add a title to the plot? default is "" 7 | #' @param vline add a vertical line to the plot, e.g. use .5 for the median reliability estimate 8 | #' @param heights must be a vector of length 2, relative heights of plot panels. Defaults to c(4,5) 9 | #' @param SE logical includes an additional panel to plot the standard errors of the scores. Note: the heights parameter must be a vector of length 3, e.g. c(2,2,3). Defaults to FALSE 10 | #' @return Returns a visualization of a multiverse object 11 | #' @examples 12 | #' \dontrun{ 13 | #' ## see online documentation for examples 14 | #' https://github.com/sdparsons/splithalf 15 | #' ## also see https://psyarxiv.com/y6tcz 16 | #' 17 | #' ## example simulated data 18 | #' n_participants = 60 ## sample size 19 | #' n_trials = 80 20 | #' n_blocks = 2 21 | #' sim_data <- data.frame(participant_number = rep(1:n_participants, 22 | #' each = n_blocks * n_trials), 23 | #' trial_number = rep(1:n_trials, 24 | #' times = n_blocks * n_participants), 25 | #' block_name = rep(c("A","B"), 26 | #' each = n_trials, 27 | #' length.out = n_participants * n_trials * n_blocks), 28 | #' trial_type = rep(c("congruent","incongruent"), 29 | #' length.out = n_participants * n_trials * n_blocks), 30 | #' RT = rnorm(n_participants * n_trials * n_blocks, 31 | #' 500, 32 | #' 200), 33 | #' ACC = 1) 34 | #' 35 | #' ## specify several data processing decisions 36 | #' specifications <- list(RT_min = c(0, 100, 200), 37 | #' RT_max = c(1000, 2000), 38 | #' averaging_method = c("mean", "median")) 39 | #' ## run splithalf, and save the output 40 | #' difference <- splithalf(data = sim_data, 41 | #' outcome = "RT", 42 | #' score = "difference", 43 | #' conditionlist = c("A"), 44 | #' halftype = "random", 45 | #' permutations = 5000, 46 | #' var.RT = "RT", 47 | #' var.condition = "block_name", 48 | #' var.participant = "participant_number", 49 | #' var.compare = "trial_type", 50 | #' var.ACC = "ACC", 51 | #' compare1 = "congruent", 52 | #' compare2 = "incongruent", 53 | #' average = "mean") 54 | #' 55 | #' ## run splithalf.multiverse to perform the multiverse of data processing 56 | #' ## and reliability estimation 57 | #' multiverse <- splithalf.multiverse(input = difference, 58 | #' specifications = specifications) 59 | #' 60 | #' ## can be plot with: 61 | #' multiverse.plot(multiverse = multiverse, 62 | #' title = "README multiverse") 63 | #' 64 | #' } 65 | #' @import tidyr 66 | #' @import Rcpp 67 | #' @import ggplot2 68 | #' @import grid 69 | #' @import patchwork 70 | #' @importFrom stats complete.cases cor median na.omit quantile sd cor.test 71 | #' @importFrom robustbase colMedians 72 | #' @importFrom dplyr select summarise group_by mutate n_distinct filter ungroup 73 | #' @importFrom tidyr gather 74 | #' @importFrom plyr arrange 75 | #' @useDynLib splithalf, .registration = TRUE 76 | #' @importFrom methods is 77 | #' @importFrom Rcpp sourceCpp 78 | #' @importFrom utils setTxtProgressBar txtProgressBar capture.output 79 | #' @rdname multiverse.plot 80 | #' @export 81 | 82 | 83 | multiverse.plot <- function(multiverse, 84 | title = "", 85 | vline = "none", 86 | heights = c(4,5), 87 | SE = FALSE) { 88 | 89 | if(SE == TRUE & length(heights) != 3) { 90 | stop("heights must be length 3 is SE = TRUE") 91 | } 92 | 93 | if(is(multiverse, "list")) { 94 | x <- length(multiverse) 95 | 96 | for(i in 1:x){ 97 | if(!is(multiverse[[i]], "multiverse")) 98 | stop("not all list objects are of class multiverse") 99 | } 100 | 101 | # create empty objects for the purposes of binding global variables 102 | #(and to pass CRAN checks) 103 | estimate <- 0 104 | low <- 0 105 | high <- 0 106 | ns <- 0 107 | time <- 0 108 | Bigdecision <- 0 109 | Decision <- 0 110 | 111 | 112 | final <- NULL 113 | final2 <- NULL 114 | ord <- order(multiverse[[1]]$estimates[,"estimate"]) 115 | 116 | 117 | for(x in 1:length(multiverse)) { 118 | final <- multiverse[[x]]$estimates 119 | final$time <- toString(x) 120 | final <- final[ord,] 121 | final$ns <- 1:nrow(final) 122 | 123 | final2 <- rbind(final2, final) 124 | 125 | } 126 | 127 | 128 | #final2 <- final 129 | # %>% 130 | # group_by(time) %>% 131 | # mutate(order = order(estimate)) 132 | 133 | 134 | 135 | } 136 | 137 | 138 | if(is(multiverse, "multiverse")){ 139 | final2 <- multiverse$estimates 140 | final2 <- final2[order(final2[,"estimate"]),] 141 | final2$SE <- multiverse$SE 142 | } 143 | 144 | suppressWarnings({ 145 | 146 | if(is(multiverse, "multiverse")){ 147 | final2$ns <- 1:multiverse$nS 148 | 149 | reliability_plot <- ggplot(data = final2, 150 | aes(x = 1:multiverse$nS, y = estimate)) + 151 | geom_ribbon(aes(ymin = low, ymax = high), fill = "grey80", alpha = .8) + 152 | {if(vline!="none")geom_vline(aes(), xintercept = round(multiverse$nS * vline), linetype = "dashed", colour = "black")} + 153 | geom_point() + 154 | scale_color_manual(values = c("#000000", "#FF0000")) + 155 | labs(x = " ") + 156 | theme(legend.position = "none", 157 | strip.text.x = element_blank(), 158 | strip.text.y = element_blank(), 159 | strip.background = element_blank(), 160 | text = element_text(size=10)) + 161 | geom_hline(yintercept = 0) 162 | 163 | if(SE == FALSE) 164 | reliability_plot <- reliability_plot + 165 | ggtitle(title) + 166 | theme(plot.title = element_text(hjust = 0.5, face = "bold")) 167 | } 168 | 169 | if(is(multiverse, "list")){ 170 | reliability_plot <- ggplot(data = final2, 171 | aes(x = ns, y = estimate, fill = time)) + 172 | geom_ribbon(aes(ymin = low, ymax = high, fill = time), alpha = .1) + 173 | {if(vline!="none")geom_vline(aes(), xintercept = round(multiverse[[1]]$nS * vline), linetype = "dashed", colour = "black")} + 174 | geom_point(aes(colour = time)) + 175 | # geom_line(aes(colour = time)) + 176 | labs(x = " ") + 177 | theme(legend.position = "top", 178 | legend.title = element_blank(), 179 | strip.text.x = element_blank(), 180 | strip.text.y = element_blank(), 181 | strip.background = element_blank(), 182 | text = element_text(size=10)) + 183 | geom_hline(yintercept = 0) + 184 | ggtitle(title) + 185 | theme(plot.title = element_text(hjust = 0.5, face = "bold")) 186 | 187 | } 188 | 189 | }) 190 | 191 | suppressWarnings({ 192 | 193 | if(is(multiverse, "multiverse")){ 194 | 195 | final2$ns <- 1:multiverse$nS 196 | 197 | 198 | final3 <- final2 %>% 199 | gather(key = "Bigdecision", 200 | value = "Decision", 201 | -ns, -estimate, -low, -high) 202 | 203 | } 204 | 205 | if(is(multiverse, "list")){ 206 | final3 <- final2 %>% 207 | dplyr::filter(time == 1) %>% 208 | tidyr::gather(key = "Bigdecision", 209 | value = "Decision", 210 | -ns, -estimate, -low, -high) 211 | } 212 | 213 | }) 214 | 215 | final3$Bigdecision <- factor(final3$Bigdecision, levels = c("ACC_cutoff", 216 | "RT_min", 217 | "RT_max", 218 | "RT_sd_cutoff", 219 | "split_by", 220 | "averaging_method")) 221 | 222 | suppressWarnings({ 223 | if(is(multiverse, "multiverse")){ 224 | dashboard <- ggplot(data = subset(final3, Bigdecision %in% multiverse$cols), 225 | aes(x = ns, y = Decision, colour = Bigdecision)) + 226 | facet_grid(Bigdecision ~ ., scales = "free", space = "free", drop = ) + 227 | {if(vline!="none")geom_vline(aes(), xintercept = round(multiverse$nS*vline), linetype = "dashed", colour = "black")} + 228 | geom_point(aes(colour = Bigdecision), shape = 108, size = 6) + 229 | labs(x = "specification number") + 230 | theme_minimal() + 231 | theme(legend.position = "none", 232 | strip.text.x = element_blank(), 233 | strip.text.y = element_blank(), 234 | strip.background = element_blank(), 235 | text = element_text(size=10)) 236 | } 237 | 238 | if(is(multiverse, "list")){ 239 | dashboard <- ggplot(data = subset(final3, Bigdecision %in% multiverse[[1]]$cols), 240 | aes(x = ns, y = Decision, colour = Bigdecision)) + 241 | facet_grid(Bigdecision ~ ., scales = "free", space = "free", drop = ) + 242 | {if(vline!="none")geom_vline(aes(), xintercept = round(multiverse[[1]]$nS*vline), linetype = "dashed", colour = "black")} + 243 | geom_point(aes(colour = Bigdecision), shape = 108, size = 6) + 244 | labs(x = "specification number") + 245 | theme_minimal() + 246 | theme(legend.position = "none", 247 | strip.text.x = element_blank(), 248 | strip.text.y = element_blank(), 249 | strip.background = element_blank(), 250 | text = element_text(size=10)) 251 | } 252 | }) 253 | 254 | if(SE == TRUE) { 255 | SE_plot <- ggplot(data = final2, 256 | aes(x = 1:multiverse$nS, y = SE)) + 257 | geom_point() + 258 | scale_color_manual(values = c("#000000", "#FF0000")) + 259 | labs(x = " ") + 260 | theme(legend.position = "none", 261 | strip.text.x = element_blank(), 262 | strip.text.y = element_blank(), 263 | strip.background = element_blank(), 264 | text = element_text(size=10)) + 265 | geom_hline(yintercept = 0) + 266 | ggtitle(title) + 267 | theme(plot.title = element_text(hjust = 0.5, face = "bold")) 268 | } 269 | 270 | 271 | if(SE == FALSE) { 272 | final_plot <- reliability_plot / dashboard + plot_layout(heights = heights) 273 | } 274 | if(SE == TRUE) { 275 | final_plot <- SE_plot / reliability_plot / dashboard + plot_layout(heights = heights) 276 | } 277 | 278 | return(final_plot) 279 | 280 | } 281 | -------------------------------------------------------------------------------- /R/splithalf_multiverse.R: -------------------------------------------------------------------------------- 1 | #' Multiverse of data processing decisions on internal consistency reliability estimates. 2 | #' 3 | #' This function enables the user to run a multiverse of data processing options and extract the resulting (internal consistency) reliability estimates generated by splithalf. The user specifies a set of data processing decisions and passes this to the function, along with a splithalf object. The output can then be explored and plotted as desired. 4 | #' 5 | #' The (unofficial) function version name is "This function will let you get honey from a hornets nest" 6 | #' @param input splithalf object or list of splithalf objects 7 | #' @param specifications list of data processing specifications 8 | #' @return Returns a multiverse object containing the reliability estimates and dataframes from all data processing specifications provided 9 | #' @examples 10 | #' \dontrun{ 11 | #' ## see online documentation for examples 12 | #' https://github.com/sdparsons/splithalf 13 | #' ## also see https://psyarxiv.com/y6tcz 14 | #' 15 | #' ## example simulated data 16 | #' n_participants = 60 ## sample size 17 | #' n_trials = 80 18 | #' n_blocks = 2 19 | #' sim_data <- data.frame(participant_number = rep(1:n_participants, 20 | #' each = n_blocks * n_trials), 21 | #' trial_number = rep(1:n_trials, 22 | #' times = n_blocks * n_participants), 23 | #' block_name = rep(c("A","B"), 24 | #' each = n_trials, 25 | #' length.out = n_participants * n_trials * n_blocks), 26 | #' trial_type = rep(c("congruent","incongruent"), 27 | #' length.out = n_participants * n_trials * n_blocks), 28 | #' RT = rnorm(n_participants * n_trials * n_blocks, 29 | #' 500, 30 | #' 200), 31 | #' ACC = 1) 32 | #' 33 | #' ## specify several data processing decisions 34 | #' specifications <- list(RT_min = c(0, 100, 200), 35 | #' RT_max = c(1000, 2000), 36 | #' averaging_method = c("mean", "median")) 37 | #' ## run splithalf, and save the output 38 | #' difference <- splithalf(data = sim_data, 39 | #' outcome = "RT", 40 | #' score = "difference", 41 | #' conditionlist = c("A"), 42 | #' halftype = "random", 43 | #' permutations = 5000, 44 | #' var.RT = "RT", 45 | #' var.condition = "block_name", 46 | #' var.participant = "participant_number", 47 | #' var.compare = "trial_type", 48 | #' var.ACC = "ACC", 49 | #' compare1 = "congruent", 50 | #' compare2 = "incongruent", 51 | #' average = "mean") 52 | #' 53 | #' ## run splithalf.multiverse to perform the multiverse of data processing 54 | #' ## and reliability estimation 55 | #' multiverse <- splithalf.multiverse(input = difference, 56 | #' specifications = specifications) 57 | #' 58 | #' ## can be plot with: 59 | #' multiverse.plot(multiverse = multiverse, 60 | #' title = "README multiverse") 61 | #' } 62 | #' @import tidyr 63 | #' @import Rcpp 64 | #' @import ggplot2 65 | #' @import grid 66 | #' @import patchwork 67 | #' @importFrom stats complete.cases cor median na.omit quantile sd cor.test 68 | #' @importFrom robustbase colMedians 69 | #' @importFrom dplyr select summarise group_by mutate n_distinct filter ungroup n 70 | #' @importFrom tidyr gather 71 | #' @importFrom plyr arrange 72 | #' @useDynLib splithalf, .registration = TRUE 73 | #' @importFrom Rcpp sourceCpp 74 | #' @importFrom utils setTxtProgressBar txtProgressBar capture.output 75 | #' @export 76 | 77 | 78 | splithalf.multiverse <- function(input, 79 | specifications) { 80 | 81 | 82 | if(!is(input, "splithalf")) { 83 | stop("please use a splithalf object as the input") 84 | } 85 | 86 | ### 87 | 88 | if(length(input$call$conditionlist) > 1) { 89 | warning("splithalf.multiverse only extracts the first condition for the analyses. If you want to run a multiverse on more than one condition, specify these separately") 90 | } 91 | 92 | 93 | 94 | # set up the output list #################################################### 95 | 96 | outlist <- list("input" = input, 97 | "specifications" = specifications, 98 | "type" = "internal_consistency", 99 | "reliability" = "internal_consistency") 100 | 101 | # create the full specificaiton list ######################################## 102 | 103 | # if anything is missing, add those variables 104 | 105 | outlist$cols <- names(specifications) 106 | 107 | if(!("ACC_cutoff" %in% names(specifications))){ 108 | specifications[["ACC_cutoff"]] <- 0 109 | } 110 | if(!("RT_min" %in% names(specifications))){ 111 | specifications[["RT_min"]] <- 0 112 | } 113 | if(!("RT_max" %in% names(specifications))){ 114 | specifications[["RT_max"]] <- 1000000 115 | } 116 | if(!("RT_sd_cutoff" %in% names(specifications))){ 117 | specifications[["RT_sd_cutoff"]] <- 0 118 | } 119 | if(!("split_by" %in% names(specifications))){ 120 | specifications[["split_by"]] <- "subject" 121 | } 122 | if(!("averaging_method" %in% names(specifications))){ 123 | specifications[["averaging_method"]] <- "mean" 124 | } 125 | 126 | # pass forward variables 127 | 128 | 129 | outcome = input$call$outcome 130 | score = input$call$score 131 | conditionlist = input$call$conditionlist 132 | halftype = input$call$halftype 133 | permutations = input$call$permutations 134 | var.RT = input$call$var.RT 135 | var.ACC = input$call$var.ACC 136 | var.condition = input$call$var.condition 137 | var.participant = input$call$var.participant 138 | var.compare = input$call$var.compare 139 | compare1 = input$call$compare1 140 | compare2 = input$call$compare2 141 | average = input$call$average 142 | 143 | 144 | ### ensure that the input$data names match 145 | input$data$var.RT = input$data[,var.RT] 146 | input$data$var.ACC = input$data[,var.ACC] 147 | input$data$var.condition = input$data[,var.condition] 148 | input$data$var.participant = input$data[,var.participant] 149 | input$data$var.compare = input$data[,var.compare] 150 | 151 | if(length(input$call$conditionlist) > 1) { 152 | 153 | input$data <- input$data %>% 154 | filter(var.condition == input$call$conditionlist[1]) 155 | 156 | } 157 | 158 | 159 | 160 | # create empty objects for the purposes of binding global variables 161 | #(and to pass CRAN checks) 162 | n <- 0 163 | ACC <- 0 164 | latency <- 0 165 | blockcode <- 0 166 | congruency <- 0 167 | low <- 0 168 | high <- 0 169 | meanRT <- 0 170 | Incongruent <- 0 171 | Congruent <- 0 172 | RTdiff <- 0 173 | . <- 0 174 | 175 | 176 | 177 | specs <- expand.grid(specifications) 178 | 179 | nS <- nrow(specs) 180 | 181 | ## add specs and nS to outlist 182 | 183 | outlist$specs <- specs 184 | outlist$nS <- nS 185 | 186 | # process specifications #################################################### 187 | 188 | print(paste("running", nS, "pre-processing specifications")) 189 | 190 | # internal consistency 191 | 192 | 193 | # calculate accuracy rates 194 | temp_data <- input$data %>% 195 | group_by(var.participant) %>% 196 | mutate(ACC = sum(var.ACC) / n()) 197 | 198 | # make all the datasets 199 | 200 | perm_out <- list() 201 | 202 | SE_out <- NULL 203 | 204 | pb <- txtProgressBar(min = 0, max = nS, style = 3) 205 | setTxtProgressBar(pb, 0) 206 | 207 | for(perm in 1:nS) { 208 | 209 | temp <- temp_data %>% 210 | dplyr::filter(var.ACC >= specs[perm, "ACC_cutoff"]) %>% 211 | dplyr::group_by(var.participant) %>% 212 | dplyr::filter(var.ACC == 1) %>% 213 | dplyr::filter(var.RT >= specs[perm, "RT_min"], 214 | var.RT <= specs[perm, "RT_max"]) %>% 215 | dplyr::ungroup() 216 | 217 | if(specs[perm, "split_by"] == "subject") 218 | temp <- temp %>% 219 | group_by(var.participant) 220 | if(specs[perm, "split_by"] == "trial") 221 | temp <- temp %>% 222 | group_by(var.participant, var.compare) 223 | 224 | if(specs[perm, "RT_sd_cutoff"] != 0) 225 | temp <- temp %>% 226 | mutate(high = mean(var.RT) + (specs[perm, "RT_sd_cutoff"]*sd(var.RT)), 227 | low = mean(var.RT) - (specs[perm, "RT_sd_cutoff"]*sd(var.RT))) %>% 228 | dplyr::filter(var.RT >= low, var.RT <= high) %>% 229 | ungroup() %>% 230 | as.data.frame() 231 | 232 | perm_out[[perm]] <- temp 233 | 234 | SE_out[perm] <- temp %>% 235 | group_by(var.participant, var.compare) %>% 236 | summarise(meanRT = mean(var.RT)) %>% 237 | spread(var.compare, meanRT) %>% 238 | ungroup() %>% 239 | mutate(RTdiff = .[[compare1]] - .[[compare2]]) %>% 240 | summarise(SE = sd(RTdiff)/sqrt(n())) %>% 241 | as.double() 242 | 243 | setTxtProgressBar(pb, perm) 244 | } 245 | 246 | outlist$sca <- perm_out 247 | outlist$SE <- SE_out 248 | 249 | 250 | 251 | nPar <- 1:nS 252 | nTrial <- 1:nS 253 | 254 | for(i in 1:nS) { 255 | nPar[i] <- length(unique(perm_out[[i]]$var.participant)) 256 | nTrial[i] <- length(perm_out[[i]]$var.participant) 257 | } 258 | 259 | removals <- specs 260 | removals$nPar <- nPar 261 | removals$nTrial <- nTrial 262 | removals$nTrialperPar <- removals$nTrial / removals$nPar 263 | 264 | removals$pPar <- removals$nPar / length(unique(input$data$var.participant)) 265 | removals$pTrial <- removals$nTrial / length(input$data$var.participant) 266 | 267 | outlist$removals <- removals 268 | 269 | ##### Run reliability estimates ############################################ 270 | 271 | print("running reliability estimates") 272 | 273 | estimates <- list() 274 | 275 | # internal consistency 276 | 277 | pb2 <- txtProgressBar(min = 0, max = nS, style = 3) 278 | setTxtProgressBar(pb2, 0) 279 | 280 | for(perm2 in 1:nS) { 281 | capture.output({ 282 | suppressWarnings({ 283 | estimates[[perm2]] <- splithalf(data = perm_out[[perm2]], 284 | outcome = input$call$outcome, 285 | # conditionlist = c("angry"), 286 | permutations = input$call$permutations, 287 | average = specs[perm2, "averaging_method"], 288 | # var.condition = "blockcode", 289 | var.ACC = input$call$var.ACC, 290 | var.RT = input$call$var.RT, 291 | var.participant = input$call$var.participant, 292 | var.compare = input$call$var.compare, 293 | compare1 = input$call$compare1, 294 | compare2 = input$call$compare2, 295 | round.to = 5)$final_estimates 296 | }) 297 | }) 298 | 299 | setTxtProgressBar(pb2, perm2) 300 | } 301 | 302 | 303 | # test retest 304 | 305 | outlist$MULTIVERSEestimates <- estimates 306 | 307 | 308 | # get quantiles 309 | 310 | # q <- 1:nS 311 | # 312 | # if(type == "internal_consistency") { 313 | # for(k in 1:length(q)){ 314 | # q[k] <- estimates[[k]]$spearmanbrown 315 | # } 316 | # } 317 | # if(type == "test_retest") { 318 | # for(k in 1:length(q)){ 319 | # q[k] <- estimates[[k]]$ICC 320 | # } 321 | # } 322 | 323 | outlist$estimates <- specs 324 | for(i in 1:nS) { 325 | outlist$estimates$estimate[i] <- estimates[[i]]$spearmanbrown 326 | outlist$estimates$low[i] <- estimates[[i]]$SB_low 327 | outlist$estimates$high[i] <- estimates[[i]]$SB_high 328 | } 329 | 330 | 331 | 332 | outlist$CI <- quantile(outlist$estimates$estimate, c(.025,.5, .975)) 333 | 334 | class(outlist) <- "multiverse" 335 | 336 | if(length(input$call$conditionlist) > 1) { 337 | print("REMINDER: splithalf.multiverse only extracts the first condition for the analyses. If you want to run a multiverse on more than one condition, specify these separately") 338 | } 339 | 340 | return(outlist) 341 | } 342 | -------------------------------------------------------------------------------- /R/testretest_multiverse.R: -------------------------------------------------------------------------------- 1 | #' Multiverse of data processing decisions on test retest reliability estimates. 2 | #' 3 | #' This function enables the user to run a multiverse of data processing options and extract the resulting test-retest reliability estimates. The user specifies a set of data processing decisions and passes this to the function, along with specifying key variables within several "var." inputs (so that the function knows where to find your participant ids and RTs for example) 4 | #' 5 | #' The (unofficial) function version name is "This function will help you pay the troll toll" 6 | #' @param data dataset 7 | #' @param specifications list of data processing specifications 8 | #' @param outcome from splithalf() specifies the RT outcome - only "RT" available currently 9 | #' @param score currently only "difference" scores are supported 10 | #' @param test test retest statistic, "ICC2", "cor", "ICC3" 11 | #' @param var.participant = "subject", 12 | #' @param var.ACC = "correct", 13 | #' @param var.RT = "RT" 14 | #' @param var.time codes the time variable (currently only works for 2 timepoints) 15 | #' @param var.compare = "congruency" trial type used to create difference scores 16 | #' @param compare1 specifies the first trial type to be compared (e.g. "Congruent" trials) 17 | #' @param compare2 specifies the second trial type to be compared (e.g. "Incongruent" trials) 18 | #' @return Returns a multiverse object containing the reliability estimates and dataframes from all data processing specifications provided 19 | #' @examples 20 | #' \dontrun{ 21 | #' ## see online documentation for examples 22 | #' https://github.com/sdparsons/splithalf 23 | #' ## also see https://psyarxiv.com/y6tcz 24 | #' 25 | #' n_participants <- 80 ## sample size 26 | #' n_trials <- 120 27 | #' n_blocks <- 2 28 | #' 29 | #' sim_data_mv <- data.frame(participant_number = rep(1:n_participants, 30 | #' each = n_blocks * n_trials), 31 | #' trial_number = rep(1:n_trials, 32 | #' times = n_blocks * n_participants), 33 | #' block_name = rep(c(1,2), 34 | #' each = n_trials, 35 | #' length.out = n_participants * n_trials * n_blocks), 36 | #' trial_type = rep(c("congruent","congruent", 37 | #' "incongruent","incongruent"), 38 | #' length.out = n_participants * n_trials * n_blocks / 2), 39 | #' RT = rnorm(n_participants * n_trials * n_blocks, 40 | #' 500, 41 | #' 200), 42 | #' ACC = c(rbinom(n_participants * 43 | #' n_trials * 44 | #' n_blocks / 6, 45 | #' 1, .5), 46 | #' rbinom(n_participants * 47 | #' n_trials * 48 | #' n_blocks / 6, 49 | #' 1, .7), 50 | #' rbinom(n_participants * 51 | #' n_trials * 52 | #' n_blocks / 6, 53 | #' 1, .9), 54 | #' rbinom(n_participants * 55 | #' n_trials * 56 | #' n_blocks / 6, 57 | #' 1, .5), 58 | #' rbinom(n_participants * 59 | #' n_trials * 60 | #' n_blocks / 6, 61 | #' 1, .7), 62 | #' rbinom(n_participants * 63 | #' n_trials * 64 | #' n_blocks / 6, 65 | #' 1, .9))) 66 | #' 67 | #' specifications <- list( 68 | #' ACC_cutoff = c(0, 0.5), 69 | #' RT_min = c(0, 200), 70 | #' RT_max = c(2000, 3000), 71 | #' RT_sd_cutoff = c(0, 2), 72 | #' split_by = c("subject", "trial"), 73 | #' averaging_method = c("mean") 74 | #' ) 75 | #' 76 | #' icc2 <- testretest.multiverse(data = sim_data_acc, 77 | #' specifications, 78 | #' test = "ICC2", 79 | #' score = "difference", 80 | #' var.participant = "participant_number", 81 | #' var.ACC = "ACC", 82 | #' var.RT = "RT", 83 | #' var.time = "block_name", 84 | #' var.compare = "trial_type", 85 | #' compare1 = "congruent", 86 | #' compare2 = "incongruent") 87 | #' 88 | #' multiverse.plot(icc2) 89 | #' 90 | #' } 91 | #' @import tidyr 92 | #' @import Rcpp 93 | #' @import ggplot2 94 | #' @import grid 95 | #' @import patchwork 96 | #' @import lme4 97 | #' @importFrom stats complete.cases cor median na.omit quantile sd cor.test 98 | #' @importFrom robustbase colMedians 99 | #' @importFrom dplyr select summarise group_by mutate n_distinct filter ungroup n 100 | #' @importFrom tidyr gather 101 | #' @importFrom plyr arrange 102 | #' @importFrom psych ICC 103 | #' @useDynLib splithalf, .registration = TRUE 104 | #' @importFrom Rcpp sourceCpp 105 | #' @importFrom utils setTxtProgressBar txtProgressBar capture.output 106 | #' @export 107 | 108 | testretest.multiverse <- function(data, 109 | specifications, 110 | test = "ICC2", 111 | 112 | outcome = "RT", 113 | score = "difference", 114 | 115 | var.participant = "subject", 116 | var.ACC = "correct", 117 | var.RT = "RT", 118 | var.time = "time", 119 | var.compare = "congruency", 120 | compare1 = "Congruent", 121 | compare2 = "Incongruent") { 122 | 123 | 124 | # check that the dataframe is a data frame 125 | if (is.data.frame(data) == FALSE) { 126 | stop("a data frame has not been specified in data = ") 127 | } 128 | # check for missing variables 129 | if (outcome != "RT") { 130 | stop("only response time outcomes are supported. accuracy rates will be added in a future version") 131 | } 132 | if (score != "difference") { 133 | stop( 134 | "currently the only score option supported is the difference score. average scores will be added in a future version" 135 | ) 136 | } 137 | 138 | # check that all of the variables exist in the data frame, 139 | # including the trial level components 140 | if (var.RT %in% colnames(data) == FALSE & outcome != "accuracy") { 141 | stop("the RT varible has not been specified") 142 | } 143 | if (var.participant %in% colnames(data) == FALSE) { 144 | stop("the participant varible has not been specified") 145 | } 146 | if (score == "difference" | score == "difference_of_difference") { 147 | if (var.compare %in% colnames(data) == FALSE) { 148 | stop("the compare varible has not been specified") 149 | } 150 | if (compare1 %in% unique(data[[var.compare]]) == FALSE) { 151 | stop("compare1 does not exist in the compare variable") 152 | } 153 | if (compare2 %in% unique(data[[var.compare]]) == FALSE) { 154 | stop("compare2 does not exist in the compare variable") 155 | } 156 | 157 | } 158 | 159 | 160 | 161 | 162 | 163 | ### 164 | 165 | data$subject <- data[, var.participant] 166 | data$time <- data[, var.time] 167 | data$correct <- data[, var.ACC] 168 | data$latency <- data[, var.RT] 169 | data$congruency <- data[, var.compare] 170 | 171 | data$congruency <- ifelse(data$congruency == compare1, "Congruent", 172 | ifelse(data$congruency == compare2, "Incongruent", NA)) 173 | 174 | data$trialnum <- 1:nrow(data) 175 | 176 | 177 | # set up the output list #################################################### 178 | 179 | outlist <- list("data" = data, 180 | "specifications" = specifications, 181 | "test" = test, 182 | "reliability" = "test_retest") 183 | 184 | 185 | # create empty objects for the purposes of binding global variables 186 | #(and to pass CRAN checks) 187 | n <- 0 188 | ACC <- 0 189 | latency <- 0 190 | blockcode <- 0 191 | congruency <- 0 192 | low <- 0 193 | high <- 0 194 | latency <- 0 195 | Incongruent <- 0 196 | Congruent <- 0 197 | time <- 0 198 | difference <- 0 199 | ICC <- 0 200 | subject <- 0 201 | correct <- 0 202 | RT <- 0 203 | 204 | 205 | # create the full specificaiton list ######################################## 206 | 207 | # if anything is missing, add those variables 208 | 209 | outlist$cols <- names(specifications) 210 | 211 | if(!("ACC_cutoff" %in% names(specifications))){ 212 | specifications[["ACC_cutoff"]] <- 0 213 | } 214 | if(!("RT_min" %in% names(specifications))){ 215 | specifications[["RT_min"]] <- 0 216 | } 217 | if(!("RT_max" %in% names(specifications))){ 218 | specifications[["RT_max"]] <- 1000000 219 | } 220 | if(!("RT_sd_cutoff" %in% names(specifications))){ 221 | specifications[["RT_sd_cutoff"]] <- 0 222 | } 223 | if(!("split_by" %in% names(specifications))){ 224 | specifications[["split_by"]] <- "subject" 225 | } 226 | if(!("averaging_method" %in% names(specifications))){ 227 | specifications[["averaging_method"]] <- "mean" 228 | } 229 | 230 | specs <- expand.grid(specifications) 231 | 232 | nS <- nrow(specs) 233 | 234 | ## add specs and nS to outlist 235 | 236 | outlist$specs <- specs 237 | outlist$nS <- nS 238 | 239 | # process specifications #################################################### 240 | 241 | print(paste("running", nS, "pre-processing specifications")) 242 | 243 | # calculate accuracy rates 244 | temp_data <- data %>% 245 | group_by(time, subject) %>% 246 | mutate(ACC = sum(correct) / n()) 247 | 248 | # make all the datasets 249 | 250 | perm_out <- list() 251 | 252 | pb <- txtProgressBar(min = 0, max = nS, style = 3) 253 | setTxtProgressBar(pb, 0) 254 | 255 | for(perm in 1:nS) { 256 | 257 | temp <- temp_data %>% 258 | filter(ACC >= specs[perm, "ACC_cutoff"]) %>% 259 | group_by(time, subject) %>% 260 | filter(correct == 1) %>% 261 | filter(latency >= specs[perm, "RT_min"], 262 | latency <= specs[perm, "RT_max"]) %>% 263 | ungroup() 264 | 265 | if(specs[perm, "split_by"] == "subject") 266 | temp <- temp %>% 267 | group_by(time, subject) 268 | # if(specs[perm, "split_by"] == "condition") 269 | # temp <- temp %>% 270 | # group_by(time, subject, blockcode) 271 | if(specs[perm, "split_by"] == "trial") 272 | temp <- temp %>% 273 | group_by(time, subject, congruency) 274 | 275 | if(specs[perm, "RT_sd_cutoff"] != 0) 276 | temp <- temp %>% 277 | mutate(high = mean(latency) + (specs[perm, "RT_sd_cutoff"]*sd(latency)), 278 | low = mean(latency) - (specs[perm, "RT_sd_cutoff"]*sd(latency))) %>% 279 | filter(latency >= low, latency <= high) %>% 280 | ungroup() %>% 281 | as.data.frame() 282 | 283 | perm_out[[perm]] <- temp 284 | setTxtProgressBar(pb, perm) 285 | } 286 | 287 | outlist$sca <- perm_out 288 | 289 | 290 | 291 | # check removals ############################################################ 292 | # note, needs tweaking for test-retest. 293 | 294 | nPar <- 1:nS 295 | nTrial <- 1:nS 296 | 297 | for(i in 1:nS) { 298 | nPar[i] <- length(unique(perm_out[[i]]$subject)) 299 | nTrial[i] <- length(perm_out[[i]]$trialnum) 300 | } 301 | 302 | removals <- specs 303 | removals$nPar <- nPar 304 | removals$nTrial <- nTrial 305 | removals$nTrialperPar <- removals$nTrial / removals$nPar 306 | 307 | removals$pPar <- removals$nPar / length(unique(data$subject)) 308 | removals$pTrial <- removals$nTrial / length(data$trialnum) 309 | 310 | outlist$removals <- removals 311 | 312 | ##### Run reliability estimates ############################################ 313 | 314 | print("running reliability estimates") 315 | 316 | estimates <- list() 317 | 318 | # test retest 319 | 320 | if(test == "ICC2") 321 | icc <- 2 322 | if(test == "ICC3") 323 | icc <- 3 324 | 325 | pb2 <- txtProgressBar(min = 0, max = nS, style = 3) 326 | setTxtProgressBar(pb2, 0) 327 | 328 | if(test == "ICC2" | test == "ICC3") { 329 | 330 | for(perm2 in 1:nS) { 331 | capture.output({ 332 | 333 | tmp <- perm_out[[perm2]] %>% 334 | group_by(time, subject, congruency) %>% 335 | summarise(RT = mean(latency)) %>% 336 | spread(congruency, RT) %>% 337 | mutate(difference = Incongruent - Congruent) %>% 338 | select(-Congruent, -Incongruent) %>% 339 | group_by(time) %>% 340 | spread(time, difference) 341 | 342 | estimates[[perm2]] <- psych::ICC(tmp[,2:3])$results[icc,] 343 | 344 | }) 345 | setTxtProgressBar(pb2, perm2) 346 | } 347 | } 348 | 349 | if(test == "cor") 350 | { 351 | for(perm2 in 1:nS) { 352 | capture.output({ 353 | 354 | tmp <- perm_out[[perm2]] %>% 355 | group_by(time, subject, congruency) %>% 356 | summarise(RT = mean(latency)) %>% 357 | spread(congruency, RT) %>% 358 | mutate(difference = Incongruent - Congruent) %>% 359 | select(-Congruent, -Incongruent) %>% 360 | group_by(time) %>% 361 | spread(time, difference) %>% 362 | as.data.frame() 363 | 364 | estimates[[perm2]] <- cor.test(tmp[,2],tmp[,3]) 365 | 366 | }) 367 | setTxtProgressBar(pb2, perm2) 368 | } 369 | } 370 | 371 | 372 | outlist$MULTIVERSEestimates <- estimates 373 | 374 | outlist$estimates <- specs 375 | 376 | if(test == "ICC2" | test == "ICC3") { 377 | for(i in 1:nS) { 378 | outlist$estimates$estimate[i] <- estimates[[i]]$ICC 379 | outlist$estimates$low[i] <- estimates[[i]]$`lower bound` 380 | outlist$estimates$high[i] <- estimates[[i]]$`upper bound` 381 | } 382 | } 383 | 384 | if(test == "cor") { 385 | for(i in 1:nS) { 386 | outlist$estimates$estimate[i] <- estimates[[i]]$estimate 387 | outlist$estimates$low[i] <- estimates[[i]]$conf.int[1] 388 | outlist$estimates$high[i] <- estimates[[i]]$conf.int[2] 389 | } 390 | } 391 | 392 | outlist$CI <- quantile(outlist$estimates$estimate, c(.025,.5, .975), na.rm = TRUE) 393 | 394 | class(outlist) <- "multiverse" 395 | 396 | return(outlist) 397 | } 398 | -------------------------------------------------------------------------------- /R/threshold.R: -------------------------------------------------------------------------------- 1 | #' Check proportion of reliability estimates from the multiverse analyses above or below a set threshold 2 | #' 3 | #' This function examines the output from splithalf_multiverse or testretest_multiverse to extract the proportions of estimates above or below a set threshold (can be the estimate or the upper or lower CI estimates). 4 | #' The (unofficial) function version name is "This function will get you up to here with it" 5 | #' 6 | #' @param multiverse multiverse object 7 | #' @param threshold threshold to look for, e.g. 0.7 8 | #' @param use set to check the reliability "estimates", or the "upper" or "lower" CIs 9 | #' @param dir look "above" or "below" the 'use' at the set threshold 10 | #' @examples 11 | #' \dontrun{ 12 | #' ## see online documentation for examples 13 | #' https://github.com/sdparsons/splithalf 14 | #' ## also see https://psyarxiv.com/y6tcz 15 | #' 16 | #' ## example simulated data 17 | #' n_participants = 60 ## sample size 18 | #' n_trials = 80 19 | #' n_blocks = 2 20 | #' sim_data <- data.frame(participant_number = rep(1:n_participants, 21 | #' each = n_blocks * n_trials), 22 | #' trial_number = rep(1:n_trials, 23 | #' times = n_blocks * n_participants), 24 | #' block_name = rep(c("A","B"), 25 | #' each = n_trials, 26 | #' length.out = n_participants * n_trials * n_blocks), 27 | #' trial_type = rep(c("congruent","incongruent"), 28 | #' length.out = n_participants * n_trials * n_blocks), 29 | #' RT = rnorm(n_participants * n_trials * n_blocks, 30 | #' 500, 31 | #' 200), 32 | #' ACC = 1) 33 | #' 34 | #' ## specify several data processing decisions 35 | #' specifications <- list(RT_min = c(0, 100, 200), 36 | #' RT_max = c(1000, 2000), 37 | #' averaging_method = c("mean", "median")) 38 | #' ## run splithalf, and save the output 39 | #' difference <- splithalf(data = sim_data, 40 | #' outcome = "RT", 41 | #' score = "difference", 42 | #' conditionlist = c("A"), 43 | #' halftype = "random", 44 | #' permutations = 5000, 45 | #' var.RT = "RT", 46 | #' var.condition = "block_name", 47 | #' var.participant = "participant_number", 48 | #' var.compare = "trial_type", 49 | #' var.ACC = "ACC", 50 | #' compare1 = "congruent", 51 | #' compare2 = "incongruent", 52 | #' average = "mean") 53 | #' 54 | #' ## run splithalf.multiverse to perform the multiverse of data processing 55 | #' ## and reliability estimation 56 | #' multiverse <- splithalf.multiverse(input = difference, 57 | #' specifications = specifications) 58 | #' 59 | #' 60 | #' ## the threshold function can be used to return the number of estimates 61 | #' ## above or below a certain threshold 62 | #' 63 | #' threshold(multiverse = multiverse, 64 | #' threshold = 0.7, 65 | #' use = "estimate", 66 | #' dir = "above") 67 | #' } 68 | #' @useDynLib splithalf, .registration = TRUE 69 | #' @rdname multiverse.plot 70 | #' @export 71 | 72 | threshold <- function(multiverse, 73 | threshold, 74 | use = "estimate", 75 | dir = "above") { 76 | 77 | tmp <- 1:multiverse$nS 78 | 79 | if(use == "estimate") { 80 | tmp <- multiverse$estimates$estimate 81 | } 82 | 83 | if(use == "lower") { 84 | tmp <- multiverse$estimates$low 85 | } 86 | 87 | if(use == "upper") { 88 | tmp <- multiverse$estimates$high 89 | } 90 | 91 | 92 | if(dir == "above") { 93 | threshold <- sum(tmp > threshold) / length(tmp) 94 | } 95 | if(dir == "below") { 96 | threshold <- sum(tmp < threshold) / length(tmp) 97 | } 98 | 99 | return(threshold) 100 | } 101 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | # This is totally copied from Sacha Epskamp's bootnet package. 2 | # I mean, he borrowed it from lavaan, so I dont feel all that bad 3 | 4 | 5 | .onAttach <- function(libname, pkgname) { 6 | version <- read.dcf(file=system.file("DESCRIPTION", package=pkgname), 7 | fields="Version") 8 | packageStartupMessage("This is ",paste(pkgname, version)) 9 | packageStartupMessage(pkgname, " is BETA software! Please report any bugs.") 10 | packageStartupMessage("The (unofficial) version name is: 'I eat stickers all the time, dude!'") 11 | packageStartupMessage("For documentation, questions, and issues, please see github.com/sdparsons/splithalf") 12 | packageStartupMessage("or find my email at https://sdparsons.github.io/") 13 | } 14 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | bibliography: inst/book.bib 4 | --- 5 | 6 | 7 | 8 | ```{r, echo = FALSE} 9 | knitr::opts_chunk$set( 10 | collapse = TRUE, 11 | comment = "#>", 12 | fig.path = "man/figures/README-" 13 | ) 14 | ``` 15 | 16 | ```{r, echo = FALSE} 17 | library("ggplot2") 18 | ``` 19 | 20 | 21 | 22 | 23 | [![DOI](https://joss.theoj.org/papers/10.21105/joss.03041/status.svg)](https://doi.org/10.21105/joss.03041) 24 | [![CRAN Version](http://www.r-pkg.org/badges/version/splithalf)](https://cran.r-project.org/package=splithalf) 25 | [![Downloads](https://cranlogs.r-pkg.org/badges/splithalf)](https://cran.r-project.org/package=splithalf) 26 | 27 | # splithalf: robust estimates of split half reliability 28 | 29 | The `R` package **splithalf** provides tools to estimate the internal consistency reliability of cognitive measures. In particular, the tools were developed for application to tasks that use difference scores as the main outcome measure, for instance the Stroop score or dot-probe attention bias index (average RT in incongruent trials minus average RT in congruent trials). 30 | 31 | The methods in **splithalf** are built around split half reliability estimation. To increase the robustness of these estimates, the package implements a permutation approach that takes a large number of random (without replacement) split halves of the data. For each permutation the correlation between halves is calculated, with the Spearman-Brown correction applied [@spearman_proof_1904]. This process generates a distribution of reliability estimates from which we can extract summary statistics (e.g. average and 95% HDI). 32 | 33 | ### Why should I estimate the reliabilty of my task measurement? 34 | 35 | While many cognitive tasks yield robust effects (e.g. everybody shows a Stroop effect) they may not yield reliable individual differences [@hedge_reliability_2018]. As these measures are used in questions of individual differences researchers need to have some psychometric information for the outcome measures. Recently, it was proposed that psychological science should set a standard expectation for the reporting of reliability information for cognitive and behavioural measures [@parsons_kruijt_fox_2019]. **splithalf** was developed to support this proposition by providing a tool to easily extract internal consistency reliability estimates from behavioural measures. 36 | 37 | ## Installation 38 | 39 | The latest release version (`0.7.2` unofficial version name: Kitten Mittens) can be installed from CRAN: 40 | 41 | ```{r eval=FALSE} 42 | install.packages("splithalf") 43 | ``` 44 | 45 | The current developmental version (`0.8.2` unofficial version name: I eat stickers all the time, dude!) can be installed from Github with: 46 | 47 | ```{r eval=FALSE} 48 | devtools::install_github("sdparsons/splithalf") 49 | ``` 50 | 51 | **splithalf** requires the **tidyr** [@R-tidyr] and **dplyr** [@R-dplyr] packages for data handling within the functions. The **robustbase** package is used to extract median scores when applicable. The computationally heavy tasks (extracting many random half samples of the data) are written in `c++` via the `R` package **Rcpp** [@R-Rcpp]. Figures use the **ggplot** package [@R-ggplot2], raincloud plots use code adapted from Allen et al. [@allen_raincloud_2019], and the **patchwork** package [@R-patchwork] is used for plotting the multiverse analyses. 52 | 53 | ```{r eval = FALSE, include = FALSE, echo = FALSE} 54 | library("tidyr") 55 | library("dplyr") 56 | library("Rcpp") 57 | library("robustbase") 58 | ``` 59 | 60 | ### Citing the package 61 | 62 | Citing packages is one way for developers to gain some recognition for the time spent maintaining the work. I would like to keep track of how the package is used so that I can solicit feedback and improve the package more generally. This would also help me track the uptake of reporting measurement reliability over time. 63 | 64 | Please use the following reference for the code: Parsons, S., (2021). splithalf: robust estimates of split half reliability. _Journal of Open Source Software, 6_(60), 3041, 65 | 66 | 67 | 68 | ### User feedback 69 | 70 | Developing the splithalf package is a labour of love (and occasionally burning hatred). If you have any suggestions for improvement, additional functionality, or anything else, please contact me (sam.parsons\@psy.ox.ac.uk) or raise an issue on github (https://github.com/sdparsons/splithalf). Likewise, if you are having trouble using the package (e.g. scream fits at your computer screen – we’ve all been there) do contact me and I will do my best to help as quickly as possible. These kind of help requests are super welcome. In fact, the package has seen several increases in performance and usability due to people asking for help. 71 | 72 | ## Latest updates: 73 | 74 | **Version 0.8.1 now out! [unofficial version name: "Rum Ham"]** Lots of fixed issues in the multiverse functions, and lots more documentation/examples! 75 | 76 | **Now on github and submitted to CRAN: VERSION 0.7.2 [unofficial version name: "Kitten Mittens"]** Featuring reliability multiverse analyses!!! 77 | 78 | This update includes the addition of reliability multiverse functions. A _splithalf_ object can be inputted into _splithalf.multiverse_ to estimate reliability across a user-defined list of data-processing specifications (e.g. min/max RTs). Then, because sometimes science is more art than science, the multiverse output can be plotted with _multiverse.plot_. A brief tutorial can be found below, and a more comprehensive one can be found in a recent preprint [@parsons_exploring_2020]. 79 | 80 | Additionally, the output of splithalf has been reworked. Now a list is returned including the specific function calls, the processed data. 81 | 82 | Since version 0.6.2 a user can also set `plot = TRUE` in _splithalf_ to generate a raincloud plot of the distribution of reliability estimates. 83 | 84 | ## Examples 85 | 86 | ### A note on terminology used in this document 87 | 88 | It is important that we have a similar understanding of the terminology I use in the package and documentation. Each is also discussed in reference to the functions later in the documentation. 89 | 90 | * Trial – whatever happens in this task, e.g. a stimuli is presented. Importantly, participants give one response per trial 91 | * Trial type – often trials can be split into different trial types (e.g. to compare congruent and incongruent trials) 92 | * Condition - this might be different blocks of trials, or something to be assessed separately within the functions. e.g. a task might have a block of 'positive' trials and a block of 'negative' trials. 93 | * Datatype - I use this to refer to the outcome of interest. specifically whether one is interested in average response times or accuracy rates 94 | * Score - I use score to indicate how the final outcome is measured; e.g. the average RT, or the difference between two average RTs, or even the difference between two differences between two RTs (yes, the final one is confusing) 95 | 96 | ### A note on preprocessing 97 | 98 | The core function _splithalf_ requires that the input dataset has already undergone preprocessing (e.g. removal of error trials, RT trimming, and participants with high error rates). Splithalf should therefore be used with the same data that will be used to calculate summary scores and outcome indices. The exception is in multiverse analyses, as described below. 99 | 100 | For those unfamiliar with R, the following snippets may help with common data-processing steps. I also highly recommend the Software Carpentry course "R for Reproducible Scientific Analysis" (https://swcarpentry.github.io/r-novice-gapminder/). 101 | 102 | Note == indicates ‘is equal to’, :: indicates that the function uses the package indicated, in the first case the **dplyr** package [@R-dplyr]. 103 | 104 | 105 | ```{r eval = FALSE} 106 | dataset %>% 107 | dplyr::filter(accuracy == 1) %>% ## keeps only trials in which participants made an accurate response 108 | dplyr::filter(RT >= 100, RT <= 2000) %>% ## removes RTs less than 100ms and greater than 2000ms 109 | dplyr::filter(participant != c(“p23”, “p45”) ## removes participants “p23” and “p45” 110 | ``` 111 | 112 | 113 | If following rt trims you also trimmed by SD, use the following as well. Note that this is for two standard deviations from the mean, within each participant, and within each condition and trialtype. 114 | 115 | ```{r eval = FALSE} 116 | dataset %>% 117 | dplyr::group_by(participant, condition, compare) %>% 118 | dplyr::mutate(low = mean(RT) - (2 * sd(RT)), 119 | high = mean(RT) + (2 * sd(RT))) %>% 120 | dplyr::filter(RT >= low & RT <= high) 121 | ``` 122 | 123 | If you want to save yourself effort in running splithalf, you could also rename your variable (column) names to the function defaults using the following 124 | 125 | ```{r eval = FALSE} 126 | dplyr::rename(dataset, 127 | RT = "latency", 128 | condition = FALSE, 129 | participant = "subject", 130 | correct = "correct", 131 | trialnum = "trialnum", 132 | compare = "congruency") 133 | ``` 134 | 135 | The following examples assume that you have already processed your data to remove outliers, apply any RT cutoffs, etc. A reminder: the data you input into _splithalf_ should be the same as that used to create your final scores - otherwise the resultant estimates will not accurately reflect the reliability of your data. 136 | 137 | ### Questions to ask before running splithalf 138 | 139 | These questions should feed into what settings are appropriate for your need, and are aimed to make the _splithalf_ function easy to use. 140 | 141 | 1. **What type of data do you have?** 142 | 143 | Are you interested in response times, or accuracy rates? 144 | 145 | Knowing this, you can set `outcome = "RT"`, or `outcome = "accuracy"` 146 | 147 | 148 | 2. **How is your outcome score calculated?** 149 | 150 | Say that your response time based task has two trial types; "incongruent" and "congruent". When you analyse your data will you use the average RT in each trial type, or will you create a difference score (or bias) by e.g. subtracting the average RT in congruent trials from the average RT in incongruent trials. The first can be called with `score = "average"` and the second with `score = "difference"`. 151 | 152 | 153 | 3. **Which method would you like to use to estimate (split-half) reliability?** 154 | 155 | A super common way is to split the data into odd and even trials. Another is to split by the first half and second half of the trials. Both approaches are implemented in the _splithalf_ funciton. However, I believe that the permutation splithalf approach is the most applicable in general and so the default is `halftype = "random"` 156 | 157 | 158 | ### An example dataset 159 | 160 | For this brief example, we will simulate some data for 60 participants, who each completed a task with two blocks (A and B) of 80 trials. Trials are also evenly distributed between "congruent" and "incongruent" trials. For each trial we have RT data, and are assuming that participants were accurate in all trials. 161 | 162 | ```{r} 163 | n_participants = 60 ## sample size 164 | n_trials = 80 165 | n_blocks = 2 166 | 167 | sim_data <- data.frame(participant_number = rep(1:n_participants, each = n_blocks * n_trials), 168 | trial_number = rep(1:n_trials, times = n_blocks * n_participants), 169 | block_name = rep(c("A","B"), each = n_trials, length.out = n_participants * n_trials * n_blocks), 170 | trial_type = rep(c("congruent","incongruent"), length.out = n_participants * n_trials * n_blocks), 171 | RT = rnorm(n_participants * n_trials * n_blocks, 500, 200), 172 | ACC = 1) 173 | 174 | 175 | ``` 176 | 177 | 178 | ### Difference scores 179 | 180 | This is by far the most common outcome measure I have come across, so lets start with that. 181 | 182 | Our data will be analysed so that we have two 'bias' or 'difference score' outcomes. So, within each block, we will take the average RT in congruent trials and subtract the average RT in incongruent trials. Calculating the final scores for each participant and for each block separately could be done as follows: 183 | 184 | ```{r comment = NA, echo = TRUE, message = FALSE} 185 | library("dplyr") 186 | library("tidyr") 187 | 188 | sim_data %>% 189 | dplyr::group_by(participant_number, block_name, trial_type) %>% 190 | dplyr::summarise(average = mean(RT)) %>% 191 | tidyr::spread(trial_type, average) %>% 192 | dplyr::mutate(bias = congruent - incongruent) 193 | 194 | ``` 195 | 196 | To estimate reliability with _splithalf_ we run the following. 197 | 198 | ```{r message = FALSE, comment = NA, results = 'hide', warning = FALSE, fig.keep='none'} 199 | library("splithalf") 200 | 201 | difference <- splithalf(data = sim_data, 202 | outcome = "RT", 203 | score = "difference", 204 | conditionlist = c("A", "B"), 205 | halftype = "random", 206 | permutations = 5000, 207 | var.RT = "RT", 208 | var.condition = "block_name", 209 | var.participant = "participant_number", 210 | var.compare = "trial_type", 211 | compare1 = "congruent", 212 | compare2 = "incongruent", 213 | average = "mean", 214 | plot = TRUE) 215 | 216 | ``` 217 | 218 | ```{r echo = FALSE, comment = NA} 219 | difference$final_estimates 220 | 221 | ``` 222 | 223 | Specifying `plot = TRUE` will also allow you to plot the distributions of reliability estimates. you can extract the plot from a saved object with e.g. `difference$plot`. 224 | 225 | ```{r plotting_distribution, echo = FALSE, comment = NA} 226 | difference$plot 227 | ``` 228 | 229 | ### Reading and reporting the output 230 | 231 | The _splithalf_ output gives estimates separately for each condition defined (if no condition is defined, the function assumes that you have only a single condition, which it will call "all" to represent that all trials were included). 232 | 233 | The second column (n) gives the number of participants analysed. If, for some reason one participant has too few trials to analyse, or did not complete one condition, this will be reflected here. I suggest you compare this n to your expected n to check that everything is running correctly. If the ns dont match, we have a problem. More likely, R will give an error message, but useful to know. 234 | 235 | Next are the estimates; the splithalf column and the associated 95% percentile intervals, and the Spearman-Brown corrected estimate with its own percentile intervals. Unsurprisingly, our simlated random data does not yield internally consistant measurements. 236 | 237 | *What should I report?* My preference is to report everything. 95% percentiles of the estimates are provided to give a picture of the spread of internal consistency estimates. Also included is the spearman-brown corrected estimates, which take into account that the estimates are drawn from half the trials that they could have been. Negative reliabilities are near uninterpretable and the spearman-brown formula is not useful in this case. 238 | 239 | > We estimated the internal consitency of bias A and B using a permutation-based splithalf approach [@R-splithalf] with 5000 random splits. The (Spearman-Brown corrected) splithalf internal consistency of bias A was were _r_~SB~ = `r difference$final_estimates[1,6]`, 95%CI [`r difference$final_estimates[1,7]`,`r difference$final_estimates[1,8]`]. 240 | > 241 | > --- Parsons, 2020 242 | 243 | 244 | ### Average scores 245 | 246 | For some tasks the outcome measure may simply be the average RT. In this case, we will ignore the trial type option. We will extract separate outcome scores for each block of trials, but this time it is simply the average RT in each block. Note that the main difference in this code is that we have omitted the inputs about what trial types to 'compare', as this is irrelevant for the current task. 247 | 248 | ```{r message = FALSE, comment = NA, results = 'hide'} 249 | average <- splithalf(data = sim_data, 250 | outcome = "RT", 251 | score = "average", 252 | conditionlist = c("A", "B"), 253 | halftype = "random", 254 | permutations = 5000, 255 | var.RT = "RT", 256 | var.condition = "block_name", 257 | var.participant = "participant_number", 258 | average = "mean") 259 | 260 | ``` 261 | 262 | ```{r echo = FALSE, comment = NA} 263 | average$final_estimates 264 | 265 | ``` 266 | 267 | ### Difference-of-difference scores 268 | 269 | The difference of differences score is a bit more complex, and perhaps also less common. I programmed this aspect of the package initially because I had seen a few papers that used a change in bias score in their analysis, and I wondered "I wonder how reliable that is as an individual difference measure". Be warned, difference scores are nearly always less reliable than raw averages, and differences-of-differences will be less reliable again. 270 | 271 | Our difference-of-difference variable in our task is the difference between bias observed in block A and B. So our outcome is calculated something like this. 272 | 273 | BiasA = incongruent_A - congruent_A 274 | 275 | BiasB = incongruent_B - congruent_B 276 | 277 | Outcome = BiasB - BiasA 278 | 279 | In our function, we specify this very similarly as in the difference score example. The only change will be changing the score to "difference_of_difference". Note that we will keep the condition list consisting of A and B. But, specifying that we are interested in the difference of differences will lead the function to calculate the outcome scores apropriately. 280 | 281 | ```{r message = FALSE, comment = NA, results = 'hide'} 282 | 283 | diff_of_diff <- splithalf(data = sim_data, 284 | outcome = "RT", 285 | score = "difference_of_difference", 286 | conditionlist = c("A", "B"), 287 | halftype = "random", 288 | permutations = 5000, 289 | var.RT = "RT", 290 | var.condition = "block_name", 291 | var.participant = "participant_number", 292 | var.compare = "trial_type", 293 | compare1 = "congruent", 294 | compare2 = "incongruent", 295 | average = "mean") 296 | 297 | 298 | ``` 299 | 300 | ```{r echo = FALSE, comment = NA} 301 | diff_of_diff$final_estimates 302 | 303 | ``` 304 | 305 | 306 | 307 | ## Multiverse analysis extension 308 | 309 | This example is simplified from Parsons [-@parsons_exploring_2020]. The process takes four steps. First, specify a list of data processing decisions. Here, we'll specify only removing trials greater or lower than a specified amount. More options are available, such as total accuracy cutoff thresholds for participant removals. 310 | 311 | ```{r} 312 | specifications <- list(RT_min = c(0, 100, 200), 313 | RT_max = c(1000, 2000), 314 | averaging_method = c("mean", "median")) 315 | ``` 316 | 317 | Second, perform `splithalf(...)`. The key difference here, compared to the earlier examples is that we are no longer assuming that all data processing has already occurred. Instead, the data processing will be performed as part of `splithalf.multiverse`, next. 318 | 319 | ```{r message = FALSE, comment = NA, results = 'hide'} 320 | difference <- splithalf(data = sim_data, 321 | outcome = "RT", 322 | score = "difference", 323 | conditionlist = c("A"), 324 | halftype = "random", 325 | permutations = 5000, 326 | var.RT = "RT", 327 | var.condition = "block_name", 328 | var.participant = "participant_number", 329 | var.compare = "trial_type", 330 | var.ACC = "ACC", 331 | compare1 = "congruent", 332 | compare2 = "incongruent", 333 | average = "mean") 334 | ``` 335 | 336 | Third, perform `splithalf.multiverse` with the specification list and splithalf objects as inputs 337 | 338 | ```{r message = FALSE, comment = NA, results = 'hide'} 339 | multiverse <- splithalf.multiverse(input = difference, 340 | specifications = specifications) 341 | ``` 342 | 343 | Finally, plot the multiverse with plot.multiverse. 344 | 345 | ```{r multiverse_plot} 346 | multiverse.plot(multiverse = multiverse, 347 | title = "README multiverse") 348 | ``` 349 | 350 | For more information, see Parsons (2020). 351 | 352 | ## Other considerations 353 | 354 | ### how many permutations? 355 | 356 | To examine how many random splits are required to provide a precise estimate, a short simulation was performed including 20 estimates of the spearman-brown reliability estimate, for each of 1, 10, 50, 100, 1000, 2000, 5000, 10000, and 20000 random splits. This simulation was performed on data from one block of 80 trials. Based on this simulation, I recommend 5000 (or more) random splits be used to calculate split-half reliability. 5000 permutations yielded a standard deviation of .002 and a total range of .008, indicating that the reliability estimates are stable to two decimal places with this number of random splits. Increasing the number of splits improved precision, however 20000 splits were required to reduce the standard deviation to .001. 357 | 358 | ### *splithalf* runtime? 359 | 360 | The speed of *splithalf* rests entirely on the number of conditions, participants, and permutations. The biggest factor will be your machine speed. For relative times, I ran a simulation with a range of sample sizes, numbers of conditions, numbers of trials, and permutations. The data is contained within the package as `data/speedtest.rda` 361 | 362 | ```{r speedtest, message = FALSE, comment = NA, results = 'hide', echo = FALSE} 363 | load("data/speedtestdata.rda") 364 | speed <- speedtestdata 365 | speed2 <- speed 366 | 367 | speed2$sample_size <- as.factor(speed2$sample_size) 368 | speed2$Number_conditions <- as.factor(speed2$Number_conditions) 369 | speed2$trials <- as.factor(speed2$trials) 370 | speed2$permutations <- as.factor(speed2$permutations) 371 | 372 | 373 | ggplot(data = speed2, 374 | aes(x = permutations, y = runtime, colour = sample_size, group = interaction(trials, sample_size))) + 375 | geom_point(size = 2) + 376 | geom_line() + 377 | theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) + 378 | labs(y = "runtime (seconds)") + 379 | guides(colour = guide_legend(reverse = TRUE)) + 380 | facet_grid(vars(trials), vars(Number_conditions)) 381 | 382 | ``` 383 | 384 | 385 | 386 | ## Future development 387 | 388 | The **splithalf** package is still under development. If you have suggestions for improvements to the package, or bugs to report, please raise an issue on github (https://github.com/sdparsons/splithalf). Currently, I have the following on my immediate to do list: 389 | 390 | * error tracking 391 | * I plan to develop a function that catches potential issues that could arise with the functions. 392 | * I also plan to document common R warnings and errors that arise and why (as sometimes without knowing exactly how the functions work these issues can be harder to trace back). 393 | * include other scoring methods: 394 | * signal detection, e.g. d prime 395 | * potentially customisable methods, e.g. where the outcome is scored in formats similar to A - B / A + B 396 | 397 | 398 | ## Comparison to other software 399 | 400 | **splithalf** is the only package to implement all of these tools, in particular reliability multiverse analyses. Some other `R` packages offer a bootstrapped approach to split-half reliability **multicon** [@R-multicon], **psych** [@R-psych], and **splithalfr** [@R-splithalfr] 401 | 402 | 403 | ## References 404 | 405 | 406 | 407 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #> Warning: package 'ggplot2' was built under R version 4.1.2 5 | 6 | 7 | 8 | [![DOI](https://joss.theoj.org/papers/10.21105/joss.03041/status.svg)](https://doi.org/10.21105/joss.03041) 9 | [![CRAN 10 | Version](http://www.r-pkg.org/badges/version/splithalf)](https://cran.r-project.org/package=splithalf) 11 | [![Downloads](https://cranlogs.r-pkg.org/badges/splithalf)](https://cran.r-project.org/package=splithalf) 12 | 13 | # splithalf: robust estimates of split half reliability 14 | 15 | The `R` package **splithalf** provides tools to estimate the internal 16 | consistency reliability of cognitive measures. In particular, the tools 17 | were developed for application to tasks that use difference scores as 18 | the main outcome measure, for instance the Stroop score or dot-probe 19 | attention bias index (average RT in incongruent trials minus average RT 20 | in congruent trials). 21 | 22 | The methods in **splithalf** are built around split half reliability 23 | estimation. To increase the robustness of these estimates, the package 24 | implements a permutation approach that takes a large number of random 25 | (without replacement) split halves of the data. For each permutation the 26 | correlation between halves is calculated, with the Spearman-Brown 27 | correction applied (Spearman 1904). This process generates a 28 | distribution of reliability estimates from which we can extract summary 29 | statistics (e.g. average and 95% HDI). 30 | 31 | ### Why should I estimate the reliabilty of my task measurement? 32 | 33 | While many cognitive tasks yield robust effects (e.g. everybody shows a 34 | Stroop effect) they may not yield reliable individual differences 35 | (Hedge, Powell, and Sumner 2018). As these measures are used in 36 | questions of individual differences researchers need to have some 37 | psychometric information for the outcome measures. Recently, it was 38 | proposed that psychological science should set a standard expectation 39 | for the reporting of reliability information for cognitive and 40 | behavioural measures (Parsons, Kruijt, and Fox 2019). **splithalf** was 41 | developed to support this proposition by providing a tool to easily 42 | extract internal consistency reliability estimates from behavioural 43 | measures. 44 | 45 | ## Installation 46 | 47 | The latest release version (`0.7.2` unofficial version name: Kitten 48 | Mittens) can be installed from CRAN: 49 | 50 | ``` r 51 | install.packages("splithalf") 52 | ``` 53 | 54 | The current developmental version (`0.8.1` unofficial version name: Rum 55 | Ham) can be installed from Github with: 56 | 57 | ``` r 58 | devtools::install_github("sdparsons/splithalf") 59 | ``` 60 | 61 | **splithalf** requires the **tidyr** (Wickham and Henry 2019) and 62 | **dplyr** (Wickham et al. 2018) packages for data handling within the 63 | functions. The **robustbase** package is used to extract median scores 64 | when applicable. The computationally heavy tasks (extracting many random 65 | half samples of the data) are written in `c++` via the `R` package 66 | **Rcpp** (Eddelbuettel et al. 2018). Figures use the **ggplot** package 67 | (Wickham 2016), raincloud plots use code adapted from Allen et al. 68 | (Allen et al. 2019), and the **patchwork** package (Pedersen 2019) is 69 | used for plotting the multiverse analyses. 70 | 71 | ### Citing the package 72 | 73 | Citing packages is one way for developers to gain some recognition for 74 | the time spent maintaining the work. I would like to keep track of how 75 | the package is used so that I can solicit feedback and improve the 76 | package more generally. This would also help me track the uptake of 77 | reporting measurement reliability over time. 78 | 79 | Please use the following reference for the code: Parsons, S., (2021). 80 | splithalf: robust estimates of split half reliability. *Journal of Open 81 | Source Software, 6*(60), 3041, 82 | 83 | ### User feedback 84 | 85 | Developing the splithalf package is a labour of love (and occasionally 86 | burning hatred). If you have any suggestions for improvement, additional 87 | functionality, or anything else, please contact me 88 | (sam.parsons@psy.ox.ac.uk) or raise an issue on github 89 | (). Likewise, if you are having 90 | trouble using the package (e.g. scream fits at your computer screen – 91 | we’ve all been there) do contact me and I will do my best to help as 92 | quickly as possible. These kind of help requests are super welcome. In 93 | fact, the package has seen several increases in performance and 94 | usability due to people asking for help. 95 | 96 | ## Latest updates: 97 | 98 | **Version 0.8.1 now out! \[unofficial version name: “Rum Ham”\]** Lots 99 | of fixed issues in the multiverse functions, and lots more 100 | documentation/examples! 101 | 102 | **Now on github and submitted to CRAN: VERSION 0.7.2 \[unofficial 103 | version name: “Kitten Mittens”\]** Featuring reliability multiverse 104 | analyses!!! 105 | 106 | This update includes the addition of reliability multiverse functions. A 107 | *splithalf* object can be inputted into *splithalf.multiverse* to 108 | estimate reliability across a user-defined list of data-processing 109 | specifications (e.g. min/max RTs). Then, because sometimes science is 110 | more art than science, the multiverse output can be plotted with 111 | *multiverse.plot*. A brief tutorial can be found below, and a more 112 | comprehensive one can be found in a recent preprint (Parsons 2020). 113 | 114 | Additionally, the output of splithalf has been reworked. Now a list is 115 | returned including the specific function calls, the processed data. 116 | 117 | Since version 0.6.2 a user can also set `plot = TRUE` in *splithalf* to 118 | generate a raincloud plot of the distribution of reliability estimates. 119 | 120 | ## Examples 121 | 122 | ### A note on terminology used in this document 123 | 124 | It is important that we have a similar understanding of the terminology 125 | I use in the package and documentation. Each is also discussed in 126 | reference to the functions later in the documentation. 127 | 128 | - Trial – whatever happens in this task, e.g. a stimuli is presented. 129 | Importantly, participants give one response per trial 130 | - Trial type – often trials can be split into different trial types 131 | (e.g. to compare congruent and incongruent trials) 132 | - Condition - this might be different blocks of trials, or something 133 | to be assessed separately within the functions. e.g. a task might 134 | have a block of ‘positive’ trials and a block of ‘negative’ trials. 135 | - Datatype - I use this to refer to the outcome of interest. 136 | specifically whether one is interested in average response times or 137 | accuracy rates 138 | - Score - I use score to indicate how the final outcome is measured; 139 | e.g. the average RT, or the difference between two average RTs, or 140 | even the difference between two differences between two RTs (yes, 141 | the final one is confusing) 142 | 143 | ### A note on preprocessing 144 | 145 | The core function *splithalf* requires that the input dataset has 146 | already undergone preprocessing (e.g. removal of error trials, RT 147 | trimming, and participants with high error rates). Splithalf should 148 | therefore be used with the same data that will be used to calculate 149 | summary scores and outcome indices. The exception is in multiverse 150 | analyses, as described below. 151 | 152 | For those unfamiliar with R, the following snippets may help with common 153 | data-processing steps. I also highly recommend the Software Carpentry 154 | course “R for Reproducible Scientific Analysis” 155 | (). 156 | 157 | Note == indicates ‘is equal to,’ :: indicates that the function uses the 158 | package indicated, in the first case the **dplyr** package (Wickham et 159 | al. 2018). 160 | 161 | ``` r 162 | dataset %>% 163 | dplyr::filter(accuracy == 1) %>% ## keeps only trials in which participants made an accurate response 164 | dplyr::filter(RT >= 100, RT <= 2000) %>% ## removes RTs less than 100ms and greater than 2000ms 165 | dplyr::filter(participant != c(“p23”, “p45”) ## removes participants “p23” and “p45” 166 | ``` 167 | 168 | If following rt trims you also trimmed by SD, use the following as well. 169 | Note that this is for two standard deviations from the mean, within each 170 | participant, and within each condition and trialtype. 171 | 172 | ``` r 173 | dataset %>% 174 | dplyr::group_by(participant, condition, compare) %>% 175 | dplyr::mutate(low = mean(RT) - (2 * sd(RT)), 176 | high = mean(RT) + (2 * sd(RT))) %>% 177 | dplyr::filter(RT >= low & RT <= high) 178 | ``` 179 | 180 | If you want to save yourself effort in running splithalf, you could also 181 | rename your variable (column) names to the function defaults using the 182 | following 183 | 184 | ``` r 185 | dplyr::rename(dataset, 186 | RT = "latency", 187 | condition = FALSE, 188 | participant = "subject", 189 | correct = "correct", 190 | trialnum = "trialnum", 191 | compare = "congruency") 192 | ``` 193 | 194 | The following examples assume that you have already processed your data 195 | to remove outliers, apply any RT cutoffs, etc. A reminder: the data you 196 | input into *splithalf* should be the same as that used to create your 197 | final scores - otherwise the resultant estimates will not accurately 198 | reflect the reliability of your data. 199 | 200 | ### Questions to ask before running splithalf 201 | 202 | These questions should feed into what settings are appropriate for your 203 | need, and are aimed to make the *splithalf* function easy to use. 204 | 205 | 1. **What type of data do you have?** 206 | 207 | Are you interested in response times, or accuracy rates? 208 | 209 | Knowing this, you can set `outcome = "RT"`, or `outcome = "accuracy"` 210 | 211 | 2. **How is your outcome score calculated?** 212 | 213 | Say that your response time based task has two trial types; 214 | “incongruent” and “congruent.” When you analyse your data will you use 215 | the average RT in each trial type, or will you create a difference score 216 | (or bias) by e.g. subtracting the average RT in congruent trials from 217 | the average RT in incongruent trials. The first can be called with 218 | `score = "average"` and the second with `score = "difference"`. 219 | 220 | 3. **Which method would you like to use to estimate (split-half) 221 | reliability?** 222 | 223 | A super common way is to split the data into odd and even trials. 224 | Another is to split by the first half and second half of the trials. 225 | Both approaches are implemented in the *splithalf* funciton. However, I 226 | believe that the permutation splithalf approach is the most applicable 227 | in general and so the default is `halftype = "random"` 228 | 229 | ### An example dataset 230 | 231 | For this brief example, we will simulate some data for 60 participants, 232 | who each completed a task with two blocks (A and B) of 80 trials. Trials 233 | are also evenly distributed between “congruent” and “incongruent” 234 | trials. For each trial we have RT data, and are assuming that 235 | participants were accurate in all trials. 236 | 237 | ``` r 238 | n_participants = 60 ## sample size 239 | n_trials = 80 240 | n_blocks = 2 241 | 242 | sim_data <- data.frame(participant_number = rep(1:n_participants, each = n_blocks * n_trials), 243 | trial_number = rep(1:n_trials, times = n_blocks * n_participants), 244 | block_name = rep(c("A","B"), each = n_trials, length.out = n_participants * n_trials * n_blocks), 245 | trial_type = rep(c("congruent","incongruent"), length.out = n_participants * n_trials * n_blocks), 246 | RT = rnorm(n_participants * n_trials * n_blocks, 500, 200), 247 | ACC = 1) 248 | ``` 249 | 250 | ### Difference scores 251 | 252 | This is by far the most common outcome measure I have come across, so 253 | lets start with that. 254 | 255 | Our data will be analysed so that we have two ‘bias’ or ‘difference 256 | score’ outcomes. So, within each block, we will take the average RT in 257 | congruent trials and subtract the average RT in incongruent trials. 258 | Calculating the final scores for each participant and for each block 259 | separately could be done as follows: 260 | 261 | ``` r 262 | library("dplyr") 263 | library("tidyr") 264 | 265 | sim_data %>% 266 | dplyr::group_by(participant_number, block_name, trial_type) %>% 267 | dplyr::summarise(average = mean(RT)) %>% 268 | tidyr::spread(trial_type, average) %>% 269 | dplyr::mutate(bias = congruent - incongruent) 270 | # A tibble: 120 x 5 271 | # Groups: participant_number, block_name [120] 272 | participant_number block_name congruent incongruent bias 273 | 274 | 1 1 A 550. 430. 120. 275 | 2 1 B 512. 433. 78.9 276 | 3 2 A 525. 496. 28.6 277 | 4 2 B 488. 523. -35.2 278 | 5 3 A 457. 500. -43.6 279 | 6 3 B 478. 518. -39.3 280 | 7 4 A 492. 479. 13.1 281 | 8 4 B 593. 458. 135. 282 | 9 5 A 568. 565. 2.72 283 | 10 5 B 485. 555. -70.3 284 | # ... with 110 more rows 285 | ``` 286 | 287 | To estimate reliability with *splithalf* we run the following. 288 | 289 | ``` r 290 | library("splithalf") 291 | 292 | difference <- splithalf(data = sim_data, 293 | outcome = "RT", 294 | score = "difference", 295 | conditionlist = c("A", "B"), 296 | halftype = "random", 297 | permutations = 5000, 298 | var.RT = "RT", 299 | var.condition = "block_name", 300 | var.participant = "participant_number", 301 | var.compare = "trial_type", 302 | compare1 = "congruent", 303 | compare2 = "incongruent", 304 | average = "mean", 305 | plot = TRUE) 306 | ``` 307 | 308 | condition n splithalf 95_low 95_high spearmanbrown SB_low SB_high 309 | 1 A 60 -0.06 -0.23 0.13 -0.10 -0.37 0.23 310 | 2 B 60 -0.13 -0.30 0.06 -0.22 -0.46 0.10 311 | 312 | Specifying `plot = TRUE` will also allow you to plot the distributions 313 | of reliability estimates. you can extract the plot from a saved object 314 | with e.g. `difference$plot`. 315 | 316 | ![](man/figures/README-plotting_distribution-1.png) 317 | 318 | ### Reading and reporting the output 319 | 320 | The *splithalf* output gives estimates separately for each condition 321 | defined (if no condition is defined, the function assumes that you have 322 | only a single condition, which it will call “all” to represent that all 323 | trials were included). 324 | 325 | The second column (n) gives the number of participants analysed. If, for 326 | some reason one participant has too few trials to analyse, or did not 327 | complete one condition, this will be reflected here. I suggest you 328 | compare this n to your expected n to check that everything is running 329 | correctly. If the ns dont match, we have a problem. More likely, R will 330 | give an error message, but useful to know. 331 | 332 | Next are the estimates; the splithalf column and the associated 95% 333 | percentile intervals, and the Spearman-Brown corrected estimate with its 334 | own percentile intervals. Unsurprisingly, our simlated random data does 335 | not yield internally consistant measurements. 336 | 337 | *What should I report?* My preference is to report everything. 95% 338 | percentiles of the estimates are provided to give a picture of the 339 | spread of internal consistency estimates. Also included is the 340 | spearman-brown corrected estimates, which take into account that the 341 | estimates are drawn from half the trials that they could have been. 342 | Negative reliabilities are near uninterpretable and the spearman-brown 343 | formula is not useful in this case. 344 | 345 | > We estimated the internal consitency of bias A and B using a 346 | > permutation-based splithalf approach (Parsons 2019) with 5000 random 347 | > splits. The (Spearman-Brown corrected) splithalf internal consistency 348 | > of bias A was were *r*SB = -0.1, 95%CI \[-0.37,0.23\]. 349 | > 350 | > — Parsons, 2020 351 | 352 | ### Average scores 353 | 354 | For some tasks the outcome measure may simply be the average RT. In this 355 | case, we will ignore the trial type option. We will extract separate 356 | outcome scores for each block of trials, but this time it is simply the 357 | average RT in each block. Note that the main difference in this code is 358 | that we have omitted the inputs about what trial types to ‘compare,’ as 359 | this is irrelevant for the current task. 360 | 361 | ``` r 362 | average <- splithalf(data = sim_data, 363 | outcome = "RT", 364 | score = "average", 365 | conditionlist = c("A", "B"), 366 | halftype = "random", 367 | permutations = 5000, 368 | var.RT = "RT", 369 | var.condition = "block_name", 370 | var.participant = "participant_number", 371 | average = "mean") 372 | ``` 373 | 374 | condition n splithalf 95_low 95_high spearmanbrown SB_low SB_high 375 | 1 A 60 0.16 -0.02 0.34 0.26 -0.03 0.51 376 | 2 B 60 0.05 -0.13 0.24 0.09 -0.23 0.39 377 | 378 | ### Difference-of-difference scores 379 | 380 | The difference of differences score is a bit more complex, and perhaps 381 | also less common. I programmed this aspect of the package initially 382 | because I had seen a few papers that used a change in bias score in 383 | their analysis, and I wondered “I wonder how reliable that is as an 384 | individual difference measure.” Be warned, difference scores are nearly 385 | always less reliable than raw averages, and differences-of-differences 386 | will be less reliable again. 387 | 388 | Our difference-of-difference variable in our task is the difference 389 | between bias observed in block A and B. So our outcome is calculated 390 | something like this. 391 | 392 | BiasA = incongruent\_A - congruent\_A 393 | 394 | BiasB = incongruent\_B - congruent\_B 395 | 396 | Outcome = BiasB - BiasA 397 | 398 | In our function, we specify this very similarly as in the difference 399 | score example. The only change will be changing the score to 400 | “difference\_of\_difference.” Note that we will keep the condition list 401 | consisting of A and B. But, specifying that we are interested in the 402 | difference of differences will lead the function to calculate the 403 | outcome scores apropriately. 404 | 405 | ``` r 406 | diff_of_diff <- splithalf(data = sim_data, 407 | outcome = "RT", 408 | score = "difference_of_difference", 409 | conditionlist = c("A", "B"), 410 | halftype = "random", 411 | permutations = 5000, 412 | var.RT = "RT", 413 | var.condition = "block_name", 414 | var.participant = "participant_number", 415 | var.compare = "trial_type", 416 | compare1 = "congruent", 417 | compare2 = "incongruent", 418 | average = "mean") 419 | ``` 420 | 421 | condition n splithalf 95_low 95_high spearmanbrown 422 | 1 difference_of_difference score 60 -0.12 -0.29 0.07 -0.21 423 | SB_low SB_high 424 | 1 -0.45 0.13 425 | 426 | ## Multiverse analysis extension 427 | 428 | This example is simplified from Parsons (2020). The process takes four 429 | steps. First, specify a list of data processing decisions. Here, we’ll 430 | specify only removing trials greater or lower than a specified amount. 431 | More options are available, such as total accuracy cutoff thresholds for 432 | participant removals. 433 | 434 | ``` r 435 | specifications <- list(RT_min = c(0, 100, 200), 436 | RT_max = c(1000, 2000), 437 | averaging_method = c("mean", "median")) 438 | ``` 439 | 440 | Second, perform `splithalf(...)`. The key difference here, compared to 441 | the earlier examples is that we are no longer assuming that all data 442 | processing has already occurred. Instead, the data processing will be 443 | performed as part of `splithalf.multiverse`, next. 444 | 445 | ``` r 446 | difference <- splithalf(data = sim_data, 447 | outcome = "RT", 448 | score = "difference", 449 | conditionlist = c("A"), 450 | halftype = "random", 451 | permutations = 5000, 452 | var.RT = "RT", 453 | var.condition = "block_name", 454 | var.participant = "participant_number", 455 | var.compare = "trial_type", 456 | var.ACC = "ACC", 457 | compare1 = "congruent", 458 | compare2 = "incongruent", 459 | average = "mean") 460 | ``` 461 | 462 | Third, perform `splithalf.multiverse` with the specification list and 463 | splithalf objects as inputs 464 | 465 | ``` r 466 | multiverse <- splithalf.multiverse(input = difference, 467 | specifications = specifications) 468 | ``` 469 | 470 | Finally, plot the multiverse with plot.multiverse. 471 | 472 | ``` r 473 | multiverse.plot(multiverse = multiverse, 474 | title = "README multiverse") 475 | ``` 476 | 477 | ![](man/figures/README-multiverse_plot-1.png) 478 | 479 | For more information, see Parsons (2020). 480 | 481 | ## Other considerations 482 | 483 | ### how many permutations? 484 | 485 | To examine how many random splits are required to provide a precise 486 | estimate, a short simulation was performed including 20 estimates of the 487 | spearman-brown reliability estimate, for each of 1, 10, 50, 100, 1000, 488 | 2000, 5000, 10000, and 20000 random splits. This simulation was 489 | performed on data from one block of 80 trials. Based on this simulation, 490 | I recommend 5000 (or more) random splits be used to calculate split-half 491 | reliability. 5000 permutations yielded a standard deviation of .002 and 492 | a total range of .008, indicating that the reliability estimates are 493 | stable to two decimal places with this number of random splits. 494 | Increasing the number of splits improved precision, however 20000 splits 495 | were required to reduce the standard deviation to .001. 496 | 497 | ### *splithalf* runtime? 498 | 499 | The speed of *splithalf* rests entirely on the number of conditions, 500 | participants, and permutations. The biggest factor will be your machine 501 | speed. For relative times, I ran a simulation with a range of sample 502 | sizes, numbers of conditions, numbers of trials, and permutations. The 503 | data is contained within the package as `data/speedtest.rda` 504 | 505 | ![](man/figures/README-speedtest-1.png) 506 | 507 | ## Future development 508 | 509 | The **splithalf** package is still under development. If you have 510 | suggestions for improvements to the package, or bugs to report, please 511 | raise an issue on github (). 512 | Currently, I have the following on my immediate to do list: 513 | 514 | - error tracking 515 | - I plan to develop a function that catches potential issues that 516 | could arise with the functions. 517 | - I also plan to document common R warnings and errors that arise 518 | and why (as sometimes without knowing exactly how the functions 519 | work these issues can be harder to trace back). 520 | - include other scoring methods: 521 | - signal detection, e.g. d prime 522 | - potentially customisable methods, e.g. where the outcome is 523 | scored in formats similar to A - B / A + B 524 | 525 | ## Comparison to other software 526 | 527 | **splithalf** is the only package to implement all of these tools, in 528 | particular reliability multiverse analyses. Some other `R` packages 529 | offer a bootstrapped approach to split-half reliability **multicon** 530 | (Sherman 2015), **psych** (Revelle 2019), and **splithalfr** (Pronk 531 | 2020) 532 | 533 | ## References 534 | 535 |
536 | 537 |
538 | 539 | Allen, Micah, Davide Poggiali, Kirstie Whitaker, Tom Rhys Marshall, and 540 | Rogier A. Kievit. 2019. “Raincloud Plots: A Multi-Platform Tool for 541 | Robust Data Visualization.” *Wellcome Open Research* 4 (April): 63. 542 | . 543 | 544 |
545 | 546 |
547 | 548 | Eddelbuettel, Dirk, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou, 549 | Nathan Russell, Douglas Bates, and John Chambers. 2018. *Rcpp: Seamless 550 | r and c++ Integration*. . 551 | 552 |
553 | 554 |
555 | 556 | Hedge, Craig, Georgina Powell, and Petroc Sumner. 2018. “The Reliability 557 | Paradox: Why Robust Cognitive Tasks Do Not Produce Reliable Individual 558 | Differences.” *Behavior Research Methods* 50 (3): 1166–86. 559 | . 560 | 561 |
562 | 563 |
564 | 565 | Parsons, Sam. 2019. “Splithalf; Robust Estimates of Split Half 566 | Reliability.” . 567 | 568 |
569 | 570 |
571 | 572 | ———. 2020. “Exploring Reliability Heterogeneity with Multiverse 573 | Analyses: Data Processing Decisions Unpredictably Influence Measurement 574 | Reliability.” Preprint, June. . 575 | 576 |
577 | 578 |
579 | 580 | Parsons, Sam, Anne-Wil Kruijt, and Elaine Fox. 2019. “Psychological 581 | Science Needs a Standard Practice of Reporting the Reliability of 582 | Cognitive Behavioural Measurements.” Advances in Methods; Practices in 583 | Psychological Science. https://doi.org/10.1177/2515245919879695. 584 | 585 |
586 | 587 |
588 | 589 | Pedersen, Thomas Lin. 2019. *Patchwork: The Composer of Plots*. 590 | . 591 | 592 |
593 | 594 |
595 | 596 | Pronk, Thomas. 2020. *Splithalfr: Extensible Bootstrapped Split-Half 597 | Reliabilities*. . 598 | 599 |
600 | 601 |
602 | 603 | Revelle, William. 2019. *Psych: Procedures for Psychological, 604 | Psychometric, and Personality Research*. Evanston, Illinois: 605 | Northwestern University. . 606 | 607 |
608 | 609 |
610 | 611 | Sherman, Ryne A. 2015. *Multicon: Multivariate Constructs*. 612 | . 613 | 614 |
615 | 616 |
617 | 618 | Spearman, C. 1904. “The Proof and Measurement of Association Between Two 619 | Things.” *The American Journal of Psychology* 15 (1): 72. 620 | https://doi.org/10.2307/1412159. 621 | 622 |
623 | 624 |
625 | 626 | Wickham, Hadley. 2016. *Ggplot2: Elegant Graphics for Data Analysis*. 627 | Springer-Verlag New York. . 628 | 629 |
630 | 631 |
632 | 633 | Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2018. 634 | *Dplyr: A Grammar of Data Manipulation*. 635 | . 636 | 637 |
638 | 639 |
640 | 641 | Wickham, Hadley, and Lionel Henry. 2019. *Tidyr: Tidy Messy Data*. 642 | . 643 | 644 |
645 | 646 |
647 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | Comments on cran checks: 2 | 3 | 4 | 1. I have moved institutions and so my email has changed 5 | 6 | 7 | 2. I received the following note: 8 | checking compiled code ... NOTE 9 | Note: information on .o files for i386 is not available 10 | Note: information on .o files for x64 is not available 11 | File 'C:/Users/samdp/AppData/Local/Temp/RtmpAdYuSM/splithalf.Rcheck/splithalf/libs/i386/splithalf.dll': 12 | Found 'abort', possibly from 'abort' (C), 'runtime' (Fortran) 13 | Found 'exit', possibly from 'exit' (C), 'stop' (Fortran) 14 | Found 'printf', possibly from 'printf' (C) 15 | File 'C:/Users/samdp/AppData/Local/Temp/RtmpAdYuSM/splithalf.Rcheck/splithalf/libs/x64/splithalf.dll': 16 | Found 'abort', possibly from 'abort' (C), 'runtime' (Fortran) 17 | Found 'exit', possibly from 'exit' (C), 'stop' (Fortran) 18 | Found 'printf', possibly from 'printf' (C) 19 | 20 | Compiled code should not call entry points which might terminate R nor 21 | write to stdout/stderr instead of to the console, nor use Fortran I/O 22 | nor system RNGs. The detected symbols are linked into the code but 23 | might come from libraries and not actually be called. 24 | 25 | See 'Writing portable packages' in the 'Writing R Extensions' manual. 26 | 27 | 28 | I believe this is a false-positive ref https://stackoverflow.com/questions/64402688/information-on-o-files-for-x64-is-not-available-note-on-r-package-checks-using 29 | -------------------------------------------------------------------------------- /data/speedtestdata.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdparsons/splithalf/d9a9ab551319ec9f36353d873ba9e7b5e63199e1/data/speedtestdata.rda -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite splithalf in publications, please use:") 2 | 3 | citEntry( 4 | entry = "Misc", 5 | title = "splithalf; robust estimates of split half reliability", 6 | author = personList(as.person("Sam Parsons")), 7 | url = "https://doi.org/10.21105/joss.03041", 8 | 9 | textVersion = "Parsons, S., (2021). splithalf: robust estimates of split half reliability. Journal of Open Source Software, 6(60), 3041, https://doi.org/10.21105/joss.03041", 10 | 11 | year = "2021") 12 | -------------------------------------------------------------------------------- /inst/book.bib: -------------------------------------------------------------------------------- 1 | @Manual{R-splithalf, 2 | title = {splithalf: robust estimates of split half reliability.}, 3 | author = {Sam Parsons}, 4 | year = {2020}, 5 | note = {R package version 0.7.2}, 6 | url = {https://doi.org/10.6084/m9.figshare.11956746.v4}, 7 | } 8 | 9 | @Book{xie2015, 10 | title = {Dynamic Documents with {R} and knitr}, 11 | author = {Yihui Xie}, 12 | publisher = {Chapman and Hall/CRC}, 13 | address = {Boca Raton, Florida}, 14 | year = {2015}, 15 | edition = {2nd}, 16 | note = {ISBN 978-1498716963}, 17 | url = {http://yihui.name/knitr/}, 18 | doi = {10.1201/b15166} 19 | } 20 | 21 | @Manual{R-bookdown, 22 | title = {bookdown: Authoring Books and Technical Documents with R Markdown}, 23 | author = {Yihui Xie}, 24 | year = {2018}, 25 | note = {R package version 0.7}, 26 | url = {https://CRAN.R-project.org/package=bookdown}, 27 | } 28 | 29 | @Manual{R-Rcpp, 30 | title = {Rcpp: Seamless R and C++ Integration}, 31 | author = {Dirk Eddelbuettel and Romain Francois and JJ Allaire and Kevin Ushey and Qiang Kou and Nathan Russell and Douglas Bates and John Chambers}, 32 | year = {2018}, 33 | note = {R package version 0.12.19}, 34 | url = {https://CRAN.R-project.org/package=Rcpp}, 35 | } 36 | 37 | @Manual{R-tidyverse, 38 | title = {tidyverse: Easily Install and Load the 'Tidyverse'}, 39 | author = {Hadley Wickham}, 40 | year = {2017}, 41 | note = {R package version 1.2.1}, 42 | url = {https://CRAN.R-project.org/package=tidyverse}, 43 | } 44 | 45 | @Manual{R-base, 46 | title = {R: A Language and Environment for Statistical Computing}, 47 | author = {{R Core Team}}, 48 | organization = {R Foundation for Statistical Computing}, 49 | address = {Vienna, Austria}, 50 | year = {2017}, 51 | url = {https://www.R-project.org/}, 52 | } 53 | 54 | @Manual{R-dplyr, 55 | title = {dplyr: A Grammar of Data Manipulation}, 56 | author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller}, 57 | year = {2018}, 58 | note = {R package version 0.7.7}, 59 | url = {https://CRAN.R-project.org/package=dplyr}, 60 | } 61 | 62 | @misc{parsons_kruijt_fox_2019, 63 | title={Psychological Science needs a standard practice of reporting the reliability of cognitive behavioural measurements}, 64 | url={https://doi.org/10.1177/2515245919879695}, 65 | DOI={10.1177/2515245919879695}, 66 | publisher={Advances in Methods and Practices in Psychological Science}, 67 | author={Sam Parsons and Anne-Wil Kruijt and Elaine Fox}, 68 | year={2019}, 69 | month={Jun} 70 | } 71 | 72 | @Manual{R-patchwork, 73 | title = {patchwork: The Composer of Plots}, 74 | author = {Thomas Lin Pedersen}, 75 | year = {2019}, 76 | note = {R package version 1.0.0}, 77 | url = {https://CRAN.R-project.org/package=patchwork}, 78 | } 79 | 80 | @Misc{R-splithalf, 81 | title = {splithalf; robust estimates of split half reliability}, 82 | author = {Sam Parsons}, 83 | url = {https://doi.org/10.6084/m9.figshare.5559175.v5}, 84 | year = {2019}, 85 | } 86 | 87 | @Manual{R-tidyr, 88 | title = {tidyr: Tidy Messy Data}, 89 | author = {Hadley Wickham and Lionel Henry}, 90 | year = {2019}, 91 | note = {R package version 1.0.0}, 92 | url = {https://CRAN.R-project.org/package=tidyr}, 93 | } 94 | 95 | @article{allen_raincloud_2019, 96 | title = {Raincloud plots: a multi-platform tool for robust data visualization}, 97 | volume = {4}, 98 | issn = {2398-502X}, 99 | shorttitle = {Raincloud plots}, 100 | url = {https://wellcomeopenresearch.org/articles/4-63/v1}, 101 | doi = {10.12688/wellcomeopenres.15191.1}, 102 | language = {en}, 103 | urldate = {2020-12-30}, 104 | journal = {Wellcome Open Research}, 105 | author = {Micah Allen and Davide Poggiali and Kirstie Whitaker and Tom Rhys Marshall and Rogier A. Kievit}, 106 | month = apr, 107 | year = {2019}, 108 | pages = {63}, 109 | file = {Allen et al. - 2019 - Raincloud plots a multi-platform tool for robust .pdf:C\:\\Users\\samdp\\Zotero\\storage\\IR4CSW4F\\Allen et al. - 2019 - Raincloud plots a multi-platform tool for robust .pdf:application/pdf} 110 | } 111 | 112 | @Book{R-ggplot2, 113 | author = {Hadley Wickham}, 114 | title = {ggplot2: Elegant Graphics for Data Analysis}, 115 | publisher = {Springer-Verlag New York}, 116 | year = {2016}, 117 | isbn = {978-3-319-24277-4}, 118 | url = {https://ggplot2.tidyverse.org}, 119 | } 120 | 121 | @article{parsons_exploring_2020, 122 | title = {Exploring reliability heterogeneity with multiverse analyses: {Data} processing decisions unpredictably influence measurement reliability}, 123 | author = {Sam Parsons}, 124 | type = {preprint}, 125 | shorttitle = {Exploring reliability heterogeneity with multiverse analyses}, 126 | url = {https://osf.io/y6tcz}, 127 | language = {en}, 128 | urldate = {2020-11-07}, 129 | institution = {PsyArXiv}, 130 | month = jun, 131 | year = {2020}, 132 | doi = {10.31234/osf.io/y6tcz}, 133 | } 134 | 135 | @Manual{R-psych, 136 | title = {psych: Procedures for Psychological, Psychometric, and Personality Research}, 137 | author = {William Revelle}, 138 | organization = { Northwestern University}, 139 | address = { Evanston, Illinois}, 140 | year = {2019}, 141 | note = {R package version 1.9.12}, 142 | url = {https://CRAN.R-project.org/package=psych}, 143 | } 144 | 145 | @Manual{R-multicon, 146 | title = {multicon: Multivariate Constructs}, 147 | author = {Ryne A. Sherman}, 148 | year = {2015}, 149 | note = {R package version 1.6}, 150 | url = {https://CRAN.R-project.org/package=multicon}, 151 | } 152 | 153 | @Manual{R-splithalfr, 154 | title = {splithalfr: Extensible Bootstrapped Split-Half Reliabilities}, 155 | author = {Thomas Pronk}, 156 | year = {2020}, 157 | note = {R package version 2.0.12}, 158 | url = {https://CRAN.R-project.org/package=splithalfr}, 159 | } 160 | 161 | @article{spearman_proof_1904, 162 | title = {The Proof and Measurement of Association between Two Things}, 163 | volume = {15}, 164 | issn = {00029556}, 165 | url = {https://www.jstor.org/stable/1412159?origin=crossref}, 166 | doi = {10.2307/1412159}, 167 | pages = {72}, 168 | number = {1}, 169 | journaltitle = {The American Journal of Psychology}, 170 | author = {Spearman, C.}, 171 | urldate = {2019-01-21}, 172 | date = {1904-01}, 173 | langid = {english}, 174 | note = {04804}, 175 | file = {Spearman - 1904 - The Proof and Measurement of Association between T.pdf:C\:\\Users\\parsonss\\Zotero\\storage\\96K6JFIT\\Spearman - 1904 - The Proof and Measurement of Association between T.pdf:application/pdf} 176 | } 177 | 178 | @article{hedge_reliability_2018, 179 | title = {The reliability paradox: Why robust cognitive tasks do not produce reliable individual differences}, 180 | volume = {50}, 181 | issn = {1554-3528}, 182 | url = {http://link.springer.com/10.3758/s13428-017-0935-1}, 183 | doi = {10.3758/s13428-017-0935-1}, 184 | shorttitle = {The reliability paradox}, 185 | pages = {1166--1186}, 186 | number = {3}, 187 | journaltitle = {Behavior Research Methods}, 188 | author = {Hedge, Craig and Powell, Georgina and Sumner, Petroc}, 189 | urldate = {2019-01-16}, 190 | date = {2018-06}, 191 | langid = {english}, 192 | file = {Hedge et al. - 2018 - The reliability paradox Why robust cognitive task.pdf:C\:\\Users\\parsonss\\Zotero\\storage\\EP44ZT4Z\\Hedge et al. - 2018 - The reliability paradox Why robust cognitive task.pdf:application/pdf} 193 | } 194 | -------------------------------------------------------------------------------- /inst/hexlogo/splithalf_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdparsons/splithalf/d9a9ab551319ec9f36353d873ba9e7b5e63199e1/inst/hexlogo/splithalf_logo.png -------------------------------------------------------------------------------- /man/figures/README-multiverse_plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdparsons/splithalf/d9a9ab551319ec9f36353d873ba9e7b5e63199e1/man/figures/README-multiverse_plot-1.png -------------------------------------------------------------------------------- /man/figures/README-plotting_distribution-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdparsons/splithalf/d9a9ab551319ec9f36353d873ba9e7b5e63199e1/man/figures/README-plotting_distribution-1.png -------------------------------------------------------------------------------- /man/figures/README-speedtest-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sdparsons/splithalf/d9a9ab551319ec9f36353d873ba9e7b5e63199e1/man/figures/README-speedtest-1.png -------------------------------------------------------------------------------- /man/multiverse.plot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot_multiverse.R, R/threshold.R 3 | \name{multiverse.plot} 4 | \alias{multiverse.plot} 5 | \alias{threshold} 6 | \title{Visualising reliability multiverses} 7 | \usage{ 8 | multiverse.plot( 9 | multiverse, 10 | title = "", 11 | vline = "none", 12 | heights = c(4, 5), 13 | SE = FALSE 14 | ) 15 | 16 | threshold(multiverse, threshold, use = "estimate", dir = "above") 17 | } 18 | \arguments{ 19 | \item{multiverse}{multiverse object} 20 | 21 | \item{title}{string add a title to the plot? default is ""} 22 | 23 | \item{vline}{add a vertical line to the plot, e.g. use .5 for the median reliability estimate} 24 | 25 | \item{heights}{must be a vector of length 2, relative heights of plot panels. Defaults to c(4,5)} 26 | 27 | \item{SE}{logical includes an additional panel to plot the standard errors of the scores. Note: the heights parameter must be a vector of length 3, e.g. c(2,2,3). Defaults to FALSE} 28 | 29 | \item{threshold}{threshold to look for, e.g. 0.7} 30 | 31 | \item{use}{set to check the reliability "estimates", or the "upper" or "lower" CIs} 32 | 33 | \item{dir}{look "above" or "below" the 'use' at the set threshold} 34 | } 35 | \value{ 36 | Returns a visualization of a multiverse object 37 | } 38 | \description{ 39 | This function allows the user to plot the output from splithalf_multiverse or testretest_multiverse. The plot includes an upper panel with all reliability estimates (and CIs) and a lower panel that indicates the data processing specifications corresponding to that reliability estimate. 40 | The (unofficial) function version name is "This function will make you a master in bird law" 41 | 42 | This function examines the output from splithalf_multiverse or testretest_multiverse to extract the proportions of estimates above or below a set threshold (can be the estimate or the upper or lower CI estimates). 43 | The (unofficial) function version name is "This function will get you up to here with it" 44 | } 45 | \examples{ 46 | \dontrun{ 47 | ## see online documentation for examples 48 | https://github.com/sdparsons/splithalf 49 | ## also see https://psyarxiv.com/y6tcz 50 | 51 | ## example simulated data 52 | n_participants = 60 ## sample size 53 | n_trials = 80 54 | n_blocks = 2 55 | sim_data <- data.frame(participant_number = rep(1:n_participants, 56 | each = n_blocks * n_trials), 57 | trial_number = rep(1:n_trials, 58 | times = n_blocks * n_participants), 59 | block_name = rep(c("A","B"), 60 | each = n_trials, 61 | length.out = n_participants * n_trials * n_blocks), 62 | trial_type = rep(c("congruent","incongruent"), 63 | length.out = n_participants * n_trials * n_blocks), 64 | RT = rnorm(n_participants * n_trials * n_blocks, 65 | 500, 66 | 200), 67 | ACC = 1) 68 | 69 | ## specify several data processing decisions 70 | specifications <- list(RT_min = c(0, 100, 200), 71 | RT_max = c(1000, 2000), 72 | averaging_method = c("mean", "median")) 73 | ## run splithalf, and save the output 74 | difference <- splithalf(data = sim_data, 75 | outcome = "RT", 76 | score = "difference", 77 | conditionlist = c("A"), 78 | halftype = "random", 79 | permutations = 5000, 80 | var.RT = "RT", 81 | var.condition = "block_name", 82 | var.participant = "participant_number", 83 | var.compare = "trial_type", 84 | var.ACC = "ACC", 85 | compare1 = "congruent", 86 | compare2 = "incongruent", 87 | average = "mean") 88 | 89 | ## run splithalf.multiverse to perform the multiverse of data processing 90 | ## and reliability estimation 91 | multiverse <- splithalf.multiverse(input = difference, 92 | specifications = specifications) 93 | 94 | ## can be plot with: 95 | multiverse.plot(multiverse = multiverse, 96 | title = "README multiverse") 97 | 98 | } 99 | \dontrun{ 100 | ## see online documentation for examples 101 | https://github.com/sdparsons/splithalf 102 | ## also see https://psyarxiv.com/y6tcz 103 | 104 | ## example simulated data 105 | n_participants = 60 ## sample size 106 | n_trials = 80 107 | n_blocks = 2 108 | sim_data <- data.frame(participant_number = rep(1:n_participants, 109 | each = n_blocks * n_trials), 110 | trial_number = rep(1:n_trials, 111 | times = n_blocks * n_participants), 112 | block_name = rep(c("A","B"), 113 | each = n_trials, 114 | length.out = n_participants * n_trials * n_blocks), 115 | trial_type = rep(c("congruent","incongruent"), 116 | length.out = n_participants * n_trials * n_blocks), 117 | RT = rnorm(n_participants * n_trials * n_blocks, 118 | 500, 119 | 200), 120 | ACC = 1) 121 | 122 | ## specify several data processing decisions 123 | specifications <- list(RT_min = c(0, 100, 200), 124 | RT_max = c(1000, 2000), 125 | averaging_method = c("mean", "median")) 126 | ## run splithalf, and save the output 127 | difference <- splithalf(data = sim_data, 128 | outcome = "RT", 129 | score = "difference", 130 | conditionlist = c("A"), 131 | halftype = "random", 132 | permutations = 5000, 133 | var.RT = "RT", 134 | var.condition = "block_name", 135 | var.participant = "participant_number", 136 | var.compare = "trial_type", 137 | var.ACC = "ACC", 138 | compare1 = "congruent", 139 | compare2 = "incongruent", 140 | average = "mean") 141 | 142 | ## run splithalf.multiverse to perform the multiverse of data processing 143 | ## and reliability estimation 144 | multiverse <- splithalf.multiverse(input = difference, 145 | specifications = specifications) 146 | 147 | 148 | ## the threshold function can be used to return the number of estimates 149 | ## above or below a certain threshold 150 | 151 | threshold(multiverse = multiverse, 152 | threshold = 0.7, 153 | use = "estimate", 154 | dir = "above") 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /man/speedtestdata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{speedtestdata} 5 | \alias{speedtestdata} 6 | \title{Simulated data for runtime of splithalf package} 7 | \format{ 8 | A data frame with 225 rows and 6 variables 9 | } 10 | \usage{ 11 | data(speedtestdata) 12 | } 13 | \description{ 14 | This simulation was run to estimate the relative runtimes for different possible combinations of sample sizes and trial numbers etc. 15 | } 16 | \details{ 17 | \itemize{ 18 | \item{Sim}{codes for the simulation number} 19 | \item{sample_size}{codes for the sample size} 20 | \item{Number_of_conditions}{codes for the number of conditions run} 21 | \item{trials}{codes for the number of trials} 22 | \item{permutations}{codes for the number of permutations} 23 | \item{runtime}{codes for the runtime in seconds} 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/splithalf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splithalf.R 3 | \name{splithalf} 4 | \alias{splithalf} 5 | \title{Internal consistency of task measures via a permutation split-half reliability approach} 6 | \usage{ 7 | splithalf( 8 | data, 9 | outcome = "RT", 10 | score = "difference", 11 | conditionlist = FALSE, 12 | halftype = "random", 13 | permutations = 5000, 14 | var.RT = "latency", 15 | var.ACC = "accuracy", 16 | var.condition = FALSE, 17 | var.participant = "subject", 18 | var.compare = "congruency", 19 | compare1 = "Congruent", 20 | compare2 = "Incongruent", 21 | average = "mean", 22 | plot = FALSE, 23 | round.to = 2, 24 | check = TRUE 25 | ) 26 | } 27 | \arguments{ 28 | \item{data}{specifies the raw dataset to be processed} 29 | 30 | \item{outcome}{indicates the type of data to be processed, e.g. "RT" or "accuracy"} 31 | 32 | \item{score}{indicates how the outcome score is calculated, e.g. most commonly the difference score between two trial types. Can be "average", "difference", "difference_of_difference", and "DPrime"} 33 | 34 | \item{conditionlist}{sets conditions/blocks to be processed} 35 | 36 | \item{halftype}{specifies the split method; "oddeven", "halfs", or "random"} 37 | 38 | \item{permutations}{specifies the number of random splits to run - 5000 is good} 39 | 40 | \item{var.RT}{specifies the RT variable name in data} 41 | 42 | \item{var.ACC}{specific the accuracy variable name in data} 43 | 44 | \item{var.condition}{specifies the condition variable name in data - if not specified then splithalf will treat all trials as one condition} 45 | 46 | \item{var.participant}{specifies the subject variable name in data} 47 | 48 | \item{var.compare}{specifies the variable that is used to calculate difference scores (e.g. including congruent and incongruent trials)} 49 | 50 | \item{compare1}{specifies the first trial type to be compared (e.g. congruent trials)} 51 | 52 | \item{compare2}{specifies the second trial type to be compared (e.g. incongruent trials)} 53 | 54 | \item{average}{use "mean" or "median" to calculate average scores?} 55 | 56 | \item{plot}{logical value giving the option to visualise the estimates in a raincloud plot. defaults to FALSE} 57 | 58 | \item{round.to}{sets the number of decimals to round the estimates to defaults to 2} 59 | 60 | \item{check}{runs several checks of the data to detect participants/conditions/trialtypes with too few trials to run splithalf} 61 | } 62 | \value{ 63 | Returns a data frame containing permutation based split-half reliability estimates 64 | 65 | splithalf is the raw estimate of the bias index 66 | 67 | spearmanbrown is the spearman-brown corrected estimate of the bias index 68 | 69 | Warning: If there are missing data (e.g one condition data missing for one participant) output will include details of the missing data and return a dataframe containing the NA data. Warnings will be displayed in the console. 70 | } 71 | \description{ 72 | This function calculates split half reliability estimates via a permutation approach for a wide range of tasks. Most of the user inputs relate to the variables in the dataset splithalf needs to read in order to estimate reliability. Currently supports response time and accuracy outcomes, for several scoring methods: average, difference, difference of difference scores, and a DPrime development. 73 | The (unofficial) version name is "This function gives me the power to fight like a crow" 74 | } 75 | \examples{ 76 | \dontrun{ 77 | ## see online documentation for full examples 78 | https://github.com/sdparsons/splithalf 79 | ## example simulated data 80 | n_participants = 60 ## sample size 81 | n_trials = 80 82 | n_blocks = 2 83 | sim_data <- data.frame(participant_number = rep(1:n_participants, 84 | each = n_blocks * n_trials), 85 | trial_number = rep(1:n_trials, 86 | times = n_blocks * n_participants), 87 | block_name = rep(c("A","B"), 88 | each = n_trials, 89 | length.out = n_participants * n_trials * n_blocks), 90 | trial_type = rep(c("congruent","incongruent"), 91 | length.out = n_participants * n_trials * n_blocks), 92 | RT = rnorm(n_participants * n_trials * n_blocks, 93 | 500, 94 | 200), 95 | ACC = 1) 96 | 97 | ## example run of splithalf on a difference score 98 | splithalf(data = sim_data, 99 | outcome = "RT", 100 | score = "difference", 101 | conditionlist = c("A", "B"), 102 | halftype = "random", 103 | permutations = 5000, 104 | var.RT = "RT", 105 | var.condition = "block_name", 106 | var.participant = "participant_number", 107 | var.compare = "trial_type", 108 | compare1 = "congruent", 109 | compare2 = "incongruent", 110 | average = "mean", 111 | plot = TRUE) 112 | 113 | ## example run of splithalf on an average score 114 | splithalf(data = sim_data, 115 | outcome = "RT", 116 | score = "average", 117 | conditionlist = c("A", "B"), 118 | halftype = "random", 119 | permutations = 5000, 120 | var.RT = "RT", 121 | var.condition = "block_name", 122 | var.participant = "participant_number", 123 | average = "mean") 124 | 125 | ## example run of splithalf on a difference of differences score 126 | splithalf(data = sim_data, 127 | outcome = "RT", 128 | score = "difference_of_difference", 129 | conditionlist = c("A", "B"), 130 | halftype = "random", 131 | permutations = 5000, 132 | var.RT = "RT", 133 | var.condition = "block_name", 134 | var.participant = "participant_number", 135 | var.compare = "trial_type", 136 | compare1 = "congruent", 137 | compare2 = "incongruent", 138 | average = "mean") 139 | 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /man/splithalf.multiverse.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/splithalf_multiverse.R 3 | \name{splithalf.multiverse} 4 | \alias{splithalf.multiverse} 5 | \title{Multiverse of data processing decisions on internal consistency reliability estimates.} 6 | \usage{ 7 | splithalf.multiverse(input, specifications) 8 | } 9 | \arguments{ 10 | \item{input}{splithalf object or list of splithalf objects} 11 | 12 | \item{specifications}{list of data processing specifications} 13 | } 14 | \value{ 15 | Returns a multiverse object containing the reliability estimates and dataframes from all data processing specifications provided 16 | } 17 | \description{ 18 | This function enables the user to run a multiverse of data processing options and extract the resulting (internal consistency) reliability estimates generated by splithalf. The user specifies a set of data processing decisions and passes this to the function, along with a splithalf object. The output can then be explored and plotted as desired. 19 | } 20 | \details{ 21 | The (unofficial) function version name is "This function will let you get honey from a hornets nest" 22 | } 23 | \examples{ 24 | \dontrun{ 25 | ## see online documentation for examples 26 | https://github.com/sdparsons/splithalf 27 | ## also see https://psyarxiv.com/y6tcz 28 | 29 | ## example simulated data 30 | n_participants = 60 ## sample size 31 | n_trials = 80 32 | n_blocks = 2 33 | sim_data <- data.frame(participant_number = rep(1:n_participants, 34 | each = n_blocks * n_trials), 35 | trial_number = rep(1:n_trials, 36 | times = n_blocks * n_participants), 37 | block_name = rep(c("A","B"), 38 | each = n_trials, 39 | length.out = n_participants * n_trials * n_blocks), 40 | trial_type = rep(c("congruent","incongruent"), 41 | length.out = n_participants * n_trials * n_blocks), 42 | RT = rnorm(n_participants * n_trials * n_blocks, 43 | 500, 44 | 200), 45 | ACC = 1) 46 | 47 | ## specify several data processing decisions 48 | specifications <- list(RT_min = c(0, 100, 200), 49 | RT_max = c(1000, 2000), 50 | averaging_method = c("mean", "median")) 51 | ## run splithalf, and save the output 52 | difference <- splithalf(data = sim_data, 53 | outcome = "RT", 54 | score = "difference", 55 | conditionlist = c("A"), 56 | halftype = "random", 57 | permutations = 5000, 58 | var.RT = "RT", 59 | var.condition = "block_name", 60 | var.participant = "participant_number", 61 | var.compare = "trial_type", 62 | var.ACC = "ACC", 63 | compare1 = "congruent", 64 | compare2 = "incongruent", 65 | average = "mean") 66 | 67 | ## run splithalf.multiverse to perform the multiverse of data processing 68 | ## and reliability estimation 69 | multiverse <- splithalf.multiverse(input = difference, 70 | specifications = specifications) 71 | 72 | ## can be plot with: 73 | multiverse.plot(multiverse = multiverse, 74 | title = "README multiverse") 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /man/testretest.multiverse.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/testretest_multiverse.R 3 | \name{testretest.multiverse} 4 | \alias{testretest.multiverse} 5 | \title{Multiverse of data processing decisions on test retest reliability estimates.} 6 | \usage{ 7 | testretest.multiverse( 8 | data, 9 | specifications, 10 | test = "ICC2", 11 | outcome = "RT", 12 | score = "difference", 13 | var.participant = "subject", 14 | var.ACC = "correct", 15 | var.RT = "RT", 16 | var.time = "time", 17 | var.compare = "congruency", 18 | compare1 = "Congruent", 19 | compare2 = "Incongruent" 20 | ) 21 | } 22 | \arguments{ 23 | \item{data}{dataset} 24 | 25 | \item{specifications}{list of data processing specifications} 26 | 27 | \item{test}{test retest statistic, "ICC2", "cor", "ICC3"} 28 | 29 | \item{outcome}{from splithalf() specifies the RT outcome - only "RT" available currently} 30 | 31 | \item{score}{currently only "difference" scores are supported} 32 | 33 | \item{var.participant}{= "subject",} 34 | 35 | \item{var.ACC}{= "correct",} 36 | 37 | \item{var.RT}{= "RT"} 38 | 39 | \item{var.time}{codes the time variable (currently only works for 2 timepoints)} 40 | 41 | \item{var.compare}{= "congruency" trial type used to create difference scores} 42 | 43 | \item{compare1}{specifies the first trial type to be compared (e.g. "Congruent" trials)} 44 | 45 | \item{compare2}{specifies the second trial type to be compared (e.g. "Incongruent" trials)} 46 | } 47 | \value{ 48 | Returns a multiverse object containing the reliability estimates and dataframes from all data processing specifications provided 49 | } 50 | \description{ 51 | This function enables the user to run a multiverse of data processing options and extract the resulting test-retest reliability estimates. The user specifies a set of data processing decisions and passes this to the function, along with specifying key variables within several "var." inputs (so that the function knows where to find your participant ids and RTs for example) 52 | } 53 | \details{ 54 | The (unofficial) function version name is "This function will help you pay the troll toll" 55 | } 56 | \examples{ 57 | \dontrun{ 58 | ## see online documentation for examples 59 | https://github.com/sdparsons/splithalf 60 | ## also see https://psyarxiv.com/y6tcz 61 | 62 | n_participants <- 80 ## sample size 63 | n_trials <- 120 64 | n_blocks <- 2 65 | 66 | sim_data_mv <- data.frame(participant_number = rep(1:n_participants, 67 | each = n_blocks * n_trials), 68 | trial_number = rep(1:n_trials, 69 | times = n_blocks * n_participants), 70 | block_name = rep(c(1,2), 71 | each = n_trials, 72 | length.out = n_participants * n_trials * n_blocks), 73 | trial_type = rep(c("congruent","congruent", 74 | "incongruent","incongruent"), 75 | length.out = n_participants * n_trials * n_blocks / 2), 76 | RT = rnorm(n_participants * n_trials * n_blocks, 77 | 500, 78 | 200), 79 | ACC = c(rbinom(n_participants * 80 | n_trials * 81 | n_blocks / 6, 82 | 1, .5), 83 | rbinom(n_participants * 84 | n_trials * 85 | n_blocks / 6, 86 | 1, .7), 87 | rbinom(n_participants * 88 | n_trials * 89 | n_blocks / 6, 90 | 1, .9), 91 | rbinom(n_participants * 92 | n_trials * 93 | n_blocks / 6, 94 | 1, .5), 95 | rbinom(n_participants * 96 | n_trials * 97 | n_blocks / 6, 98 | 1, .7), 99 | rbinom(n_participants * 100 | n_trials * 101 | n_blocks / 6, 102 | 1, .9))) 103 | 104 | specifications <- list( 105 | ACC_cutoff = c(0, 0.5), 106 | RT_min = c(0, 200), 107 | RT_max = c(2000, 3000), 108 | RT_sd_cutoff = c(0, 2), 109 | split_by = c("subject", "trial"), 110 | averaging_method = c("mean") 111 | ) 112 | 113 | icc2 <- testretest.multiverse(data = sim_data_acc, 114 | specifications, 115 | test = "ICC2", 116 | score = "difference", 117 | var.participant = "participant_number", 118 | var.ACC = "ACC", 119 | var.RT = "RT", 120 | var.time = "block_name", 121 | var.compare = "trial_type", 122 | compare1 = "congruent", 123 | compare2 = "incongruent") 124 | 125 | multiverse.plot(icc2) 126 | 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /paper.md: -------------------------------------------------------------------------------- 1 | --- 2 | # Example from https://joss.readthedocs.io/en/latest/submitting.html 3 | title: 'splithalf: robust estimates of split half reliability' 4 | tags: 5 | - reliability 6 | - cognitive tasks 7 | - multiverse 8 | - split half methods 9 | - R 10 | authors: 11 | - name: Sam Parsons 12 | affiliation: 1 # (Multiple affiliations must be quoted) 13 | affiliations: 14 | - name: Department of Experimental Psychology, University of Oxford 15 | index: 1 16 | 17 | citation_author: Parsons 18 | date: 19 April 2021 19 | year: 2021 20 | bibliography: inst/book.bib 21 | --- 22 | 23 | # splithalf: robust estimates of split half reliability 24 | 25 | The `R` package **splithalf** provides tools to estimate the internal consistency reliability of cognitive measures. In particular, the tools were developed for application to tasks that use difference scores as the main outcome measure, for instance the Stroop score or dot-probe attention bias index (average RT in incongruent trials minus average RT in congruent trials). 26 | 27 | The methods in **splithalf** are built around split half reliability estimation. To increase the robustness of these estimates, the package implements a permutation approach that takes a large number of random (without replacement) split halves of the data. For each permutation the correlation between halves is calculated, with the Spearman-Brown correction applied [@spearman_proof_1904]. This process generates a distribution of reliability estimates from which we can extract and plot summary statistics (e.g. average and 95% HDI). 28 | 29 | ### Statement of need 30 | 31 | While many cognitive tasks yield highly robust effects, the same task may not yield reliable individual differences [@hedge_reliability_2018]. As these measures are used in questions of individual differences researchers need to have some psychometric information for the outcome measures. Recently, it was proposed that psychological science should set a standard expectation for the reporting of reliability information for cognitive and behavioural measures [@parsons_kruijt_fox_2019]. **splithalf** was developed to support this proposition by providing a tool to easily extract internal consistency reliability estimates from behavioural measures. 32 | 33 | ## Usage 34 | 35 | The _splithalf_ function estimates reliability for a variety of scoring types, including average scores, difference scores, and difference-of-difference scores. The function is also extendable to other scoring calculations, e.g. signal detection. Reliability can be estimated for response time and accuracy rate outcomes. A plotting option is also provided for users to examine the distribution of reliability estimates. 36 | 37 | Users can perform a reliability multiverse analysis to examine the stability of reliability estimates, given a rage of data processing decisions [@parsons_exploring_2020]. By passing a list of data processing decisions (e.g. maximum and minimum RT cutoffs) and a _splithalf_ object into the _splithalf.multiverse_ function. _testretest.multiverse_ can be used to explore a similar multiverse of data processing decisions on test retest reliability. Multiverse output can be plotted with _plot_multiverse_. 38 | 39 | 40 | **splithalf** requires the **tidyr** [@R-tidyr] and **dplyr** [@R-dplyr] packages for data handling within the functions. The **robustbase** package is used to extract median scores when applicable. The computationally heavy tasks (extracting many random half samples of the data) are written in `c++` via the `R` package **Rcpp** [@R-Rcpp]. Test retest multiverse analyses require the **psych** package [@R-psych]. Figures use the **ggplot** package [@R-ggplot2], raincloud plots use code adapted from Allen et al. [@allen_raincloud_2019], and the **patchwork** package [@R-patchwork] is used for plotting the multiverse analyses. 41 | 42 | 43 | ## Comparison to other software 44 | 45 | **splithalf** is the only package to implement all of these tools, in particular reliability multiverse analyses. Some other `R` packages offer a bootstrapped approach to split-half reliability: **multicon** [@R-multicon], **psych** [@R-psych], and **splithalfr** [@R-splithalfr]. 46 | 47 | 48 | ## Acknowledgements 49 | 50 | This work was supported by a grant from the Economic and Social Research Council (ESRC; Grant reference ES/R004285/1). I would also like to thank Anne-Wil Kruijt, James Bartlett, Andrew Jones, and Jean-Paul Snijder for their input on the package. I also thank all that have asked questions, posed suggestions, and shared bug reports - the **splithalf** package is more stable, and more powerful, because of them. 51 | 52 | ## References 53 | -------------------------------------------------------------------------------- /r-references.bib: -------------------------------------------------------------------------------- 1 | @Manual{R-base, 2 | title = {R: A Language and Environment for Statistical Computing}, 3 | author = {{R Core Team}}, 4 | organization = {R Foundation for Statistical Computing}, 5 | address = {Vienna, Austria}, 6 | year = {2018}, 7 | url = {https://www.R-project.org/}, 8 | } 9 | @Manual{R-Cairo, 10 | title = {Cairo: R Graphics Device using Cairo Graphics Library for Creating 11 | High-Quality Bitmap (PNG, JPEG, TIFF), Vector (PDF, SVG, 12 | PostScript) and Display (X11 and Win32) Output}, 13 | author = {Simon Urbanek and Jeffrey Horner}, 14 | year = {2019}, 15 | note = {R package version 1.5-10}, 16 | url = {https://CRAN.R-project.org/package=Cairo}, 17 | } 18 | @Manual{R-dplyr, 19 | title = {dplyr: A Grammar of Data Manipulation}, 20 | author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller}, 21 | year = {2019}, 22 | note = {R package version 0.8.3}, 23 | url = {https://CRAN.R-project.org/package=dplyr}, 24 | } 25 | @Manual{R-forcats, 26 | title = {forcats: Tools for Working with Categorical Variables (Factors)}, 27 | author = {Hadley Wickham}, 28 | year = {2019}, 29 | note = {R package version 0.4.0}, 30 | url = {https://CRAN.R-project.org/package=forcats}, 31 | } 32 | @Book{R-ggplot2, 33 | author = {Hadley Wickham}, 34 | title = {ggplot2: Elegant Graphics for Data Analysis}, 35 | publisher = {Springer-Verlag New York}, 36 | year = {2016}, 37 | isbn = {978-3-319-24277-4}, 38 | url = {https://ggplot2.tidyverse.org}, 39 | } 40 | @Manual{R-gridExtra, 41 | title = {gridExtra: Miscellaneous Functions for "Grid" Graphics}, 42 | author = {Baptiste Auguie}, 43 | year = {2017}, 44 | note = {R package version 2.3}, 45 | url = {https://CRAN.R-project.org/package=gridExtra}, 46 | } 47 | @Manual{R-papaja, 48 | author = {Frederik Aust and Marius Barth}, 49 | title = {{papaja}: {Create} {APA} manuscripts with {R Markdown}}, 50 | year = {2018}, 51 | note = {R package version 0.1.0.9842}, 52 | url = {https://github.com/crsh/papaja}, 53 | } 54 | @Manual{R-patchwork, 55 | title = {patchwork: The Composer of Plots}, 56 | author = {Thomas Lin Pedersen}, 57 | year = {2019}, 58 | note = {R package version 1.0.0}, 59 | url = {https://CRAN.R-project.org/package=patchwork}, 60 | } 61 | @Manual{R-psych, 62 | title = {psych: Procedures for Psychological, Psychometric, and Personality Research}, 63 | author = {William Revelle}, 64 | organization = { Northwestern University}, 65 | address = { Evanston, Illinois}, 66 | year = {2019}, 67 | note = {R package version 1.9.12}, 68 | url = {https://CRAN.R-project.org/package=psych}, 69 | } 70 | @Manual{R-purrr, 71 | title = {purrr: Functional Programming Tools}, 72 | author = {Lionel Henry and Hadley Wickham}, 73 | year = {2019}, 74 | note = {R package version 0.3.3}, 75 | url = {https://CRAN.R-project.org/package=purrr}, 76 | } 77 | @Manual{R-readr, 78 | title = {readr: Read Rectangular Text Data}, 79 | author = {Hadley Wickham and Jim Hester and Romain Francois}, 80 | year = {2018}, 81 | note = {R package version 1.3.1}, 82 | url = {https://CRAN.R-project.org/package=readr}, 83 | } 84 | @Misc{R-splithalf, 85 | title = {splithalf; robust estimates of split half reliability}, 86 | author = {Sam Parsons}, 87 | url = {https://doi.org/10.6084/m9.figshare.5559175.v5}, 88 | year = {2019}, 89 | } 90 | @Manual{R-stringr, 91 | title = {stringr: Simple, Consistent Wrappers for Common String Operations}, 92 | author = {Hadley Wickham}, 93 | year = {2019}, 94 | note = {R package version 1.4.0}, 95 | url = {https://CRAN.R-project.org/package=stringr}, 96 | } 97 | @Manual{R-tibble, 98 | title = {tibble: Simple Data Frames}, 99 | author = {Kirill Müller and Hadley Wickham}, 100 | year = {2019}, 101 | note = {R package version 2.1.3}, 102 | url = {https://CRAN.R-project.org/package=tibble}, 103 | } 104 | @Manual{R-tidyr, 105 | title = {tidyr: Tidy Messy Data}, 106 | author = {Hadley Wickham and Lionel Henry}, 107 | year = {2019}, 108 | note = {R package version 1.0.0}, 109 | url = {https://CRAN.R-project.org/package=tidyr}, 110 | } 111 | @Article{R-tidyverse, 112 | title = {Welcome to the {tidyverse}}, 113 | author = {Hadley Wickham and Mara Averick and Jennifer Bryan and Winston Chang and Lucy D'Agostino McGowan and Romain François and Garrett Grolemund and Alex Hayes and Lionel Henry and Jim Hester and Max Kuhn and Thomas Lin Pedersen and Evan Miller and Stephan Milton Bache and Kirill Müller and Jeroen Ooms and David Robinson and Dana Paige Seidel and Vitalie Spinu and Kohske Takahashi and Davis Vaughan and Claus Wilke and Kara Woo and Hiroaki Yutani}, 114 | year = {2019}, 115 | journal = {Journal of Open Source Software}, 116 | volume = {4}, 117 | number = {43}, 118 | pages = {1686}, 119 | doi = {10.21105/joss.01686}, 120 | } 121 | -------------------------------------------------------------------------------- /splithalf.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageBuildArgs: --compact-vignettes=qpdf 22 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.dll 4 | -------------------------------------------------------------------------------- /src/RcppExports.cpp: -------------------------------------------------------------------------------- 1 | // Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | #include 5 | 6 | using namespace Rcpp; 7 | 8 | // Speedloop 9 | NumericMatrix Speedloop(NumericMatrix A, int x, NumericVector y); 10 | RcppExport SEXP _splithalf_Speedloop(SEXP ASEXP, SEXP xSEXP, SEXP ySEXP) { 11 | BEGIN_RCPP 12 | Rcpp::RObject rcpp_result_gen; 13 | Rcpp::RNGScope rcpp_rngScope_gen; 14 | Rcpp::traits::input_parameter< NumericMatrix >::type A(ASEXP); 15 | Rcpp::traits::input_parameter< int >::type x(xSEXP); 16 | Rcpp::traits::input_parameter< NumericVector >::type y(ySEXP); 17 | rcpp_result_gen = Rcpp::wrap(Speedloop(A, x, y)); 18 | return rcpp_result_gen; 19 | END_RCPP 20 | } 21 | -------------------------------------------------------------------------------- /src/Speedloop.cpp: -------------------------------------------------------------------------------- 1 | # include 2 | using namespace Rcpp; 3 | 4 | 5 | // [[Rcpp::export]] 6 | NumericMatrix Speedloop(NumericMatrix A, int x, NumericVector y){ 7 | NumericVector tmp = y; 8 | int l = y.size(); 9 | NumericMatrix tmpM = A; 10 | 11 | for(int i = 0; i < x; i++) { 12 | 13 | tmpM(_,i) = Rcpp::sample(tmp, l); 14 | } 15 | return tmpM; 16 | 17 | } 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/splithalf_init.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include // for NULL 4 | #include 5 | 6 | /* FIXME: 7 | Check these declarations against the C/Fortran source code. 8 | */ 9 | 10 | /* .Call calls */ 11 | extern SEXP _splithalf_Speedloop(SEXP, SEXP, SEXP); 12 | 13 | static const R_CallMethodDef CallEntries[] = { 14 | {"_splithalf_Speedloop", (DL_FUNC) &_splithalf_Speedloop, 3}, 15 | {NULL, NULL, 0} 16 | }; 17 | 18 | void R_init_splithalf(DllInfo *dll) 19 | { 20 | R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); 21 | R_useDynamicSymbols(dll, TRUE); 22 | } 23 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /vignettes/sim-validation.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "sim-validation" 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{sim-validation} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | --- 9 | 10 | ```{r, include = FALSE} 11 | knitr::opts_chunk$set( 12 | collapse = TRUE, 13 | comment = "#>" 14 | ) 15 | knitr::opts_chunk$set(echo = TRUE) 16 | knitr::opts_chunk$set(message = FALSE) 17 | knitr::opts_chunk$set(warning = FALSE) 18 | knitr::opts_chunk$set(results = "hide") 19 | knitr::opts_chunk$set(fig.dim = c(6,4)) 20 | 21 | 22 | 23 | ``` 24 | 25 | 26 | ```{r setup} 27 | library("splithalf") 28 | library("tidyr") 29 | 30 | ``` 31 | 32 | # Validaion Sim for splithalf 33 | 34 | This script runs _splithalf_ with many possible combinations of the options. Its main use is to ensure that the _splithalf_ function 35 | 36 | # Splithalf() 37 | 38 | 39 | ```{r generate_data} 40 | # Thanks to Nathaniel Haines for the suggestion and the starting code (https://github.com/sdparsons/splithalf/issues/9). 41 | 42 | set.seed(01042021) 43 | 44 | n_participants <- 60 ## sample size 45 | n_trials <- 80 46 | n_blocks <- 2 47 | 48 | sim_data <- data.frame(participant_number = rep(1:n_participants, 49 | each = n_blocks * n_trials), 50 | trial_number = rep(1:n_trials, 51 | times = n_blocks * n_participants), 52 | block_name = rep(c("A","B"), 53 | each = n_trials, 54 | length.out = n_participants * n_trials * n_blocks), 55 | trial_type = rep(c("congruent","congruent", 56 | "incongruent","incongruent"), 57 | length.out = n_participants * n_trials * n_blocks / 2), 58 | RT = rnorm(n_participants * n_trials * n_blocks, 59 | 500, 60 | 200), 61 | ACC = 1) 62 | 63 | sim_data_acc <- data.frame(participant_number = rep(1:n_participants, 64 | each = n_blocks * n_trials), 65 | trial_number = rep(1:n_trials, 66 | times = n_blocks * n_participants), 67 | block_name = rep(c("A","B"), 68 | each = n_trials, 69 | length.out = n_participants * n_trials * n_blocks), 70 | trial_type = rep(c("congruent","congruent", 71 | "incongruent","incongruent"), 72 | length.out = n_participants * n_trials * n_blocks / 2), 73 | RT = rnorm(n_participants * n_trials * n_blocks, 74 | 500, 75 | 200), 76 | ACC = c(rbinom(n_participants * 77 | n_trials * 78 | n_blocks / 6, 79 | 1, .5), 80 | rbinom(n_participants * 81 | n_trials * 82 | n_blocks / 6, 83 | 1, .7), 84 | rbinom(n_participants * 85 | n_trials * 86 | n_blocks / 6, 87 | 1, .9), 88 | rbinom(n_participants * 89 | n_trials * 90 | n_blocks / 6, 91 | 1, .5), 92 | rbinom(n_participants * 93 | n_trials * 94 | n_blocks / 6, 95 | 1, .7), 96 | rbinom(n_participants * 97 | n_trials * 98 | n_blocks / 6, 99 | 1, .9))) 100 | 101 | 102 | 103 | 104 | ``` 105 | 106 | 107 | ```{r test_setup} 108 | params <- list(score = c("average", 109 | "difference", 110 | "difference_of_difference"), 111 | halftype = c("oddeven", 112 | "halfs", 113 | "random"), 114 | averae = c("mean", 115 | "median") ) 116 | 117 | expand.grid(params) %>% 118 | dplyr::arrange(., score, halftype) 119 | 120 | ``` 121 | 122 | ## Response times 123 | 124 | ```{r rt_test1} 125 | splithalf(data = sim_data, 126 | outcome = "RT", 127 | score = "average", 128 | conditionlist = c("A", "B"), 129 | halftype = "oddeven", 130 | permutations = 500, 131 | var.RT = "RT", 132 | var.condition = "block_name", 133 | var.participant = "participant_number", 134 | var.compare = "trial_type", 135 | compare1 = "congruent", 136 | compare2 = "incongruent", 137 | average = "mean") 138 | ``` 139 | 140 | ```{r rt_test2} 141 | splithalf(data = sim_data, 142 | outcome = "RT", 143 | score = "average", 144 | conditionlist = c("A", "B"), 145 | halftype = "oddeven", 146 | permutations = 500, 147 | var.RT = "RT", 148 | var.condition = "block_name", 149 | var.participant = "participant_number", 150 | var.compare = "trial_type", 151 | compare1 = "congruent", 152 | compare2 = "incongruent", 153 | average = "median") 154 | ``` 155 | 156 | ```{r rt_test3} 157 | splithalf(data = sim_data, 158 | outcome = "RT", 159 | score = "average", 160 | conditionlist = c("A", "B"), 161 | halftype = "halfs", 162 | permutations = 500, 163 | var.RT = "RT", 164 | var.condition = "block_name", 165 | var.participant = "participant_number", 166 | var.compare = "trial_type", 167 | compare1 = "congruent", 168 | compare2 = "incongruent", 169 | average = "mean") 170 | ``` 171 | 172 | ```{r rt_test4} 173 | splithalf(data = sim_data, 174 | outcome = "RT", 175 | score = "average", 176 | conditionlist = c("A", "B"), 177 | halftype = "halfs", 178 | permutations = 500, 179 | var.RT = "RT", 180 | var.condition = "block_name", 181 | var.participant = "participant_number", 182 | var.compare = "trial_type", 183 | compare1 = "congruent", 184 | compare2 = "incongruent", 185 | average = "median") 186 | ``` 187 | 188 | ```{r rt_test5} 189 | splithalf(data = sim_data, 190 | outcome = "RT", 191 | score = "average", 192 | conditionlist = c("A", "B"), 193 | halftype = "random", 194 | permutations = 500, 195 | var.RT = "RT", 196 | var.condition = "block_name", 197 | var.participant = "participant_number", 198 | var.compare = "trial_type", 199 | compare1 = "congruent", 200 | compare2 = "incongruent", 201 | average = "mean", 202 | plot = TRUE) 203 | ``` 204 | 205 | ```{r rt_test6} 206 | splithalf(data = sim_data, 207 | outcome = "RT", 208 | score = "average", 209 | conditionlist = c("A", "B"), 210 | halftype = "random", 211 | permutations = 500, 212 | var.RT = "RT", 213 | var.condition = "block_name", 214 | var.participant = "participant_number", 215 | var.compare = "trial_type", 216 | compare1 = "congruent", 217 | compare2 = "incongruent", 218 | average = "median", 219 | plot = TRUE) 220 | ``` 221 | 222 | ```{r rt_test7} 223 | splithalf(data = sim_data, 224 | outcome = "RT", 225 | score = "difference", 226 | conditionlist = c("A", "B"), 227 | halftype = "oddeven", 228 | permutations = 500, 229 | var.RT = "RT", 230 | var.condition = "block_name", 231 | var.participant = "participant_number", 232 | var.compare = "trial_type", 233 | compare1 = "congruent", 234 | compare2 = "incongruent", 235 | average = "mean") 236 | ``` 237 | 238 | ```{r rt_test8} 239 | splithalf(data = sim_data, 240 | outcome = "RT", 241 | score = "difference", 242 | conditionlist = c("A", "B"), 243 | halftype = "oddeven", 244 | permutations = 500, 245 | var.RT = "RT", 246 | var.condition = "block_name", 247 | var.participant = "participant_number", 248 | var.compare = "trial_type", 249 | compare1 = "congruent", 250 | compare2 = "incongruent", 251 | average = "median") 252 | ``` 253 | 254 | ```{r rt_test9} 255 | splithalf(data = sim_data, 256 | outcome = "RT", 257 | score = "difference", 258 | conditionlist = c("A", "B"), 259 | halftype = "halfs", 260 | permutations = 500, 261 | var.RT = "RT", 262 | var.condition = "block_name", 263 | var.participant = "participant_number", 264 | var.compare = "trial_type", 265 | compare1 = "congruent", 266 | compare2 = "incongruent", 267 | average = "mean") 268 | ``` 269 | 270 | ```{r rt_test10} 271 | splithalf(data = sim_data, 272 | outcome = "RT", 273 | score = "difference", 274 | conditionlist = c("A", "B"), 275 | halftype = "halfs", 276 | permutations = 500, 277 | var.RT = "RT", 278 | var.condition = "block_name", 279 | var.participant = "participant_number", 280 | var.compare = "trial_type", 281 | compare1 = "congruent", 282 | compare2 = "incongruent", 283 | average = "median") 284 | ``` 285 | 286 | ```{r rt_test11} 287 | splithalf(data = sim_data, 288 | outcome = "RT", 289 | score = "difference", 290 | conditionlist = c("A", "B"), 291 | halftype = "random", 292 | permutations = 500, 293 | var.RT = "RT", 294 | var.condition = "block_name", 295 | var.participant = "participant_number", 296 | var.compare = "trial_type", 297 | compare1 = "congruent", 298 | compare2 = "incongruent", 299 | average = "mean", 300 | plot = TRUE) 301 | ``` 302 | 303 | ```{r rt_test12} 304 | splithalf(data = sim_data, 305 | outcome = "RT", 306 | score = "difference", 307 | conditionlist = c("A", "B"), 308 | halftype = "random", 309 | permutations = 500, 310 | var.RT = "RT", 311 | var.condition = "block_name", 312 | var.participant = "participant_number", 313 | var.compare = "trial_type", 314 | compare1 = "congruent", 315 | compare2 = "incongruent", 316 | average = "median", 317 | plot = TRUE) 318 | ``` 319 | 320 | ```{r rt_test13} 321 | splithalf(data = sim_data, 322 | outcome = "RT", 323 | score = "difference_of_difference", 324 | conditionlist = c("A", "B"), 325 | halftype = "oddeven", 326 | permutations = 500, 327 | var.RT = "RT", 328 | var.condition = "block_name", 329 | var.participant = "participant_number", 330 | var.compare = "trial_type", 331 | compare1 = "congruent", 332 | compare2 = "incongruent", 333 | average = "mean") 334 | ``` 335 | 336 | ```{r rt_test14} 337 | splithalf(data = sim_data, 338 | outcome = "RT", 339 | score = "difference_of_difference", 340 | conditionlist = c("A", "B"), 341 | halftype = "oddeven", 342 | permutations = 500, 343 | var.RT = "RT", 344 | var.condition = "block_name", 345 | var.participant = "participant_number", 346 | var.compare = "trial_type", 347 | compare1 = "congruent", 348 | compare2 = "incongruent", 349 | average = "median") 350 | ``` 351 | 352 | ```{r rt_test15} 353 | splithalf(data = sim_data, 354 | outcome = "RT", 355 | score = "difference_of_difference", 356 | conditionlist = c("A", "B"), 357 | halftype = "halfs", 358 | permutations = 500, 359 | var.RT = "RT", 360 | var.condition = "block_name", 361 | var.participant = "participant_number", 362 | var.compare = "trial_type", 363 | compare1 = "congruent", 364 | compare2 = "incongruent", 365 | average = "mean") 366 | ``` 367 | 368 | ```{r rt_test16} 369 | splithalf(data = sim_data, 370 | outcome = "RT", 371 | score = "difference_of_difference", 372 | conditionlist = c("A", "B"), 373 | halftype = "halfs", 374 | permutations = 500, 375 | var.RT = "RT", 376 | var.condition = "block_name", 377 | var.participant = "participant_number", 378 | var.compare = "trial_type", 379 | compare1 = "congruent", 380 | compare2 = "incongruent", 381 | average = "median") 382 | ``` 383 | 384 | ```{r rt_test17} 385 | splithalf(data = sim_data, 386 | outcome = "RT", 387 | score = "difference_of_difference", 388 | conditionlist = c("A", "B"), 389 | halftype = "random", 390 | permutations = 500, 391 | var.RT = "RT", 392 | var.condition = "block_name", 393 | var.participant = "participant_number", 394 | var.compare = "trial_type", 395 | compare1 = "congruent", 396 | compare2 = "incongruent", 397 | average = "mean", 398 | plot = TRUE) 399 | ``` 400 | 401 | ```{r rt_test18} 402 | splithalf(data = sim_data, 403 | outcome = "RT", 404 | score = "difference_of_difference", 405 | conditionlist = c("A", "B"), 406 | halftype = "random", 407 | permutations = 500, 408 | var.RT = "RT", 409 | var.condition = "block_name", 410 | var.participant = "participant_number", 411 | var.compare = "trial_type", 412 | compare1 = "congruent", 413 | compare2 = "incongruent", 414 | average = "median", 415 | plot = TRUE) 416 | ``` 417 | 418 | ## Average accuracy rates 419 | 420 | ```{r acc_test1} 421 | splithalf(data = sim_data_acc, 422 | outcome = "accuracy", 423 | score = "average", 424 | conditionlist = c("A", "B"), 425 | halftype = "oddeven", 426 | permutations = 500, 427 | var.RT = "RT", 428 | var.condition = "block_name", 429 | var.participant = "participant_number", 430 | var.compare = "trial_type", 431 | var.ACC = "ACC", 432 | compare1 = "congruent", 433 | compare2 = "incongruent", 434 | average = "mean") 435 | ``` 436 | 437 | ```{r acc_test2} 438 | splithalf(data = sim_data_acc, 439 | outcome = "accuracy", 440 | score = "average", 441 | conditionlist = c("A", "B"), 442 | halftype = "oddeven", 443 | permutations = 500, 444 | var.RT = "RT", 445 | var.condition = "block_name", 446 | var.participant = "participant_number", 447 | var.compare = "trial_type", 448 | var.ACC = "ACC", 449 | 450 | compare1 = "congruent", 451 | compare2 = "incongruent", 452 | average = "median") 453 | ``` 454 | 455 | ```{r acc_test3} 456 | splithalf(data = sim_data_acc, 457 | outcome = "accuracy", 458 | score = "average", 459 | conditionlist = c("A", "B"), 460 | halftype = "halfs", 461 | permutations = 500, 462 | var.RT = "RT", 463 | var.condition = "block_name", 464 | var.participant = "participant_number", 465 | var.compare = "trial_type", 466 | var.ACC = "ACC", 467 | compare1 = "congruent", 468 | compare2 = "incongruent", 469 | average = "mean") 470 | ``` 471 | 472 | ```{r acc_test4} 473 | splithalf(data = sim_data_acc, 474 | outcome = "accuracy", 475 | score = "average", 476 | conditionlist = c("A", "B"), 477 | halftype = "halfs", 478 | permutations = 500, 479 | var.RT = "RT", 480 | var.condition = "block_name", 481 | var.participant = "participant_number", 482 | var.compare = "trial_type", 483 | var.ACC = "ACC", 484 | compare1 = "congruent", 485 | compare2 = "incongruent", 486 | average = "median") 487 | ``` 488 | 489 | ```{r acc_test5} 490 | splithalf(data = sim_data_acc, 491 | outcome = "accuracy", 492 | score = "average", 493 | conditionlist = c("A", "B"), 494 | halftype = "random", 495 | permutations = 500, 496 | var.RT = "RT", 497 | var.condition = "block_name", 498 | var.participant = "participant_number", 499 | var.compare = "trial_type", 500 | var.ACC = "ACC", 501 | compare1 = "congruent", 502 | compare2 = "incongruent", 503 | average = "mean", 504 | plot = TRUE) 505 | ``` 506 | 507 | ```{r acc_test6} 508 | splithalf(data = sim_data_acc, 509 | outcome = "accuracy", 510 | score = "average", 511 | conditionlist = c("A", "B"), 512 | halftype = "random", 513 | permutations = 500, 514 | var.RT = "RT", 515 | var.condition = "block_name", 516 | var.participant = "participant_number", 517 | var.compare = "trial_type", 518 | var.ACC = "ACC", 519 | compare1 = "congruent", 520 | compare2 = "incongruent", 521 | average = "median", 522 | plot = TRUE) 523 | ``` 524 | 525 | ```{r acc_test7} 526 | splithalf(data = sim_data_acc, 527 | outcome = "accuracy", 528 | score = "difference", 529 | conditionlist = c("A", "B"), 530 | halftype = "oddeven", 531 | permutations = 500, 532 | var.RT = "RT", 533 | var.condition = "block_name", 534 | var.participant = "participant_number", 535 | var.compare = "trial_type", 536 | var.ACC = "ACC", 537 | compare1 = "congruent", 538 | compare2 = "incongruent", 539 | average = "mean") 540 | ``` 541 | 542 | ```{r acc_test8} 543 | splithalf(data = sim_data_acc, 544 | outcome = "accuracy", 545 | score = "difference", 546 | conditionlist = c("A", "B"), 547 | halftype = "oddeven", 548 | permutations = 500, 549 | var.RT = "RT", 550 | var.condition = "block_name", 551 | var.participant = "participant_number", 552 | var.compare = "trial_type", 553 | var.ACC = "ACC", 554 | compare1 = "congruent", 555 | compare2 = "incongruent", 556 | average = "median") 557 | ``` 558 | 559 | ```{r acc_test9} 560 | splithalf(data = sim_data_acc, 561 | outcome = "accuracy", 562 | score = "difference", 563 | conditionlist = c("A", "B"), 564 | halftype = "halfs", 565 | permutations = 500, 566 | var.RT = "RT", 567 | var.condition = "block_name", 568 | var.participant = "participant_number", 569 | var.compare = "trial_type", 570 | var.ACC = "ACC", 571 | compare1 = "congruent", 572 | compare2 = "incongruent", 573 | average = "mean") 574 | ``` 575 | 576 | ```{r acc_test10} 577 | splithalf(data = sim_data_acc, 578 | outcome = "accuracy", 579 | score = "difference", 580 | conditionlist = c("A", "B"), 581 | halftype = "halfs", 582 | permutations = 500, 583 | var.RT = "RT", 584 | var.condition = "block_name", 585 | var.participant = "participant_number", 586 | var.compare = "trial_type", 587 | var.ACC = "ACC", 588 | compare1 = "congruent", 589 | compare2 = "incongruent", 590 | average = "median") 591 | ``` 592 | 593 | ```{r acc_test11} 594 | splithalf(data = sim_data_acc, 595 | outcome = "accuracy", 596 | score = "difference", 597 | conditionlist = c("A", "B"), 598 | halftype = "random", 599 | permutations = 500, 600 | var.RT = "RT", 601 | var.condition = "block_name", 602 | var.participant = "participant_number", 603 | var.compare = "trial_type", 604 | var.ACC = "ACC", 605 | compare1 = "congruent", 606 | compare2 = "incongruent", 607 | average = "mean", 608 | plot = TRUE) 609 | ``` 610 | 611 | ```{r acc_test12} 612 | splithalf(data = sim_data_acc, 613 | outcome = "accuracy", 614 | score = "difference", 615 | conditionlist = c("A", "B"), 616 | halftype = "random", 617 | permutations = 500, 618 | var.RT = "RT", 619 | var.condition = "block_name", 620 | var.participant = "participant_number", 621 | var.compare = "trial_type", 622 | var.ACC = "ACC", 623 | compare1 = "congruent", 624 | compare2 = "incongruent", 625 | average = "median", 626 | plot = TRUE) 627 | ``` 628 | 629 | ```{r acc_test13} 630 | splithalf(data = sim_data_acc, 631 | outcome = "accuracy", 632 | score = "difference_of_difference", 633 | conditionlist = c("A", "B"), 634 | halftype = "oddeven", 635 | permutations = 500, 636 | var.RT = "RT", 637 | var.condition = "block_name", 638 | var.participant = "participant_number", 639 | var.compare = "trial_type", 640 | var.ACC = "ACC", 641 | compare1 = "congruent", 642 | compare2 = "incongruent", 643 | average = "mean") 644 | ``` 645 | 646 | ```{r acc_test14} 647 | splithalf(data = sim_data_acc, 648 | outcome = "accuracy", 649 | score = "difference_of_difference", 650 | conditionlist = c("A", "B"), 651 | halftype = "oddeven", 652 | permutations = 500, 653 | var.RT = "RT", 654 | var.condition = "block_name", 655 | var.participant = "participant_number", 656 | var.compare = "trial_type", 657 | var.ACC = "ACC", 658 | compare1 = "congruent", 659 | compare2 = "incongruent", 660 | average = "median") 661 | ``` 662 | 663 | ```{r acc_test15} 664 | splithalf(data = sim_data_acc, 665 | outcome = "accuracy", 666 | score = "difference_of_difference", 667 | conditionlist = c("A", "B"), 668 | halftype = "halfs", 669 | permutations = 500, 670 | var.RT = "RT", 671 | var.condition = "block_name", 672 | var.participant = "participant_number", 673 | var.compare = "trial_type", 674 | var.ACC = "ACC", 675 | compare1 = "congruent", 676 | compare2 = "incongruent", 677 | average = "mean") 678 | ``` 679 | 680 | ```{r acc_test16} 681 | splithalf(data = sim_data_acc, 682 | outcome = "accuracy", 683 | score = "difference_of_difference", 684 | conditionlist = c("A", "B"), 685 | halftype = "halfs", 686 | permutations = 500, 687 | var.RT = "RT", 688 | var.condition = "block_name", 689 | var.participant = "participant_number", 690 | var.compare = "trial_type", 691 | var.ACC = "ACC", 692 | compare1 = "congruent", 693 | compare2 = "incongruent", 694 | average = "median") 695 | ``` 696 | 697 | ```{r acc_test17} 698 | splithalf(data = sim_data_acc, 699 | outcome = "accuracy", 700 | score = "difference_of_difference", 701 | conditionlist = c("A", "B"), 702 | halftype = "random", 703 | permutations = 500, 704 | var.RT = "RT", 705 | var.condition = "block_name", 706 | var.participant = "participant_number", 707 | var.compare = "trial_type", 708 | var.ACC = "ACC", 709 | compare1 = "congruent", 710 | compare2 = "incongruent", 711 | average = "mean", 712 | plot = TRUE) 713 | ``` 714 | 715 | ```{r acc_test18} 716 | splithalf(data = sim_data_acc, 717 | outcome = "accuracy", 718 | score = "difference_of_difference", 719 | conditionlist = c("A", "B"), 720 | halftype = "random", 721 | permutations = 500, 722 | var.RT = "RT", 723 | var.condition = "block_name", 724 | var.participant = "participant_number", 725 | var.compare = "trial_type", 726 | var.ACC = "ACC", 727 | compare1 = "congruent", 728 | compare2 = "incongruent", 729 | average = "median", 730 | plot = TRUE) 731 | ``` 732 | 733 | # multiverse 734 | 735 | Runs several multiverse 736 | 737 | ```{r generate_mv_data} 738 | set.seed(01042021) 739 | 740 | n_participants <- 80 ## sample size 741 | n_trials <- 120 742 | n_blocks <- 2 743 | 744 | 745 | sim_data_mv <- data.frame(participant_number = rep(1:n_participants, 746 | each = n_blocks * n_trials), 747 | trial_number = rep(1:n_trials, 748 | times = n_blocks * n_participants), 749 | block_name = rep(c(1,2), 750 | each = n_trials, 751 | length.out = n_participants * n_trials * n_blocks), 752 | trial_type = rep(c("congruent","congruent", 753 | "incongruent","incongruent"), 754 | length.out = n_participants * n_trials * n_blocks / 2), 755 | RT = rnorm(n_participants * n_trials * n_blocks, 756 | 500, 757 | 200), 758 | ACC = c(rbinom(n_participants * 759 | n_trials * 760 | n_blocks / 6, 761 | 1, .5), 762 | rbinom(n_participants * 763 | n_trials * 764 | n_blocks / 6, 765 | 1, .7), 766 | rbinom(n_participants * 767 | n_trials * 768 | n_blocks / 6, 769 | 1, .9), 770 | rbinom(n_participants * 771 | n_trials * 772 | n_blocks / 6, 773 | 1, .5), 774 | rbinom(n_participants * 775 | n_trials * 776 | n_blocks / 6, 777 | 1, .7), 778 | rbinom(n_participants * 779 | n_trials * 780 | n_blocks / 6, 781 | 1, .9))) 782 | 783 | 784 | ``` 785 | 786 | 787 | ```{r create_specs} 788 | specifications <- list( 789 | ACC_cutoff = c(0, 0.5), 790 | RT_min = c(0, 200), 791 | RT_max = c(2000, 3000), 792 | RT_sd_cutoff = c(0, 2), 793 | split_by = c("subject", "trial"), 794 | averaging_method = c("mean") 795 | ) 796 | 797 | ``` 798 | 799 | ## internal consistency 800 | 801 | ```{r splithalf_for_mv, comment=FALSE, results='hide'} 802 | mv_splithalf <- splithalf(data = sim_data, 803 | outcome = "RT", 804 | score = "difference", 805 | conditionlist = c("A"), 806 | halftype = "random", 807 | permutations = 50, 808 | var.RT = "RT", 809 | var.condition = "block_name", 810 | var.participant = "participant_number", 811 | var.compare = "trial_type", 812 | var.ACC = "ACC", 813 | compare1 = "congruent", 814 | compare2 = "incongruent", 815 | average = "mean") 816 | 817 | multiverse <- splithalf.multiverse(input = mv_splithalf, 818 | specifications = specifications) 819 | 820 | ``` 821 | 822 | ```{r splithalf_for_mv_fig} 823 | 824 | multiverse.plot(multiverse = multiverse, 825 | title = "sim_multiverse") 826 | ``` 827 | 828 | ```{r} 829 | 830 | ``` 831 | 832 | 833 | ## test-retest 834 | 835 | 836 | ```{r retest_mv1, comment=FALSE, results='hide'} 837 | icc2 <- testretest.multiverse(data = sim_data_acc, 838 | specifications, 839 | test = "ICC2", 840 | 841 | score = "difference", 842 | 843 | var.participant = "participant_number", 844 | var.ACC = "ACC", 845 | var.RT = "RT", 846 | var.time = "block_name", 847 | var.compare = "trial_type", 848 | compare1 = "congruent", 849 | compare2 = "incongruent") 850 | 851 | multiverse.plot(icc2) 852 | 853 | 854 | ``` 855 | 856 | ```{r retest_mv2, comment=FALSE, results='hide'} 857 | 858 | icc3 <- testretest.multiverse(data = sim_data_acc, 859 | specifications, 860 | test = "ICC3", 861 | 862 | score = "difference", 863 | 864 | var.participant = "participant_number", 865 | var.ACC = "ACC", 866 | var.RT = "RT", 867 | var.time = "block_name", 868 | var.compare = "trial_type", 869 | compare1 = "congruent", 870 | compare2 = "incongruent") 871 | 872 | multiverse.plot(icc3) 873 | 874 | ``` 875 | 876 | ```{r retest_mv3, comment=FALSE, results='hide'} 877 | 878 | retest_cor <- testretest.multiverse(data = sim_data_acc, 879 | specifications, 880 | test = "cor", 881 | 882 | score = "difference", 883 | 884 | var.participant = "participant_number", 885 | var.ACC = "ACC", 886 | var.RT = "RT", 887 | var.time = "block_name", 888 | var.compare = "trial_type", 889 | compare1 = "congruent", 890 | compare2 = "incongruent") 891 | 892 | multiverse.plot(retest_cor) 893 | 894 | 895 | ``` 896 | --------------------------------------------------------------------------------