Random effects and nested models with SAS



Similar documents
Milk Data Analysis. 1. Objective Introduction to SAS PROC MIXED Analyzing protein milk data using STATA Refit protein milk data using PROC MIXED

SAS Syntax and Output for Data Manipulation:

Chapter 19 Split-Plot Designs

Outline. Topic 4 - Analysis of Variance Approach to Regression. Partitioning Sums of Squares. Total Sum of Squares. Partitioning sums of squares

Family economics data: total family income, expenditures, debt status for 50 families in two cohorts (A and B), annual records from

Basic Statistical and Modeling Procedures Using SAS

This can dilute the significance of a departure from the null hypothesis. We can focus the test on departures of a particular form.

Data Mining and Data Warehousing. Henryk Maciejewski. Data Mining Predictive modelling: regression

Electronic Thesis and Dissertations UCLA

ORTHOGONAL POLYNOMIAL CONTRASTS INDIVIDUAL DF COMPARISONS: EQUALLY SPACED TREATMENTS

MEAN SEPARATION TESTS (LSD AND Tukey s Procedure) is rejected, we need a method to determine which means are significantly different from the others.

Topic 9. Factorial Experiments [ST&D Chapter 15]

New SAS Procedures for Analysis of Sample Survey Data

I L L I N O I S UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN

Overview of Methods for Analyzing Cluster-Correlated Data. Garrett M. Fitzmaurice

STATISTICA Formula Guide: Logistic Regression. Table of Contents

Experimental Design for Influential Factors of Rates on Massive Open Online Courses

ANOVA. February 12, 2015

An Introduction to Statistical Tests for the SAS Programmer Sara Beck, Fred Hutchinson Cancer Research Center, Seattle, WA

ADVANCED FORECASTING MODELS USING SAS SOFTWARE

ii. More than one per Trt*Block -> EXPLORATORY MODEL

861 Example SPLH. 5 page 1. prefer to have. New data in. SPSS Syntax FILE HANDLE. VARSTOCASESS /MAKE rt. COMPUTE mean=2. COMPUTE sal=2. END IF.

E(y i ) = x T i β. yield of the refined product as a percentage of crude specific gravity vapour pressure ASTM 10% point ASTM end point in degrees F

xtmixed & denominator degrees of freedom: myth or magic

The ANOVA for 2x2 Independent Groups Factorial Design

Lesson 1: Comparison of Population Means Part c: Comparison of Two- Means

MISSING DATA TECHNIQUES WITH SAS. IDRE Statistical Consulting Group

9.2 User s Guide SAS/STAT. The MIXED Procedure. (Book Excerpt) SAS Documentation

SAS Code to Select the Best Multiple Linear Regression Model for Multivariate Data Using Information Criteria

MIXED MODELS FOR REPEATED (LONGITUDINAL) DATA PART 1 DAVID C. HOWELL 4/26/2010

Stat 5303 (Oehlert): Tukey One Degree of Freedom 1

Lab 5 Linear Regression with Within-subject Correlation. Goals: Data: Use the pig data which is in wide format:

Getting Correct Results from PROC REG

5. Linear Regression

Statistics, Data Analysis & Econometrics

Lecture 14: GLM Estimation and Logistic Regression

Assessing Model Fit and Finding a Fit Model

Simple Linear Regression Inference

ECON 142 SKETCH OF SOLUTIONS FOR APPLIED EXERCISE #2

Chapter 4 and 5 solutions

1. What is the critical value for this 95% confidence interval? CV = z.025 = invnorm(0.025) = 1.96

An Introduction to Modeling Longitudinal Data

Final Exam Practice Problem Answers

SAS Software to Fit the Generalized Linear Model

Logistic (RLOGIST) Example #3

Factor Analysis. Factor Analysis

Appendix 1: Estimation of the two-variable saturated model in SPSS, Stata and R using the Netherlands 1973 example data

This chapter will demonstrate how to perform multiple linear regression with IBM SPSS

MIXED MODEL ANALYSIS USING R

Use of deviance statistics for comparing models

Logistic (RLOGIST) Example #7

