Announcements
New! New erratum (under Errata in the Navigation to the left).
New! New reading assignment.
Solutions for Homework 4 posted. User name and password are posted on the Canvas web site for the course (linked in the navigation to the left).
On Wednesday, Dec 10 we will have two office hours (like every day homework is due) one before and one after class (also like most other days homework is due). As always, Zoom only allows start times on the half hour, so the links say 12:00 and 2:30 but the office hours will start at 12:20 and 2:30. But the second often starts a bit late.
Homework 5 assigned. Canvas upload (assignment) made.
Homework 3 solutions uploaded (under Homework Solutions in navigation to the left).
Since 3 days after homework 4 is due is a holiday, that homework (only) will be accepted with late penalty up to 4 days late. Canvas has been set accordingly.
New erratum (under Errata in the Navigation to the left).
Two new links added under Computer Examples in the navigation to the left. One is the central limit theorem examples shown in class Monday, September 15.
Notes about statistical inference for the binomial have some details useful for doing the homework that are not in the chapter zero notes.
Office hours scheduled right after every class except for a few moved to right before class. All the Zoom links should show in Canvas. The before class office hours start at 12:20 but Zoom only allows 12:00 or 12:30 so I chose 12:00 but won't open the Zoom session until 12:20. There is also an extra office hour before class on days homework is due, but only one of those has been scheduled (for the first homework).
Canvas discussion group set up for questions about homeworks.
Canvas assignment set up for homework 1. Canvas assignment also set up for toy homework. The latter is just to practice uploading if you want to.
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
labelsargument to R functionordered. -
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 thelevelsargument to R functionordered. -
You could also use the argument
labelsto specify different category names (perhaps abbreviated). -
In short, arguments
levelsandlabelswork very differently, and you have to know which you want.-
Argument
levelsis for specifying the order of the factor levels. -
Argument
labelsis for changing the names of the factor levels.
-
Argument
- Everything above also applies to R function
factorwhich makes unordered or ordered factors.
Search this Website
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/5421does 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/notessays 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
- R Markdown: The Definitive Guide"
- the R Markdown Cookbook
- bookdown: Authoring Books and Technical Documents with R Markdown
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.
Downloading Files
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)to read the file.
