# Ed Psych 590CA

Edpsych 590CA

C.J. Anderson

Spring 2018

**General Information**

**Announcements**

**Lecture notes**

**Computing**

**Homework**

**Handy program and links**

**General Information **(MSword
format):

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

**Announcements:**

- March 28:
- A little example of the
**brms**(Bayesian regression models using Stan) package using nels data is posted under heirarchical models. This package fits "Bayesian generalized (non)linear multivariate models using Stan for full Bayesian interference". - The brms package requires use of Stan. To install Stan see https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows

- A little example of the
- March 26: Posted materials on multilevel models
- March 15: Posted materials on logistic regression
- March 3:
- Posted multiple regression notes and example R code.
- Put the nels data up under linear regression.
- Posted some data that will be used for logistic regression and HLM
- No lectures notes yet for HLM, logistic regresion or IRT (only the basics for the latter).

- Feb 26: Posted lecture and examples for Simple Linear Regression.
- Feb 20: Posted lecture and materials for Gibbs sampling and jags.
- Feb 13:
- Some small edits to MCMC notes and metropolis for mean and variance code.
- Folder for next 2 topics created (but nothing posted yet).
- I corrected some errors in normal mean and variance notes.
- Feb 8: Up-dated material on MCMC
- Feb 6: The following were posted today
- New version of lecture on normal mu with fixed variance.
- New version of lecture on unknown mean and variance
**What I did on my pc to set up R to run jags.**

- Feb 5:
- up-dated notes on normal distribution
- posted materials for MCMC

- Jan 22: posted more notes, data and R.
- Jan 17: web-sites are fixed up
- This advanced graduate seminar is designed for Ph.D. students in QUERIES, quantitative psychology, or related field. Enrollment will be based on consent of instructor. Required for the course is knowledge of multilevel modeling, mulitvariate statistics, different probability distributions beyond the "big 5", and basic mathematical statistics.
- Class participation is very important. After an introducation to basic topics and methods, students will be responsible for presenting a model and showing how to estimate it. Specific models will be determined by intereste of the class. The student presentations placed online and at the end of the semester will be compiled and put online as an archive.
- R will be used for computing.
**Introduction****Inference and Estimation of a Proportion**

R code:- R code for prior x likelihood
- R diferent binomial and beta distributions
- R function: beta.binomial.txt
- R for example (height of post 1924 US presidental candidates)
- R for example comparing two probabilities.
- R function: grid.BetaBin.txt
- DATA: Height and handedness of all US presidental candidates.
- DATA for practice: GSS 2012 Does earth revolve around the sun? (and years of education) -- not used
- DATA for practice: GSS 2012 Does earth revolve around the sun? (and number of children) -- not used

**Inference mean of a normally distribution variable with variance known.**(at least some typos fixed)

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
- 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;

**Markov_Chain_Monte_Carlo**(part 1)

R code:- R functon that illustrates Metropolis alogrithm. 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/comment out the graphing commands.
- Anorexia data analyzed by Metropolis alogrithm. Approximates the posteriors of just the mean with known variance and approximates posteriors of both mean and variance.
- R functon that uses Metropolis alogrithm for mean and variance of normal (version 2). This is version and works well for variables regardless of mean or scale. Need to input proposal (jump) standard deviation, which helps with tuning. Note that starting values for the mean should be between min(y) and max(y) for alogrithm to work properly.
- Anorexia data analyzed by Metropolis alogrithm. Approximates the posteriors of just the mean with known variance and approximates posteriors of both mean and variance.
- R code for mean and sigma to test your code set up. This estimates the mean and variance for the Getting what you paid for data set.
- 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-produces graphics in the text; however, more things are available in the coda package.

**Gibbs Sampling and jagas**

R code:- 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.
- Anorexia data.
- SAT data: getting what you paid for.

**Bayesian Linear Regression**

R code:**Multiple Linear Regression**

R code:**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.

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

R scripts and data:- R script for fitting models to anorexia data.
- Anorexia data (long format).
- Anorexia data (wide format).
- R code for fitting models to nels data. (just 23 schools)
- R package brms illustrated using nels data. The package can do alot more than is illustrated here. See top of R script for more information.
- 23 schools from nels.
- 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.

**Bayesian IRT (1 and 2pl models) These notes are not quite comlete.**

R scripts and data:- IRT models for General Social Survey Vocabulary data.
- 10 General Social Survey Vocabulary data. Includes 10 items and some possible predictors. We will only use 5 items.

**Student's Choice & Presentations:**Materials are not public but may be available upon request and consent of student who created presentation and R script. Topics covered (2018):
- The BANOVA package.
- Hierarchial linear model applied to PISA data.
- 1 and 2pl IRT models using Stan.
- Meta-analysis using the brms package (& metafo).
- Multilevel logistic regression.
- Cross-random effects model.

**Lectures Notes: (****I will up-date these throughout the semester. Since these are 1st drafts, lots of typos most of which are corrected in class**)