1.1. Simple Regression in Excel (Excel 2010).

Technical report. in SPSS AN INTRODUCTION TO THE MIXED PROCEDURE

Regression Analysis: A Complete Example

5. Multiple regression

Multiple Regression in SPSS This example shows you how to perform multiple regression. The basic command is regression : linear.

Failure to take the sampling scheme into account can lead to inaccurate point estimates and/or flawed estimates of the standard errors.

Logistic (RLOGIST) Example #1

Curve Fitting. Before You Begin

Time-Series Regression and Generalized Least Squares in R

Generalized Linear Models

I n d i a n a U n i v e r s i t y U n i v e r s i t y I n f o r m a t i o n T e c h n o l o g y S e r v i c e s

MSwM examples. Jose A. Sanchez-Espigares, Alberto Lopez-Moreno Dept. of Statistics and Operations Research UPC-BarcelonaTech.

August 2012 EXAMINATIONS Solution Part I

Multiple Linear Regression

VI. Introduction to Logistic Regression

A Brief Introduction to SPSS Factor Analysis

POLYNOMIAL AND MULTIPLE REGRESSION. Polynomial regression used to fit nonlinear (e.g. curvilinear) data into a least squares linear regression model.

Elementary Statistics Sample Exam #3

Regression step-by-step using Microsoft Excel

Gamma Distribution Fitting

One-Way Analysis of Variance (ANOVA) Example Problem

IAPRI Quantitative Analysis Capacity Building Series. Multiple regression analysis & interpreting results

Handling missing data in Stata a whirlwind tour

N-Way Analysis of Variance

Data Analysis Tools. Tools for Summarizing Data

Multivariate Analysis of Variance (MANOVA)

Linear Mixed-Effects Modeling in SPSS: An Introduction to the MIXED Procedure

Using An Ordered Logistic Regression Model with SAS Vartanian: SW 541

GLM I An Introduction to Generalized Linear Models

n + n log(2π) + n log(rss/n)

DEPARTMENT OF PSYCHOLOGY UNIVERSITY OF LANCASTER MSC IN PSYCHOLOGICAL RESEARCH METHODS ANALYSING AND INTERPRETING DATA 2 PART 1 WEEK 9

Estimation of σ 2, the variance of ɛ

" Y. Notation and Equations for Regression Lecture 11/4. Notation:

SIMPLE LINEAR CORRELATION. r can range from -1 to 1, and is independent of units of measurement. Correlation can be done on two dependent variables.

Generalized Mixed Models for Binomial Longitudinal Outcomes (% Correct) using PROC GLIMMIX

Please follow the directions once you locate the Stata software in your computer. Room 114 (Business Lab) has computers with Stata software

Lecture 11: Confidence intervals and model comparison for linear regression; analysis of variance

Evaluation of Correlation between Within-Barn Curing Environment and TSNA Accumulation in Dark Air-Cured Tobacco

Univariate Regression

Testing for Lack of Fit

5 Analysis of Variance models, complex linear models and Random effects models

Specification of Rasch-based Measures in Structural Equation Modelling (SEM) Thomas Salzberger

Section 13, Part 1 ANOVA. Analysis Of Variance

HURDLE AND SELECTION MODELS Jeff Wooldridge Michigan State University BGSE/IZA Course in Microeconometrics July 2009

(1) These are incomplete block designs (sometimes balanced) that are resolvable.

Transcription:

Random effects and nested models with SAS /************* classical2.sas ********************* Three levels of factor A, four levels of B Both fixed Both random A fixed, B random B nested within A ***************************************************/ options linesize = 79 pagesize=100 noovp formdlim='-'; data mixedup; infile 'mixedup.data'; input ID Y A B; proc glm; title 'Default proc glm: Both Fixed'; model y = a b; means a*b; proc glm; title 'Both Random with proc glm'; model y = a b; random a b a*b / test ; /* Have to specify interaction random too, and explicitly ask for tests */ proc glm; title 'A Fixed, B Random'; model y = a b; random b a*b / test; proc glm; title 'A fixed, B random and nested within A'; model y = a b(a); random b(a) / test; proc mixed cl; title 'A fixed, B random and nested within A'; title2 'Using proc mixed'; model y = a ; random b(a); proc glm; title 'Both random, B nested within A'; model y = a b(a); random a b(a) / test; proc sort; by A B; /* Data must be sorted in order of nesting*/ proc nested; title 'Nested random effects with proc nested'; class A B; var Y; proc mixed cl; title 'Pure nested with proc mixed'; model y = ; random a b(a); Page 1 of 11

