---
title: "Ling 201, session 09: practice (class)"
author:
   - name: "[Stefan Th. Gries](https://www.stgries.info)"
     affiliation: "UC Santa Barbara & JLU Giessen"
     orcid: 0000-0002-6497-3958
date: "2027-03-02 12:34:56"
date-format: "DD MMM YYYY HH-mm-ss"
editor: source
format:
   html:
      page-layout: full
      code-fold: false
      code-link: true
      code-copy: true
      code-tools: true
      code-line-numbers: true
      code-overflow: scroll
      number-sections: true
      smooth-scroll: true
      toc: true
      toc-depth: 4
      number-depth: 4
      toc-location: left
      monofont: lucida console
      tbl-cap-location: top
      fig-cap-location: bottom
      fig-width: 6
      fig-height: 6
      fig-format: png
      fig-dpi: 300
      fig-align: center
      embed-resources: true
      include-in-header:
         text: '<link rel="shortcut icon" href="https://www.stgries.info/favicon.ico" type="image/x-icon" />'
execute:
   cache: false
   echo: true
   eval: true
   warning: false
---

```{r prepworkspace}
rm(list=ls(all=TRUE)); library(magrittr)
```

# Exercise 1

Each member of a group of 10 subjects is asked to read two sentences, each containing a particular vowel segment, and the pitch level of the vowel is measured in each reading. The results (in arbitrary units) are as follows; you want to test whether the average pitch levels in sentence 1 and sentence 2 are significantly different.

## Hypotheses

The

* dependent/response variables is/are, if any, # replace this with your answers/code;
* independent/predictor variables is/are, if any, # replace this with your answers/code.

What are the hypotheses?

* text hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code;
* statistical hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code.

We create the data:

```{r exercise01create}
SENTENCE1 <- setNames(
   c(30,41,34,28,35,39,40,29,27,33), 1:10)
SENTENCE2 <- setNames(
   c(27,36,35,30,38,44,46,31,33,37), 1:10)
```

## Descriptive stats/visualization

```{r exercise01desc}
# replace this with your answers/code
```

## Statistical testing

```{r exercise01test}
# replace this with your answers/code
```

## Write-up

replace this with your answers/code

# Exercise 2

An experiment is performed to test the effect of certain linguistic features on the politeness of two sentences in a particular social context. 15 informants are asked to rate the two sentences on a scale from 1 (very impolite) to 5 (very polite), with the following results. You want to test the hypothesis that sentence 2 is rated as more polite than sentence 1.

## Hypotheses

The

* dependent/response variables is/are, if any, # replace this with your answers/code;
* independent/predictor variables is/are, if any, # replace this with your answers/code.

What are the hypotheses?

* text hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code;
* statistical hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code.

We create the data:

```{r exercise02create}
SENTENCE1 <- setNames(
   c(1,2,1,2,3,2,1,2,3,1,2,1,2,2,1),
   1:15)
SENTENCE2 <- setNames(
   c(3,2,4,3,1,4,1,3,5,3,3,4,1,4,3),
   1:15)
```

## Descriptive stats/visualization

```{r exercise02desc}
# replace this with your answers/code
```

## Statistical testing

```{r exercise02test}
median(SENTENCE1); IQR(SENTENCE1)
median(SENTENCE2); IQR(SENTENCE2)
wilcox.test(
   SENTENCE1, SENTENCE2, paired=TRUE, # compute a Wilcoxon test of both vectors
   correct=FALSE,                     # no continuity correction
   alternative="less")                # expecting that the median of the 1st is < than that of the 2nd
```

## Write-up

replace this with your answers/code

# Exercise 3

You want to test whether the numbers of IUs transcribers identify in a recording changes depending on whether the transcribers work on the recording once or twice. Ten transcribers annotated a recording for IUs on Monday and then again on Wednesday. Do the numbers of IUs differ on average?

## Hypotheses

The

* dependent/response variables is/are, if any, # replace this with your answers/code;
* independent/predictor variables is/are, if any, # replace this with your answers/code.

What are the hypotheses?

* text hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code;
* statistical hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code.

We create the data:

```{r exercise03create}
MONDAY <- setNames(
   c(16,18,15,18,10,12,16,14,16,11), 1:10)
WEDDAY <- setNames(
   c(15,16,13,15,11,11,14,11,15,15), 1:10)
```

## Descriptive stats/visualization

```{r exercise03desc}
# replace this with your answers/code
```

## Statistical testing

```{r exercise03test}
# replace this with your answers/code
```

## Write-up

replace this with your answers/code

# Exercise 4

We have language proficiency scores from two groups of subjects; you want to test whether the means differ significantly.

