{ "cells": [ { "metadata": { "toc": true }, "cell_type": "markdown", "source": "

Table of Contents

\n
" }, { "metadata": {}, "cell_type": "markdown", "source": "## Introduction (Various Statistical Tests)" }, { "metadata": {}, "cell_type": "markdown", "source": "**Choosing test?** \n* what level of measurement of our **data** \n* How many **samples** \n* what is the **purpose** of our analysis) " }, { "metadata": { "run_control": { "frozen": false, "read_only": false } }, "cell_type": "markdown", "source": "## One Sample\n### Mean (Z- and t-tests, Type I and II Error, Power & Sample Size)" }, { "metadata": {}, "cell_type": "markdown", "source": "* z test is used when there is any statistical significance difference between a sample mean and a population mean with a known population standard deviation\n* It uses z-scores and a normal distribution to determine the probability the sample mean is drawn randomly from a known population." }, { "metadata": {}, "cell_type": "markdown", "source": "http://stats.seandolinar.com/one-mean-z-test-with-r-code/ \nhttp://stats.seandolinar.com/one-sample-t-test-with-r-code/ \nhttp://www.artofstat.com/webapps.html#Distributions " }, { "metadata": { "run_control": { "frozen": false, "read_only": false } }, "cell_type": "markdown", "source": "### Proportion (Z-test)\n### Variance (Chi-squared Test)" }, { "metadata": { "run_control": { "frozen": false, "read_only": false } }, "cell_type": "markdown", "source": "## Two Samples" }, { "metadata": { "run_control": { "frozen": false, "read_only": false } }, "cell_type": "markdown", "source": "### Means (Independent vs. Paired Samples, Nonparametric tests)\n### Proportions (Z-test, Chi-squared Test, McNemar Test)\n* Applications: Case-Control Studies, Test of Association and Test of Homogeneity of Odds Ratios, Mantel-Haenszel Estimate of Summary Odds Ratio\n### Variances (F-test, Levene Test)" }, { "metadata": { "run_control": { "frozen": false, "read_only": false } }, "cell_type": "markdown", "source": "## Several Samples" }, { "metadata": { "run_control": { "frozen": false, "read_only": false } }, "cell_type": "markdown", "source": "### Means (ANOVA, F-test, Multiple Comparisons)" }, { "metadata": { "trusted": false }, "cell_type": "code", "source": "# Analysis of Variance Example (ANOVA)\n# MyBookSucks.Com \"PartyMoreStudyLess\n\nGroup1 <- c(2,3,7,2,6)\nGroup2 <- c(10,8,7,5,10)\nGroup3 <- c(10,13,14,13,15)\n\nCombined_Groups <- data.frame(cbind(Group1, Group2, Group3)) # combines the data into a single data set.\nCombined_Groups # shows spreadsheet like results\nsummary(Combined_Groups) # min, median, mean, max\n\nStacked_Groups <- stack(Combined_Groups)\nStacked_Groups #shows the table Stacked_Groups\n\nAnova_Results <- aov(values ~ ind, data = Stacked_Groups) \nsummary(Anova_Results) # shows Anova_Results", "execution_count": 1, "outputs": [ { "data": { "text/html": "\n\n\n\t\n\t\n\t\n\t\n\t\n\n
Group1Group2Group3
2 1010
3 813
7 714
2 513
6 1015
\n", "text/latex": "\\begin{tabular}{r|lll}\n Group1 & Group2 & Group3\\\\\n\\hline\n\t 2 & 10 & 10\\\\\n\t 3 & 8 & 13\\\\\n\t 7 & 7 & 14\\\\\n\t 2 & 5 & 13\\\\\n\t 6 & 10 & 15\\\\\n\\end{tabular}\n", "text/markdown": "\nGroup1 | Group2 | Group3 | \n|---|---|---|---|---|\n| 2 | 10 | 10 | \n| 3 | 8 | 13 | \n| 7 | 7 | 14 | \n| 2 | 5 | 13 | \n| 6 | 10 | 15 | \n\n\n", "text/plain": " Group1 Group2 Group3\n1 2 10 10 \n2 3 8 13 \n3 7 7 14 \n4 2 5 13 \n5 6 10 15 " }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": " Group1 Group2 Group3 \n Min. :2 Min. : 5 Min. :10 \n 1st Qu.:2 1st Qu.: 7 1st Qu.:13 \n Median :3 Median : 8 Median :13 \n Mean :4 Mean : 8 Mean :13 \n 3rd Qu.:6 3rd Qu.:10 3rd Qu.:14 \n Max. :7 Max. :10 Max. :15 " }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": "\n\n\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\n
valuesind
2 Group1
3 Group1
7 Group1
2 Group1
6 Group1
10 Group2
8 Group2
7 Group2
5 Group2
10 Group2
10 Group3
13 Group3
14 Group3
13 Group3
15 Group3
\n", "text/latex": "\\begin{tabular}{r|ll}\n values & ind\\\\\n\\hline\n\t 2 & Group1\\\\\n\t 3 & Group1\\\\\n\t 7 & Group1\\\\\n\t 2 & Group1\\\\\n\t 6 & Group1\\\\\n\t 10 & Group2\\\\\n\t 8 & Group2\\\\\n\t 7 & Group2\\\\\n\t 5 & Group2\\\\\n\t 10 & Group2\\\\\n\t 10 & Group3\\\\\n\t 13 & Group3\\\\\n\t 14 & Group3\\\\\n\t 13 & Group3\\\\\n\t 15 & Group3\\\\\n\\end{tabular}\n", "text/markdown": "\nvalues | ind | \n|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n| 2 | Group1 | \n| 3 | Group1 | \n| 7 | Group1 | \n| 2 | Group1 | \n| 6 | Group1 | \n| 10 | Group2 | \n| 8 | Group2 | \n| 7 | Group2 | \n| 5 | Group2 | \n| 10 | Group2 | \n| 10 | Group3 | \n| 13 | Group3 | \n| 14 | Group3 | \n| 13 | Group3 | \n| 15 | Group3 | \n\n\n", "text/plain": " values ind \n1 2 Group1\n2 3 Group1\n3 7 Group1\n4 2 Group1\n5 6 Group1\n6 10 Group2\n7 8 Group2\n8 7 Group2\n9 5 Group2\n10 10 Group2\n11 10 Group3\n12 13 Group3\n13 14 Group3\n14 13 Group3\n15 15 Group3" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": " Df Sum Sq Mean Sq F value Pr(>F) \nind 2 203.3 101.7 22.59 8.54e-05 ***\nResiduals 12 54.0 4.5 \n---\nSignif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1" }, "metadata": {}, "output_type": "display_data" } ] }, { "metadata": { "run_control": { "frozen": false, "read_only": false } }, "cell_type": "markdown", "source": "https://help.plot.ly/anova-test/ \nhttps://www.youtube.com/watch?v=-yQb_ZJnFXw&t=323s&list=PL3A0F3CC5D48431B3&index=2 \nhttps://www.youtube.com/watch?v=FPqeVhtOXEo" }, { "metadata": { "run_control": { "frozen": false, "read_only": false } }, "cell_type": "markdown", "source": "### Proportions (Chi-squared Test)" }, { "metadata": {}, "cell_type": "markdown", "source": "https://help.plot.ly/chi-square/ " }, { "metadata": { "run_control": { "frozen": false, "read_only": false } }, "cell_type": "markdown", "source": "### Variances (Bartlett’s Test, etc.)" }, { "metadata": { "trusted": false }, "cell_type": "code", "source": "# bartlett.test(values~groups, dataset)\n# bartlett.test(list(dataset$sample1, dataset$sample2, dataset$sample3))\nPlantGrowth\nbartlett.test(weight~group, PlantGrowth)", "execution_count": 3, "outputs": [ { "data": { "text/html": "\n\n\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\n
weightgroup
4.17ctrl
5.58ctrl
5.18ctrl
6.11ctrl
4.50ctrl
4.61ctrl
5.17ctrl
4.53ctrl
5.33ctrl
5.14ctrl
4.81trt1
4.17trt1
4.41trt1
3.59trt1
5.87trt1
3.83trt1
6.03trt1
4.89trt1
4.32trt1
4.69trt1
6.31trt2
5.12trt2
5.54trt2
5.50trt2
5.37trt2
5.29trt2
4.92trt2
6.15trt2
5.80trt2
5.26trt2
\n", "text/latex": "\\begin{tabular}{r|ll}\n weight & group\\\\\n\\hline\n\t 4.17 & ctrl\\\\\n\t 5.58 & ctrl\\\\\n\t 5.18 & ctrl\\\\\n\t 6.11 & ctrl\\\\\n\t 4.50 & ctrl\\\\\n\t 4.61 & ctrl\\\\\n\t 5.17 & ctrl\\\\\n\t 4.53 & ctrl\\\\\n\t 5.33 & ctrl\\\\\n\t 5.14 & ctrl\\\\\n\t 4.81 & trt1\\\\\n\t 4.17 & trt1\\\\\n\t 4.41 & trt1\\\\\n\t 3.59 & trt1\\\\\n\t 5.87 & trt1\\\\\n\t 3.83 & trt1\\\\\n\t 6.03 & trt1\\\\\n\t 4.89 & trt1\\\\\n\t 4.32 & trt1\\\\\n\t 4.69 & trt1\\\\\n\t 6.31 & trt2\\\\\n\t 5.12 & trt2\\\\\n\t 5.54 & trt2\\\\\n\t 5.50 & trt2\\\\\n\t 5.37 & trt2\\\\\n\t 5.29 & trt2\\\\\n\t 4.92 & trt2\\\\\n\t 6.15 & trt2\\\\\n\t 5.80 & trt2\\\\\n\t 5.26 & trt2\\\\\n\\end{tabular}\n", "text/markdown": "\nweight | group | \n|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n| 4.17 | ctrl | \n| 5.58 | ctrl | \n| 5.18 | ctrl | \n| 6.11 | ctrl | \n| 4.50 | ctrl | \n| 4.61 | ctrl | \n| 5.17 | ctrl | \n| 4.53 | ctrl | \n| 5.33 | ctrl | \n| 5.14 | ctrl | \n| 4.81 | trt1 | \n| 4.17 | trt1 | \n| 4.41 | trt1 | \n| 3.59 | trt1 | \n| 5.87 | trt1 | \n| 3.83 | trt1 | \n| 6.03 | trt1 | \n| 4.89 | trt1 | \n| 4.32 | trt1 | \n| 4.69 | trt1 | \n| 6.31 | trt2 | \n| 5.12 | trt2 | \n| 5.54 | trt2 | \n| 5.50 | trt2 | \n| 5.37 | trt2 | \n| 5.29 | trt2 | \n| 4.92 | trt2 | \n| 6.15 | trt2 | \n| 5.80 | trt2 | \n| 5.26 | trt2 | \n\n\n", "text/plain": " weight group\n1 4.17 ctrl \n2 5.58 ctrl \n3 5.18 ctrl \n4 6.11 ctrl \n5 4.50 ctrl \n6 4.61 ctrl \n7 5.17 ctrl \n8 4.53 ctrl \n9 5.33 ctrl \n10 5.14 ctrl \n11 4.81 trt1 \n12 4.17 trt1 \n13 4.41 trt1 \n14 3.59 trt1 \n15 5.87 trt1 \n16 3.83 trt1 \n17 6.03 trt1 \n18 4.89 trt1 \n19 4.32 trt1 \n20 4.69 trt1 \n21 6.31 trt2 \n22 5.12 trt2 \n23 5.54 trt2 \n24 5.50 trt2 \n25 5.37 trt2 \n26 5.29 trt2 \n27 4.92 trt2 \n28 6.15 trt2 \n29 5.80 trt2 \n30 5.26 trt2 " }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": "\n\tBartlett test of homogeneity of variances\n\ndata: weight by group\nBartlett's K-squared = 2.8786, df = 2, p-value = 0.2371\n" }, "metadata": {}, "output_type": "display_data" } ] }, { "metadata": {}, "cell_type": "markdown", "source": "http://www.statisticshowto.com/bartletts-test/ \nhttp://www.instantr.com/2012/12/12/performing-bartletts-test-in-r/ " }, { "metadata": {}, "cell_type": "markdown", "source": "# Which Statistics Test Should I Use? \nhttp://www.socscistatistics.com/tests/what_stats_test_wizard.aspx \n" }, { "metadata": {}, "cell_type": "markdown", "source": "![Imgur](https://i.imgur.com/CO0s61b.png)" }, { "metadata": { "trusted": true }, "cell_type": "code", "source": "", "execution_count": null, "outputs": [] } ], "metadata": { "hide_input": false, "kernelspec": { "name": "r", "display_name": "R", "language": "R" }, "language_info": { "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", "version": "3.4.1", "file_extension": ".r", "codemirror_mode": "r" }, "nav_menu": {}, "toc": { "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "base_numbering": 1, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": { "height": "552px", "left": "0px", "right": "1154px", "top": "110px", "width": "212px" }, "toc_section_display": "block", "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }