Edpsych/Psych/Stat 587

C.J. Anderson

Fall 2016

*Last revised: August 30, 2016*

**General Information **(MSword format):

- Aug 30: Homework is due at the beginning of lecture. If you are sick then give it to a friend or e-mail it to both Wes and Carolyn.
- Aug 30: If you come to the lab session at 9am for an introduction to SAS, bring your laptop and put data file on your remote desktop account (if using).
- Aug 25:
- Introduction to SAS will be Tuesday Sept 1, 9-10am in room 22 Education. Bring you laptop.
- The lab sessions when we have them will be 9-10:30 for R and 10:30-12 for SAS and mostly likely be on Thursdays.

- Aug 25: See below for the first homework assignement, which is due Tuesday August 30.
- Aug 24: Those who came to class but weren't registered and signed the attendence sheet can all register. You have to send me your UIN and netid so that I can put in a request for an override.
**Draft chapters on GLM, GLMM, and LLM (i.e., HLM).**- Resources for R users:
- Introduction to Multilevel Modeling in R by Grover, Guillermono and Hudson (2015). This document using high school and beyond data set to illustrate a lot about how to do data management, HLM models and analyses, and graphics. If you are using R, I highly recomend this.
- Doing scatterplots with lattice
- A Brief Introduction to R, the multilevel package and the nlme package by Paul Bliese (2016). This includes some introductory material on R and how to do multilevel modeling.
- Lecture notes by Kyle Roberts. I included these because there is a nice R code section

**Computing:**We will be running statistical software (SAS) using remote desktop to a university server. Here are the instructions: remote desktop connection. Here is the file referred to in the instructions as an RDP file. --- Use "Save link as" when you download the RDP file and save it to a convient location (e.g., desktop). When you run the RDP application and it will run remote desktop application and set up configurations such that you will be able to directly open and save files from the remote server to your computer (and visa versa). If you don't want to do these things, just use your remote desktop program and enter "remote2.webstore.illinois.edu". There are 2 things that you need before you can do this:- Your computer must be hooked up to the internet. If you access the internet via campus wireless, home, hotel, Espresso Royal, or elsewhere), you will eed to use VPN (Virtual Private Networking) to securely connect to the campus internet.
- You must be registered for the class. If you reccently registered, you may not yet have permission to login yet.

**Introduction (**up-dated Fall 2016).

SAS that generated (most of) the statistics and graphs in the lecture notes:**Models for clustered data: Fixed and random effects ANOVA and multiple regression. up-dated Fall 2016**

SAS and R code that reproduces the statistics, graphs, etc. in the lecture notes:- SAS
- NELS data for 10 schools. Run this program before the next one.
- Generates statistics, fits models & produces graphics.

- R (New 2016)

- SAS
**Optional: Introduction to SAS to be held....Tuesday Aug 30, 9am in room 22 Education.**- Introduction to SAS notes..
- hsb1.sas. Creates SAS data set of level 1 data for the High School and Beyond data.
- Using SAS assist for graphics.
- Slick online SAS training from SAS.com

**Random Intercept Models**. up-dated Fall 2016

- SAS:
**ANCOVA.sas.**Fits ANCOVA model to NELS88, N=10 data (includes centering a variable, model fitting using GLM, and SAS/GRAPH of model).**hsb1.sas.**Creates SAS data set of level 1 data for the High School and Beyond data.**hsb2.sas.**Creates SAS data set of level 2 data for the High School and Beyond data.**hsball.sas.**Merges level 1 and level 2 high school and beyond sas datasets.**betwithin.sas.**SAS/GRAPHS for looking between and within variability of SES in the high school and beyond data.**randomintercepts.sas.**SAS PROC MIXED and fitting random intercept models (includes centering SES)...and some graphics.

- R: (New 2016)
- For the NELS example, use R from note on previous lecture on models for clustered data.
**HSB1data.txt**. Student level data**HSB2data.txt**. School level data**R_hsb_rand_intercept.txt**. R code that reproduces everything in lecture notes. You will need to change the "setwd" to where you put the data and install package lmer, lattice and lmerTest.

- SAS:
**SAS for HLM and a little R**.

These will be used in lecture (they can also be used to reproduce the models for HSB data in the lecture notes on random intercept models):

- SAS:
- HSB1 data. (level 1 data -- students)
- HSB2 data (level 2 data -- schools)
- SAS code to be discussed in lecture.
- Using SAS assist for graphics.

- This is from the introduction to SAS session:
- R: See R code under Notes on Random Intercept Models

- SAS:
**Random Intercept and Slopes Models**. (up-dated Fall 2016)

