## Announcements

New! Solutions for Homework 5 posted. User name and password are posted on the Canvas web site for the course (linked in the navigation to the left).

The textbook (see Textbook under General Info (in navigation to the left)) is available electronically through the university library (in the Canvas web site, under "Library Course Materials" in the Canvas navigation). So you do not have to buy a textbook unless you want a physical copy.

The slides for the talk about reproducibility.

## Announcements from Previous Years

### Arguments of R functions `factor` and `ordered`

The example in the notes for ordered categorical data serves as a poor example of R function `ordered` that creates an ordered factor. The example is completely correct, but isn't doing the same thing as in homework problem 4-3.

• In the example, the data (from Agresti) has numerical values (1, 2, 3) which the code in the example takes to be the levels of the ordered category. But since we don't like those as category names, we supply the correct names at the `labels` argument to R function `ordered`.
• In the homework, the data (from me) has character values (`"not injured"`, `"injured, no ER"`, `"injured, ER, not hospitalized"`, `"hospitalized did not die"`, `"died"`). So there isn't a pre-existing order. If you don't specify an order of categories, R will take alphabetical order, which is not what is wanted. Thus you have to supply the correct order as the `levels` argument to R function `ordered`.
• You could also use the argument `labels` to specify different category names (perhaps abbreviated).
• In short, arguments `levels` and `labels` work very differently, and you have to know which you want.
• Argument `levels` is for specifying the order of the factor levels.
• Argument `labels` is for changing the names of the factor levels.
• Everything above also applies to R function `factor` which makes unordered or ordered factors.

This web site has no index, so in order to find stuff one needs to use a search engine. Here is how to do that. For example, if you want to find information on Poisson sampling, then the search

```"Poisson sampling" site:www.stat.umn.edu/geyer/5421
```
does that. This works either with Google or with DuckDuckGo. The quotation marks mean find the exact phrase. If they are left off, then the search engine will return results that have the word Poisson and the word distribution, not necessarily in the same section much less in the same sentence. The magic is the `site:` part, which tells the search engine only to look in that site. The site can be made more restrictive, for example,
```"Poisson sampling" site:www.stat.umn.edu/geyer/5421/notes
```
says to look only in the notes directory.

### Plain R

This course will use plain R rather than Rstudio.

You can use Rstudio if you want, but I don't need anything it does.

I am starting to use the base R pipe operator `|>` (introduced in R 4.1.0, released 2021-05-18). In pipelines I may also use the placeholder `_` (introduced in in R 4.2.0, released 2022-04-22). So if you have an older version of R, you may want to upgrade. (Otherwise, some of what is done in the notes may not work for you).

For more on pipelines, see here, but that may be a lot more than you want to know right now.

### R Packages

There are two R packages designed specifically for this course

and numerous other packages used in course notes and examples. R packages that are used in the homework solutions include Install these packages in R by executing the commands
```pkgs <- c("CatDataAnalysis", "glmbb", "mcmc", "network", "ump")
install.packages(pkgs)
```
at the R command line or, of you prefer, by mousing around in menus of the R app or Rstudio. (Packages KernSmooth and MASS do not need to be installed because they are R recommended packages installed by default when R is installed.)

### R markdown

My introduction to R markdown is on my Stat 3701 web pages: An Rmarkdown Demo. Both the R markdown source (Rmd file) and the output (either HTML or PDF file) are linked there.

Other material about R markdown can be found at rstudio.com and in the books

Hopefully, you will not need any of these books to do the homework. Since all of the course notes and homework assignments are in R markdown, you can always look at the source and see how I did anything you see in the notes or homework assignments.

One student and perhaps others have had trouble getting the file for homework problem 4-3. Apparently some computer vendors believe in handcuffing users so severely they cannot get any work done. So here is an alternative procedure.

• Use a web browser to download the file table-8.18.txt to your computer. Put it in the same directory (also called folder) as your Rmarkdown file.
• Then use the command
```read.table("table-8.18.txt", header = TRUE)
```