## Hypotheses

The

* dependent/response variables is/are, if any, # replace this with your answers/code;
* independent/predictor variables is/are, if any, # replace this with your answers/code.

What are the hypotheses?

* text hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code;
* statistical hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code.

We create the data:

```{r exercise04create}
grp_A <- c(41,58,62,51,48,34,64,50,53,60,44)
grp_B <- c(38,40,64,47,51,49,32,44,61)
```

## Descriptive stats/visualization

```{r exercise04desc1}
# replace this with your answers/code
```

## Statistical testing

```{r exercise04test}
# replace this with your answers/code
```

## Write-up

replace this with your answers/code

# Exercise 5

20 adult learners of Swahili are divided into two groups of 10 at random. Group A is taught by a grammar-translation method, group B by an audio-lingual method. At the end of the course, the two groups obtain the following scores on a proficiency test. You want to test whether group B performs significantly better on average.

## Hypotheses

The

* dependent/response variables is/are, if any, # replace this with your answers/code;
* independent/predictor variables is/are, if any, # replace this with your answers/code.

What are the hypotheses?

* text hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code;
* statistical hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code.

We create the data:

```{r exercise05create}
grp_A <- c(45,58,60,51,53,59,54,40,56,56)
grp_B <- c(48,58,71,56,59,62,64,62,52,69)
```

## Descriptive stats/visualization

We do a quick plot of the data and compute summary statistics for both groups:

```{r exercise05desc}
# replace this with your answers/code
```

## Statistical testing

```{r exercise05test}
# replace this with your answers/code
```

## Write-up

replace this with your answers/code

# Exercise 6

A study counted the frequencies of inversion of subject and verb after an introductory adverbial in declarative affirmative clauses in three texts for each of two time periods. You want to test for each time period whether the texts differ with regard to their frequencies of inversions. Here are the two tables with the frequencies for each time period:

## Hypotheses

The

* dependent/response variables is/are, if any, # replace this with your answers/code;
* independent/predictor variables is/are, if any, # replace this with your answers/code.

What are the hypotheses?

* text hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code;
* statistical hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code.

| Early  | Inversion: *no* | Inversion: *yes* |
|:------:|:---------------:|:----------------:|
| Text 1 | 27              | 11               |
| Text 2 | 34              | 16               |
| Text 3 | 34              | 14               |

| Late   | Inversion: *no* | Inversion: *yes* |
|:------:|:---------------:|:----------------:|
| Text 1 | 109             | 27               |
| Text 2 |  61             | 11               |
| Text 3 |  49             | 29               |

We input them into R:

```{r exercise06create}
# replace this with your answers/code
early <- # replace this with your answers/code
late <- # replace this with your answers/code
```

## Descriptive stats/visualization

We describe the data:

```{r exercise06desc}
# replace this with your answers/code
```

## Statistical testing

Here's the test for the early data:

```{r exercise06testearly}
# replace this with your answers/code
```

And here's the test for the later data:

```{r exercise06testlate}
# replace this with your answers/code
```

## Write-up

replace this with your answers/code

# Exercise 7

A panel of teachers is asked to grade the reading and writing abilities of 15 children on a scale from 1 (very poor) to 7 (excellent), with the results given below. You want to calculate an appropriate correlation coefficient and test it for significance.

## Hypotheses

The

* dependent/response variables is/are, if any, # replace this with your answers/code;
* independent/predictor variables is/are, if any, # replace this with your answers/code.

What are the hypotheses?

* text hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code;
* statistical hypotheses:
   + H~1~: replace this with your answers/code;
   + H~0~: replace this with your answers/code.

```{r exercise07create}
READING <- setNames(
   c(3,4,5,6,3,4,3,5,2,4,7,5,6,2,3), 1:15)
WRITING <- setNames(
   c(6,4,3,7,4,2,5,6,3,5,3,4,4,3,2), 1:15)
```

## Descriptive stats/visualization

```{r exercise07desc}
# replace this with your answers/code
```

## Statistical testing

Since this is a correlation scenario that probably involves ordinal variables -- "to grade the reading and writing abilities of 15 children" -- we compute two rank correlation coefficients:

```{r exercise07test}
# replace this with your answers/code
```

## Write-up

replace this with your answers/code

# Homework

Analyze the Chevrolet promotion data so that you can present your code and results in class; the question is whether the data in [_input/chevyprom1.csv](_input/chevyprom1.csv) (see [_input/chevyprom1.r](_input/chevyprom1.r)) support the claim that Chevrolet discriminated against women when it came to promoting staff?

# Session info

```{r sessionInfo}
sessionInfo()
```