- SAS
- text file of data. NELS88 data for N=23 school.
- school23.sas. SAS program that creates SAS data set for NEL88 data for N=23 school.
- NELS23.sas. SAS program that fits various random intercept and slope models to the NEL88 data for N=23 school.
- Centering & NELS data. Illustrates effects of different kinds of centering -- NEL88 data for N=23 school.
- SAS examples discussed in lecture.

- R (New Fall 2016)
- NELS23 data in txt format.
- R code for NELS for 23 schools. Including among other things, code for data manipulation, creating variables, doing some graphics, model fitting using lmer.
- Student level HSB data in txt format.
- School level HSB data in txt format.
- R code for HSB. Code for data manipulation, creating variables, doing some graphics, model fitting using lmer. Note all the graphics code is here, but the R code for Nels (23 schools) has examples of similar graphics.

**Estimation of Marginal Model**. (Up-dated fall 2016)- SAS: How to simulate HLM (in SAS).
- SAS: Simulation study on MLE vs REML and different N.
- SAS: For those who might want to use Bayesian estimation, I worked up a small example for the empty model, random intercept with one predictor, and a random intercept and slope model. I also included SAS PROC MIXED code if you want to compare results. You can change the seed to "-1" and run the mcmc code a few times and compare results.

R: R code for graphs illustrating MLE. **Statistical Inference: Marginal Model**.- SAS commands for ddfm (Simulation to show what different choices for df yield).
- HSB1 data. (level 1 data -- students)
- HSB2 data (level 2 data -- schools)
- hlmrsq.sas SAS macro that computes R_1^2 and R_2^2.
- Recchia JSS paper describing the hlmrsq.sas macro and how to use it.
- SAS for fixed effects & Rsq. Illustrates various things.
- Example: computing p-value of mixture of chi-squares (i.e., test of variance).
**Random Effects.**- HSB1 data. (level 1 data -- students)
- HSB2 data (level 2 data -- schools)
- SAS program and EB estimates of U's.
- SAS commands for mini-study on micro sample size on U's.
- SAS commands for mini-study on macro sample size on estimates.
- SAS commands for mini-study on effects of non-normality onf the distribution of EB estimates.
- Using SAS/ASSIST to produce graphics. (Alternatives given in next lecture).
- Links to software and rescourse for computing power and deciding on sample size:
- Optimal Design Software Program and documenation from Raudenbush group. (PC only)
- PINT Program and documentation from Snijders. (PC only)
- Xiaofeng Steven Liu (2014). Statistical Power Analysis for the Social and Behavioral Sciences: Basic and Advanced Techinques. Routledge: NY. This book contains explanation of procedures and code for R, SAS and SPSS. If you search google scholar for "Xiaofeng Liu power hlm", you will find some of his papers on power and HLM (He was a student of Raudenbush).

**Model Building. (revision complete)**- New SAS programs:
- NELS data for N=23 schools (from Kreft & de Leeuw).
- SAS Exploratory data analysis: Fixed Effects
- SAS Exploratory data analysis: Random Effects
- Modeling the data & diagnostics.
- Assessing homogeneity variance assumption (and modeling level 1 variance as random ).
You will need the high school and beyond data for this:
- HSB1 data. (level 1 data -- students)
- HSB2 data (level 2 data -- schools)

- Old SAS programs:
- eda.sas SAS program including commands for exploratory data analyses (SAS/GRAPH, R^2meta, R^2_j, means structure, etc).
- Simulations.sas. SAS program running first simulation and exploration of random structure.
- Simulation_long.sas. SAS program running second simulation and exploration of random structure. This has a different sigma^2's and tau's.
- New Variance EDA.sas. Exploratory data analyses of random structure for example given in class.
- SAS v9.1 experimental diagnostics..

- Longitudinal Data Analysis
- Lecture notes on Longitudinal Data and HLM.
- Lecture notes on Serial Correlation.. (not up-dated---may not cover)
- HLM for Riesby data. (data from Hedeker web-site plus additional analyses I did).
- Error Structures Simulation:

- Multilevel Logistic Regression.
- Longitudinal study on depression. (data from Agresti, 2002)
- Longitudinal study on respiratory infections. (data from Skrondal & Rabe-Hesketh,2004)
- Simmulation study & demonstration.
- I will not be posting the Rodkin et al. data set or SAS code.
- Rasch and 2pl model fit to LSAT6.
- Rasch and 2pl model fit to General Social Suvery Vocabulary items with covariate.
- SAS for plotting item response curves for GSS data.

**Computer Lab Sessions: Bring laptop**

- Computer Lab Session 0 (optional): Introduction to SAS ---> Tuesday 9am, Aug 30, 3016
- HSB1 data sas file (level 1 data -- students)
- Introduction to SAS notes..
- Using SAS assist for graphics.
- Slick online SAS training from SAS.com

- Computer Lab Session 1: (bring laptop)
- Computer Lab Session 2: (bring laptop)
- SAS program and data for Lab 2.
- Computer Lab instructions & description of data.
- Short program created during session 1 and used in session 2.
- SAS program that does it all. (available after homework 2 turned in).

- Computer Lab Session 3: bring laptop.
- Computer Lab instructions. We will use data and your programs from previous labs. If you don't have it handy, use SAS program that does it all.
- hlmrsq.sas SAS macro that computes R_1^2 and R_2^2.
- Lab3, session 1 (new)
- Lab3, session 2 (new)
- SAS program that does it all.

- Computer Lab Session 4: bring laptop.

- New SAS programs:
- Homwork 1:
- Homework 1 (Due August 30, 2016)
- Some example answers will go here.

- Homwork 2:
- Homework 2 (Due TBA)
- Answers will go here.

**Final Exam and Projects**: Hardcopy is due**due TBA (offices are locked around 4:00pm)**. Pentalty for late finals or projects is 10 points (out of 100 points) per weekday (e.g., turn in Friday, 10 point deduction; turn in Monday 20 point, etc).- Payne, B.R., Gao, X., Noh, S.R., Anderson, C.J., Stine-Morrow, E.A.L. (2011). The effects of print
exposure on sentence processing and memory in older adulats: Evidence for efficiency and reserve. Aging, Neuropsychology, and Cognition.

Some examples of crossed random effects, skewed responses (i.e., reaction times), and discrete response (i.e., Poisson). - Segerstrom, S.C. & Sephton, S.E. (2010). Optimistic expectanices and cell-mediated immunity: The role
of positive affect. Psychological Science, 21, 448-455.

Example of where cluster centered level one variable is substantive (theoretical) interest. The response variable is numerical/continuous.

- Allen, N.E., Todd, N.R., Anderson, C.J., Davis, S.M., Javdani, Bruehler, V., & Dorsey, H.
(2013). Council-Based approaches to intimate partner violence: Evidence for distal change in system response. American Journal of Community
Psychology, 52, 1-12.

Example of a longitudinal study with creative centering of time. The response variable was a rate (probability). - Poteat, V.P. & Anderson, C.J. (2012). Developmental changes in sexual prejudice from early to late
adolescence: The effects of gener, race, and ideology on different patterns of change. Developmental Psychology, 48, 1403-1415.

Example of an accelerated longitudinal design. - Examples from Tom Snijders course web-page where multilevel models have been used. (click on "info course multilevel" on left and go to
bottom of page. These papers cover a range of topics (e.g., political science, sociology, school psychology, criminology, medicine, and others).
**MLbook.sas**. Create SAS data for examples in Chapters 4 and 5.**Ch4_examples.sas**. Example 2-level analyses from Chapter 4 (random intercept models).**Ch5_examples.sas**. Example 2-level analyses from Chapter 5 (random intercept and slopes).**Ch12_examples.sas**. Examples analyses from Chapter 12 (longitudinal data analysis), including creating sas dataset.-
**Examples from Chapter 4 of Kreft & de Leeuw (provided and written by Carol Nickerson):** -
**School23.sas.**SAS code that creates data set and fits models reported in Kreft & de Leeuw. -
**school23.dat.**Raw data file that is used as input to school23.sas. -
**Ones specific to multilevel modeling:** -
**Centre for Multilevel Modelling.**This site includes trainting materials, publications, reviews of multilevel software, data sets, a BBC audio program featuring Harvey Goldstein, and more.. -
**Tom Snijders' multilevel web-site.**This has data & various material that's used in Snijders & Bosker*An Introduction to Basic and Advanced Multilevel Modeling*as well as other multilevel stuff. -
**Scientific software international**home page. Student version of HLM program can be downloaded from this site. -
**NELS88 data**: various data sets used in Kreft & de Leeuw (Introducing heirarchical linear modeling) -
**Using SAS PROC MIXED to fit multilevel, heirarchical models, and individual growth models.**Downloadable paper by Judith Singer. Other papers also downloadable. -
**General ones:** -
**CIforP.f:**A FORTRAN program that computes large sample confidence intervals for a proportion. -
**pvalue.f:**A FORTRAN program that computes p-values and (bonferroni) critical values for the standard normal, chi-squared, t, and F distributions (and for correlations). For users of PC type computers, pvalue.exe is an executable (i.e. already compiled) program.