General Statistics: Difference between revisions
copied from markdown converted mediawiki |
Updated to match github version |
||
| Line 1: | Line 1: | ||
[[ Category: General ]] | |||
[[ Category: Data ]] | |||
[[ Category: Statistics ]] | |||
= General Statistical Methods = | = General Statistical Methods = | ||
There are several important concepts that we will adhere to in our group. These involve design considerations, execution considerations and analysis concerns. | There are several important concepts that we will adhere to in our group. These involve design considerations, execution considerations and analysis concerns. The standard for our field is null hypothesis significance testing, which means that we are generally comparing our data to a null hypothesis, generating an '''effect size''' and a '''p-value'''. As a general rule, we report both of these both within our Rmd scripts, and in our publications. | ||
We generally use an <math>\alpha</math> of <math>p<0.05</math> to determine significance, which means that (if true) we are rejecting the null hypothesis. | |||
== Experimental Design == | == Experimental Design == | ||
| Line 11: | Line 17: | ||
* The desired power (normally 0.8). This indicates that 80% of the time you will detect the effect if there is one. This is also known as 1 minus the false negative rate or 1 minus the Type II error rate. | * The desired power (normally 0.8). This indicates that 80% of the time you will detect the effect if there is one. This is also known as 1 minus the false negative rate or 1 minus the Type II error rate. | ||
We use the R package '''pwr''' to do a power analysis (Champely, | We use the R package '''pwr''' to do a power analysis (Champely, 2020). Here is an example: | ||
=== Pairwise Comparasons === | === Pairwise Comparasons === | ||
| Line 158: | Line 164: | ||
leveneTest(Result ~ Treatment, data=test.data) %>% tidy %>% kable</pre> | leveneTest(Result ~ Treatment, data=test.data) %>% tidy %>% kable</pre> | ||
{| | {| | ||
!align="right"| statistic | !align="right"| statistic | ||
!align="right"| p.value | !align="right"| p.value | ||
!align="right"| df | |||
!align="right"| df.residual | |||
|- | |- | ||
|align="right"| 0.368 | |align="right"| 0.368 | ||
|align="right"| 0.558 | |align="right"| 0.558 | ||
| | |align="right"| 1 | ||
| | |||
|align="right"| 10 | |align="right"| 10 | ||
|} | |} | ||
| Line 188: | Line 188: | ||
t.test(Result~Treatment,data=test.data, var.equal=T) %>% tidy %>% kable</pre> | t.test(Result~Treatment,data=test.data, var.equal=T) %>% tidy %>% kable</pre> | ||
{| | {| | ||
!align="right"| estimate1 | !align="right" width="8%"| estimate | ||
!align="right"| estimate2 | !align="right" width="9%"| estimate1 | ||
!align="right"| statistic | !align="right" width="9%"| estimate2 | ||
!align="right"| p.value | !align="right" width="9%"| statistic | ||
!align="right"| parameter | !align="right" width="7%"| p.value | ||
!align="right"| conf.low | !align="right" width="9%"| parameter | ||
!align="right"| conf.high | !align="right" width="8%"| conf.low | ||
! method | !align="right" width="9%"| conf.high | ||
! alternative | !width="16%"| method | ||
!width="11%"| alternative | |||
|- | |- | ||
|align="right"| -1.1 | |||
|align="right"| 8.79 | |align="right"| 8.79 | ||
|align="right"| 9.89 | |align="right"| 9.89 | ||
| Line 214: | Line 216: | ||
t.test(Result~Treatment,data=test.data, var.equal=F) %>% tidy %>% kable</pre> | t.test(Result~Treatment,data=test.data, var.equal=F) %>% tidy %>% kable</pre> | ||
{| | {| | ||
!align="right"| estimate | !align="right" width="8%"| estimate | ||
!align="right"| estimate1 | !align="right" width="9%"| estimate1 | ||
!align="right"| estimate2 | !align="right" width="9%"| estimate2 | ||
!align="right"| statistic | !align="right" width="9%"| statistic | ||
!align="right"| p.value | !align="right" width="7%"| p.value | ||
!align="right"| parameter | !align="right" width="9%"| parameter | ||
!align="right"| conf.low | !align="right" width="8%"| conf.low | ||
!align="right"| conf.high | !align="right" width="9%"| conf.high | ||
! method | !width="20%"| method | ||
! alternative | !width="10%"| alternative | ||
|- | |- | ||
|align="right"| -1.1 | |align="right"| -1.1 | ||
| Line 249: | Line 251: | ||
|align="right"| 12 | |align="right"| 12 | ||
|align="right"| 0.394 | |align="right"| 0.394 | ||
| Wilcoxon rank sum test | | Wilcoxon rank sum exact test | ||
| two.sided | | two.sided | ||
|} | |} | ||
| Line 272: | Line 274: | ||
<pre class="r">sessionInfo()</pre> | <pre class="r">sessionInfo()</pre> | ||
<pre>## R version | <pre>## R version 4.4.1 (2024-06-14) | ||
## Platform: x86_64-apple- | ## Platform: x86_64-apple-darwin20 | ||
## Running under: macOS | ## Running under: macOS Monterey 12.7.6 | ||
## | ## | ||
## Matrix products: default | ## Matrix products: default | ||
## BLAS: /Library/Frameworks/R.framework/Versions/ | ## BLAS: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRblas.0.dylib | ||
## LAPACK: /Library/Frameworks/R.framework/Versions/ | ## LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0 | ||
## | ## | ||
## locale: | ## locale: | ||
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 | ## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 | ||
## | |||
## time zone: America/Detroit | |||
## tzcode source: internal | |||
## | ## | ||
## attached base packages: | ## attached base packages: | ||
| Line 287: | Line 292: | ||
## | ## | ||
## other attached packages: | ## other attached packages: | ||
## [1] | ## [1] car_3.1-2 carData_3.0-5 broom_1.0.6 | ||
## [4] pwr_1. | ## [4] pwr_1.3-0 knitcitations_1.0.12 dplyr_1.1.4 | ||
## [7] | ## [7] tidyr_1.3.1 knitr_1.48 | ||
## | ## | ||
## loaded via a namespace (and not attached): | ## loaded via a namespace (and not attached): | ||
## [1] | ## [1] jsonlite_1.8.8 compiler_4.4.1 tidyselect_1.2.1 Rcpp_1.0.13 | ||
## [5] xml2_1.3.6 stringr_1.5.1 jquerylib_0.1.4 yaml_2.3.10 | |||
## [ | ## [9] fastmap_1.2.0 R6_2.5.1 plyr_1.8.9 generics_0.1.3 | ||
## [ | ## [13] backports_1.5.0 tibble_3.2.1 RefManageR_1.4.0 lubridate_1.9.3 | ||
## [17] bslib_0.8.0 pillar_1.9.0 rlang_1.1.4 utf8_1.2.4 | |||
## [ | ## [21] stringi_1.8.4 cachem_1.1.0 xfun_0.46 sass_0.4.9 | ||
## [ | ## [25] bibtex_0.5.1 timechange_0.3.0 cli_3.6.3 withr_3.0.0 | ||
## [29] magrittr_2.0.3 digest_0.6.36 lifecycle_1.0.4 vctrs_0.6.5 | |||
## [ | ## [33] evaluate_0.24.0 glue_1.7.0 abind_1.4-5 fansi_1.0.6 | ||
## [ | ## [37] rmarkdown_2.27 purrr_1.0.2 httr_1.4.7 tools_4.4.1 | ||
## [41] pkgconfig_2.0.3 htmltools_0.5.8.1</pre> | |||
## [ | |||
## [ | |||
## [ | |||
## [ | |||
= References = | = References = | ||
<a name=bib-pwr></a>[[#cite-pwr|[1]]] S. Champely. ''pwr: Basic Functions for Power Analysis''. R package version 1. | <a name=bib-pwr></a>[[#cite-pwr|[1]]] S. Champely. ''pwr: Basic Functions for Power Analysis''. R package version 1.3-0. 2020. URL: https://CRAN.R-project.org/package=pwr. | ||