# Ed Psych 590CA

Edpsych 590CA

C.J. Anderson

Fall 2019

Last Revised November 5, 2019

**General Information**

**Announcements**

**Lecture notes**

**Computing**

**Homework**

**Handy program and links**

Questions or problems regarding this site should be sent to cja@illinois.edu.

**General Information **(MSword
format):

- Syllabus 2019. Working draft.
- Course log/plan.

- This advanced graduate seminar is designed for Ph.D. students in QUERIES, quantitative psychology, or related field. Required for this seminar is knowledge of multilevel modeling, mulitvariate statistics, different probability distributions beyond the "big 5", and basic mathematical statistics.
- Class participation is very important. The student presentations of their projects will be placed online in login based learning management system that is password protected
- R will be used for computing.
**Introduction****Estimation and Inferences for a Proportion**

R scripts:- R code to plot various priors, likelihoods, and posteriors
- Function to plot diferent binomial and different beta distributions
- R functions that plot prior, likelihood, and resulting posterior
- US president height example for post 1924 US presidental candidates
- R for example comparing two probabilities.
- Data for Example with 2 proportions height of post 1924 US presidental candidates
- R function: grid.BetaBin.txt
- Additional examples to use for practice:
- DATA for practice: GSS 2018, approve laws regarding gun ownership. for three different years.
- DATA for practice: Trump approval polls Retrived from three different polls.
- DATA for practice: GSS 2012 Does earth revolve around the sun? (and years of education)
- DATA for practice: GSS 2012 Does earth revolve around the sun? (and number of children)

**Inference mean of a normally distribution variable with variance known.**

R code:- R function normal prior x normal likelihood
- R anorexia data example.
- Anorexia data
- Getting what you pay for data I pulled this from web and added some variables. Information about the data: SAT data -- getting what you pay for; Data are from 1994-95; Data source: Deborah Guber, Depart Political Science, U of Vermont;

**Inference mean and variance of a normally distributed variable.**

R code:- R code for graphs of Gamma and Inverse Gamma Distributions.
- R anorexia data example.
- Anorexia data li>Getting what you pay for data I pulled this from web and added some variables. Information about the data: SAT data -- getting what you pay for; Data are from 1994-95; Data source: Deborah Guber, Depart Political Science, U of Vermont;
- Getting what you pay for analyses. (fixed variance, estimate mean)
- Getting what you pay for analyses. (adding in estimating both mean and variance)

**Markov Chain Monte Carlo.**

R code:- R function that illustrates Metropolis algorithm. This requires a fixed value of sigma and estimates distribution for mean. The algorithm creates plots at each iteration. To make it run faster, delete the graphing commands.
- Anorexia data analyzed by Metropolis algorithm. Approximates the posteriors of just the mean with known variance and approximates posteriors of both mean and variance.
- R function that uses Metropolis algorithm for mean and variance of normal. This version works well for variables regardless of mean or scale. Need tuning to get a good proposal (jump) standard deviation. Note that starting values for the mean should be between min(y) and max(y) for algorithm to work properly.
- Getting what you pay for data I pulled this from web and added some variables. Information about the data: SAT data -- getting what you pay for; Data are from 1994-95; Data source: Deborah Guber, Depart Political Science, U of Vermont;
- Some code to help with practice problem. Approximates the posteriors of just the mean with known variance and approximates posteriors of both mean and variance.
- DBDA2E-utilities.txt. These are a set of functions from Krischke's text, Doing Bayesian Data Analysis, edition 2. I pulled this off the text web-site and put it into a stand alone txt file. This re-produce graphics in the text; however, more things are available in the coda package.

**Gibbs Sampling and jags**

R code:- R code for mean and sigma to test your code set up. This estimates the mean and variance for the anorexia data set.
- 3-D plots of mean and variance of normal. One is static and the other is dynamic/interactive.
- R functon that illustrates Gibbs sampling. This is for the case of a mean and variance for a single normal variable
- Analysis of anorexia data using jags.
- Rmarkdown version of Analysis of anorexia data using jags. This is a word document has the same content as the txt file immediately above, but in word document with code and results. You can also add notes to this for latter use.
- Anorexia data.
- SAT data: getting what you paid for.
- R and jags for getting what you paid for.

**Bayesian Linear Regression**

R code:- NELS: example of simple linear regression.
- Rmardown of NELS example of simple linear regression. This include almost all the R-code as the text file. The latter includes the "2nd" method referred to in the former.
- NELS data for one school.
- Anorexia with discrete predictor.
- Anorexia data.
- SAT data: getting what you paid for.

**Multiple Linear Regression**

R code:**Multilevel (heirarchical) Linear and Logistic Regression**Note: logistic example data was not quite right --- see next set of notes for correction.

I'm still working on this secton R and data:- Rmarkdown word doc for anorexia example.
- R script for fitting models to anorexia data.
- Anorexia Data (long format).
- Anorexia Data (wide format).
- Rmarkdown (word doc) for nels example. (just 23 schools)
- R code for fitting models to nels data. (just 23 schools)
- Data: 23 schools from nels.
- R package brms illustrated using nels data. This is running stan under the hood. The package can do alot more than is illustrated here and Hamletonian Sampling will be discussed in subsequent lecture. See top of R script for more information.
- R script for multilevel logistic regression. This uses data set with 5 items and actually is an IRT model.
- 10 General Social Survey Vocabulary data. Includes 10 items and some possible predictors. We will only use 5 items.

**Hamiltonian and Stan ...1st draft...**- Rmarkdown showing brms Various models fit to nels 23 school using brms. Also how to extract stand code from brms model object and subsequently use it. This could be a big time saver in simulation studies.
- Rmarkdown: Nels 23 school examples (mean and sd, simple linear regression, and multiple regression
- Nels 23 school examples (hierarchical linear models with random intercept....very slow)
- Nels 23 school data
- Example of Stan using anorexia data.

**Logistic Regression**

R code:- R code for Medical school admission data: gpa and gmat
- Medical school admission data: gpa and gmat
- Addmision data from UCLA web-site. (admission, gre, gpa and rank of school graduating from)....if you want to try fitting models to another data set.

**Student Presentations:**Materials are not public but may be available upon request and consent of student who created presentation and R script.- Homework 1
- Assignment 1 (due September 4)
- Answer key

- Homework 2
- Assignment 2 (due September 11)
- Answer key

- Homework 3
- Assignment 3 (due September 18)
- Answer key

**Announcements:**

**Lectures Notes:**

(I will up-date these throughout the semester. Since these are drafts, there are likely many typos most of which will be corrected in class)

(I will up-date these throughout the semester. Since these are drafts, there are likely many typos most of which will be corrected in class)

**Homework**

** **