Default proc glm: Both Fixed 1 Default proc glm: Both Fixed 2 Sum of Source DF Squares Mean Square F Value Pr > F Model 11 723.6220996 65.7838272 6.69 <.0001 Error 24 236.0284247 9.8345177 Corrected Total 35 959.6505243 R-Square Coeff Var Root MSE Y Mean 0.754048 29.78261 3.136003 10.52964 Source DF Type I SS Mean Square F Value Pr > F Page 2 of 11

Both Random with proc glm 4 Both Random with proc glm 5 Sum of Source DF Squares Mean Square F Value Pr > F Model 11 723.6220996 65.7838272 6.69 <.0001 Error 24 236.0284247 9.8345177 Corrected Total 35 959.6505243 R-Square Coeff Var Root MSE Y Mean 0.754048 29.78261 3.136003 10.52964 Source DF Type I SS Mean Square F Value Pr > F Source A B A*B Type III Expected Mean Square Var(Error) + 3 Var(A*B) + 12 Var(A) Var(Error) + 3 Var(A*B) + 9 Var(B) Var(Error) + 3 Var(A*B) Page 3 of 11

Both Random with proc glm 7 Tests of Hypotheses for Random Model Analysis of Variance A 2 448.156313 224.078156 10.41 0.0112 B 3 146.257270 48.752423 2.26 0.1813 Error: MS(A*B) 6 129.208517 21.534753 A*B 6 129.208517 21.534753 2.19 0.0796 Error: MS(Error) 24 236.028425 9.834518 A Fixed, B Random 8 A Fixed, B Random 9 Sum of Source DF Squares Mean Square F Value Pr > F Model 11 723.6220996 65.7838272 6.69 <.0001 Error 24 236.0284247 9.8345177 Corrected Total 35 959.6505243 R-Square Coeff Var Root MSE Y Mean 0.754048 29.78261 3.136003 10.52964 Page 4 of 11

Source DF Type I SS Mean Square F Value Pr > F A Fixed, B Random 10 Source A B A*B Type III Expected Mean Square Var(Error) + 3 Var(A*B) + Q(A) Var(Error) + 3 Var(A*B) + 9 Var(B) Var(Error) + 3 Var(A*B) A Fixed, B Random 11 Tests of Hypotheses for Mixed Model Analysis of Variance A 2 448.156313 224.078156 10.41 0.0112 B 3 146.257270 48.752423 2.26 0.1813 Error: MS(A*B) 6 129.208517 21.534753 A*B 6 129.208517 21.534753 2.19 0.0796 Error: MS(Error) 24 236.028425 9.834518 Page 5 of 11

A fixed, B random and nested within A 12 A fixed, B random and nested within A 13 Sum of Source DF Squares Mean Square F Value Pr > F Model 11 723.6220996 65.7838272 6.69 <.0001 Error 24 236.0284247 9.8345177 Corrected Total 35 959.6505243 R-Square Coeff Var Root MSE Y Mean 0.754048 29.78261 3.136003 10.52964 Source DF Type I SS Mean Square F Value Pr > F B(A) 9 275.4657870 30.6073097 3.11 0.0126 B(A) 9 275.4657870 30.6073097 3.11 0.0126 A fixed, B random and nested within A 14 Source A B(A) Type III Expected Mean Square Var(Error) + 3 Var(B(A)) + Q(A) Var(Error) + 3 Var(B(A)) Page 6 of 11

