Skip to content

Commit

Permalink
Eal26 jun18 (#12)
Browse files Browse the repository at this point in the history
* just following bread crumbs

* worked on factorial example mostly

* cleaning up files

* for pull request end Jul

* why was this file left behind?
  • Loading branch information
emilioalaca authored Aug 1, 2018
1 parent d490340 commit 6fb591f
Show file tree
Hide file tree
Showing 74 changed files with 9,281 additions and 16,663 deletions.
17 changes: 16 additions & 1 deletion 02.0_Rcomputation.Rmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
output:
html_document:
fig_caption: yes
number_sections: yes
theme: readable
toc: yes
---
# Statistics with R {#chStatsR}

## Learning Objectives for Chapter
Expand Down Expand Up @@ -63,6 +71,13 @@ RStudio has a pane specifically designed to find information about functions, ob

There is a large community of R users all over the world. This community provides lots of help and support through multiple websites. Whenever you are stuck and cannot find the information you need in a form that you understand using R help, you should use a seach engine, typically Google, and pose your question directly as a web search. This works remarkably well if you use the correct keyworkds. Always end your query with "in R" so the search is much more focused.

## RStudio editor

```{block, type = 'rsstip'}
In R studio you can easily add balanced parenthesis ( ), brackets [ ], braces { }, single ' ' and double " " quotation marks by selecting the text to be enclosed and then typing the beginning character (, [, {, ', or ". RStudio will insert both the beginning and end parenthesis etc. making them "balanced."
```

## Data and data frames

See wikipedia entry on <a href="https://en.wikipedia.org/wiki/Data_curation" target = "_blank">Data Curation</a>.
Expand Down Expand Up @@ -147,7 +162,7 @@ Summary statistics are classified as measures of central tendency and measures o
We use the *clover.txt* data set provided in the first assignment. These data represent the mass of clover plants grown for different periods at three different temperatures. Temperatures are in the first column coded as 1 for 5-15 C, 2 for 10-20 C and 3 for 15-25 C. The second column contains the number of days of growth and the last column contains the log of the plant mass in g. Column names are in the first row of the file, so we specify *header = TRUE* in the line of code to read the data. Data are placed in a data frame named "clover.

```{r summarystats1, echo = TRUE}
clover <- read.csv("../PLS120Fall2016/LabFiles/Lab01clover.txt", header = TRUE) # read in data.
clover <- read.csv("Datasets/Lab01clover.txt", header = TRUE) # read in data.
help(clover) # Read about the nature of the data set.
(avg.lnwt <- mean(clover$lnwt)) # obtain the average lnwtance; note the use of $ to select parts of an object and the outer parentheses to display the result.
(med.lnwt <- median(clover$lnwt)) # median or 50th percentile
Expand Down
113 changes: 77 additions & 36 deletions 03.0_MathSymbols.Rmd

Large diffs are not rendered by default.

Binary file removed 03.0_MathSymbols_files/figure-html/math.polys-1.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 18 additions & 9 deletions 09.0_Anova1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ editor_options:
## Learning Objectives for Chapter

1. Write down the model for ANOVA and label its components.
1. Define experimental unit and determine number of experimental units in a given example.
1. Define experimental unit and determine number of experimental units in an experiment.
1. State the typical assumptions for ANOVA.
1. Perform tests of ANOVA assumptions.
1. Test ANOVA assumptions.
1. Translate scientific questions into null and alternative hypotheses.
1. State the null and alternative hypotheses for ANOVA.
1. Describe how variance is partitioned in a simple one-way ANOVA .
1. When is an ANOVA more appropriate than a T-test for hypothesis testing?
1. How does the calculation of experimental error change with and without subsamples?
1. Run an ANOVA, report the calculated F-value, report the p-value and state your hypothesis decision.
Run a T-test and report the calculated t-value. Compare this value to the F-value; what is the relationship?
Compare the calculated experimental error with and without subsamples in R.
1. Describe how variance is partitioned in a simple one-way ANOVA.
1. Calculate sum of squares and the corresponding degrees of freedom.
1. Compare ANOVA with t-tests for hypothesis testing.
1. Calculate of experimental error with and without subsamples.
1. Run an ANOVA and interpret the results in terms of the original scientific question.
1. Run a T-test and report the calculated t-value. Compare this value to the F-value; what is the relationship?

##Analysis of Variance (ANOVA)

Expand Down Expand Up @@ -117,6 +118,14 @@ for (i in 1:4) {
```

## Estimation of parameters

### R Code

### Detailed calculations

First, we present the calculations as traditionally taught in introductory courses. Then we briefly explain the method and equations actually used in the theory of least squares and emplemented by statistical software.


##Hypothesis Testing

Expand Down Expand Up @@ -427,7 +436,7 @@ The descriptive statistics for these data are augmented by with a table of avera

$$\bar{Y}_i. = \exp(\bar{Z}_i.) - 1.0$$

where $\bar{Z}_i.$ is the treatment average for the transformed variable. Transformations of reponse and predictor variables can be extremely useful to statistical modeling in general and in particular to meet the assumptions necessary to do inference in ANOVA. Recall that inference (**insert cross-reference**) means to make statistical statements about populations and their parameters based on samples.
where $\bar{Z}_i.$ is the treatment average for the transformed variable. Transformations of reponse and predictor variables can be extremely useful to statistical modeling in general and in particular to meet the assumptions necessary to do inference in ANOVA. Recall that inference ([see Chapter about inference](#)) means to make statistical statements about populations and their parameters based on samples.

To obtain descriptive statistics we will use the `aggregate` function. This is a versatile function that aggregates the data into groups defined by a formula and applies a predefined or a custom-built formula to obtain one result for each group. The custom function can be specified directly inside `aggregate`. Below, `smeans` is a dataframe that has two columns: one for treatment names and the other with the mean `logSmass` for each treatment. The `formula = ` argument tells R what variable is to be aggregated (logSmass) and what variable to use as grouping factor (Treatment). These variables are to be found in the dataframe specified by `data = `. Each group will be processed with the function `mean` as specified in `FUN = `. Note that the parentheses are not necessary to refer to the function that calculates the averages.

Expand Down
8 changes: 4 additions & 4 deletions 11.0_AnovaBlocks.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ output: html_document
editor_options:
chunk_output_type: console
---
# ANOVA with Blocks {#ch.rcbd}
# ANOVA with Blocks {#chRcbd}

## Learning Objectives for Chapter

Expand All @@ -24,7 +24,7 @@ editor_options:

## Laboratory Exercises

### Plant Sciences {#LabCh11PLS}
### Plant Sciences {#LabRCBD}

Prepare an .Rmd document starting with the following text, where you substitute the corresponsing information for author name and date.

Expand All @@ -37,7 +37,7 @@ output: html_document
---
```

```{r setup, include=FALSE}
```{r setupPS, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Expand Down Expand Up @@ -393,7 +393,7 @@ output: html_document
---
```

```{r setup, include=FALSE}
```{r setupAS, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Expand Down
Loading

0 comments on commit 6fb591f

Please sign in to comment.