A fixed, B random and nested within A 15 Tests of Hypotheses for Mixed Model Analysis of Variance A 2 448.156313 224.078156 7.32 0.0130 Error: MS(B(A)) 9 275.465787 30.607310 B(A) 9 275.465787 30.607310 3.11 0.0126 Error: MS(Error) 24 236.028425 9.834518 A fixed, B random and nested within A 16 Using proc mixed The Mixed Procedure Model Information Data Set Dependent Variable Covariance Structure Estimation Method Residual Variance Method Fixed Effects SE Method Degrees of Freedom Method WORK.MIXEDUP Y Variance Components REML Profile Model-Based Containment Dimensions Covariance Parameters 2 Columns in X 4 Columns in Z 12 Subjects 1 Max Obs Per Subject 36 Number of Observations Number of Observations Not Used 0 Page 7 of 11

Iteration History Iteration Evaluations -2 Res Log Like Criterion 0 1 191.55201049 1 1 186.75737473 0.00000000 Convergence criteria met. Covariance Parameter Estimates Cov Parm Estimate Alpha Lower Upper B(A) 6.9243 0.05 2.4834 57.3781 Residual 9.8345 0.05 5.9960 19.0328 Fit Statistics -2 Res Log Likelihood 186.8 AIC (smaller is better) 190.8 AICC (smaller is better) 191.2 BIC (smaller is better) 191.7 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F A 2 9 7.32 0.0130 Page 8 of 11

Both random, B nested within A 17 Both random, B nested within A 18 Sum of Source DF Squares Mean Square F Value Pr > F Model 11 723.6220996 65.7838272 6.69 <.0001 Error 24 236.0284247 9.8345177 Corrected Total 35 959.6505243 R-Square Coeff Var Root MSE Y Mean 0.754048 29.78261 3.136003 10.52964 Source DF Type I SS Mean Square F Value Pr > F B(A) 9 275.4657870 30.6073097 3.11 0.0126 B(A) 9 275.4657870 30.6073097 3.11 0.0126 Both random, B nested within A 19 Source A B(A) Type III Expected Mean Square Var(Error) + 3 Var(B(A)) + 12 Var(A) Var(Error) + 3 Var(B(A)) Page 9 of 11

Both random, B nested within A 20 Tests of Hypotheses for Random Model Analysis of Variance A 2 448.156313 224.078156 7.32 0.0130 Error: MS(B(A)) 9 275.465787 30.607310 B(A) 9 275.465787 30.607310 3.11 0.0126 Error: MS(Error) 24 236.028425 9.834518 Nested random effects with proc nested 21 The NESTED Procedure Coefficients of Expected Mean Squares Source A B Error A 12 3 1 B 0 3 1 Error 0 0 1 Nested Random Effects Analysis of Variance for Variable Y Variance Sum of Error Source DF Squares F Value Pr > F Term Total 35 959.650524 A 2 448.156313 7.32 0.0130 B B 9 275.465787 3.11 0.0126 Error Error 24 236.028425 Nested Random Effects Analysis of Variance for Variable Y Variance Variance Percent Source Mean Square Component of Total Total 27.418586 32.881352 100.0000 A 224.078156 16.122571 49.0326 B 30.607310 6.924264 21.0583 Error 9.834518 9.834518 29.9091 Y Mean 10.52964444 Standard Error of Y Mean 2.49487339 Page 10 of 11

Pure nested with proc mixed 22 The Mixed Procedure Model Information Data Set Dependent Variable Covariance Structure Estimation Method Residual Variance Method Fixed Effects SE Method Degrees of Freedom Method WORK.MIXEDUP Y Variance Components REML Profile Model-Based Containment Dimensions Covariance Parameters 3 Columns in X 1 Columns in Z 15 Subjects 1 Max Obs Per Subject 36 Number of Observations Number of Observations Not Used 0 Iteration History Iteration Evaluations -2 Res Log Like Criterion 0 1 218.80195545 1 1 199.38591766 0.00000000 Convergence criteria met. Covariance Parameter Estimates Cov Parm Estimate Alpha Lower Upper A 16.1226 0.05 3.8361 1927.28 B(A) 6.9243 0.05 2.4834 57.3781 Residual 9.8345 0.05 5.9960 19.0328 Page 11 of 11