《spss mixed model学习课件学习.pptx》由会员分享,可在线阅读,更多相关《spss mixed model学习课件学习.pptx(82页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、1Outline1.Classification of Effects2.Random Effects1.Two-Way Random Layout2.Solutions and estimates3.General linear model1.Fixed Effects Models1.The one-way layout4.Mixed Model theory1.Proper error terms5.Two-way layout6.Full-factorial model1.Contrasts with interaction terms2.Graphing Interactions第1
2、页/共82页2Outline-ContdRepeated Measures ANOVAAdvantages of Mixed Models over GLM.第2页/共82页3Definition of Mixed Modelsby their component effects1.Mixed Models contain both fixed and random effects2.Fixed Effects:factors for which the only levels under consideration are contained in the coding of those e
3、ffects3.Random Effects:Factors for which the levels contained in the coding of those factors are a random sample of the total number of levels in the population for that factor.第3页/共82页4Examples of Fixed and Random Effects1.Fixed effect:2.Sex where both male and female genders are included in the fa
4、ctor,sex.3.Agegroup:Minor and Adult are both included in the factor of agegroup4.Random effect:1.Subject:the sample is a random sample of the target population第4页/共82页5Classification of effects1.There are main effects:Linear Explanatory Factors 2.There are interaction effects:Joint effects over and
5、above the component main effects.第5页/共82页6第6页/共82页7Classification of Effects-contdHierarchical designs have nested effects.Nested effects are those with subjects within groups.An example would be patients nested within doctors and doctors nested within hospitalsThis could be expressed bypatients(doc
6、tors)doctors(hospitals)第7页/共82页8第8页/共82页9Between and Within-Subject effectsSuch effects may sometimes be fixed or random.Their classification depends on the experimental designBetween-subjects effects are those who are in one group or another but not in both.Experimental group is a fixed effect beca
7、use the manager is considering only those groups in his experiment.One group is the experimental group and the other is the control group.Therefore,this grouping factor is a between-subject effect.Within-subject effects are experienced by subjects repeatedly over time.Trial is a random effect when t
8、here are several trials in the repeated measures design;all subjects experience all of the trials.Trial is therefore a within-subject effect.Operator may be a fixed or random effect,depending upon whether one is generalizing beyond the sampleIf operator is a random effect,then the machine*operator i
9、nteraction is a random effect.There are contrasts:These contrast the values of one level with those of other levels of the same effect.第9页/共82页10Between Subject effectsGender:One is either male or female,but not both.Group:One is either in the control,experimental,or the comparison group but not mor
10、e than one.第10页/共82页11Within-Subjects EffectsThese are repeated effects.Observation 1,2,and 3 might be the pre,post,and follow-up observations on each person.Each person experiences all of these levels or categories.These are found in repeated measures analysis of variance.第11页/共82页12Repeated Observ
11、ations are Within-Subjects effects Trial 1 Trial 2 Trial 3 GroupGroup is a between subjects effect,whereas Trial is a within subjects effect.第12页/共82页13The General Linear Model1.The main effects general linear model can be parameterized as第13页/共82页14A factorial modelIf an interaction term were inclu
12、ded,the formula would beThe interaction or crossed effect is the joint effect,over and above the individual main effects.Therefore,the main effects must be in the model for the interaction to be properly specified.第14页/共82页15Higher-Order InteractionsIf 3-way interactions are in the model,then the ma
13、in effects and all lower order interactions must be in the model for the 3-way interaction to be properly specified.For example,a 3-way interaction model would be:第15页/共82页16The General Linear ModelIn matrix terminology,the general linear model may be expressed as第16页/共82页17AssumptionsOf the general
14、 linear model第17页/共82页18General Linear Model Assumptions-contd1.Residual Normality.2.Homogeneity of error variance3.Functional form of Model:Linearity of Model4.No Multicollinearity5.Independence of observations6.No autocorrelation of errors 7.No influential outliersWe have to test for these to be s
15、ure that the model is valid.We will discuss the robustness of the model in face of violations of these assumptions.We will discuss recourses when these assumptions are violated.第18页/共82页19Explanation of these assumptions1.Functional form of Model:Linearity of Model:These models only analyze the line
16、ar relationship.2.Independence of observations3.Representativeness of sample4.Residual Normality:So the alpha regions of the significance tests are properly defined.5.Homogeneity of error variance:So the confidence limits may be easily found.6.No Multicollinearity:Prevents efficient estimation of th
17、e parameters.7.No autocorrelation of errors:Autocorrelation inflates the R2,F and t tests.8.No influential outliers:They bias the parameter estimation.第19页/共82页20Diagnostic tests for these assumptions1.Functional form of Model:Linearity of Model:Pair plot2.Independence of observations:Runs test3.Rep
18、resentativeness of sample:Inquire about sample design4.Residual Normality:SK or SW test5.Homogeneity of error variance Graph of Zresid*Zpred6.No Multicollinearity:Corr of X7.No autocorrelation of errors:ACF8.No influential outliers:Leverage and Cooks D.第20页/共82页21Testing for outliersFrequencies anal
19、ysis of stdres cksd.Look for standardized residuals greater than 3.5 or less than 3.5And look for Cooks D.第21页/共82页22Studentized ResidualsBelsley et al(1980)recommend the use of studentizedResiduals to determine whether there is an outlier.第22页/共82页23Influence of Outliers1.Leverage is measured by th
20、e diagonal components of the hat matrix.2.The hat matrix comes from the formula for the regression of Y.第23页/共82页24Leverage and the Hat matrix1.The hat matrix transforms Y into the predicted scores.2.The diagonals of the hat matrix indicate which values will be outliers or not.3.The diagonals are th
21、erefore measures of leverage.4.Leverage is bounded by two limits:1/n and 1.The closer the leverage is to unity,the more leverage the value has.5.The trace of the hat matrix=the number of variables in the model.6.When the leverage 2p/n then there is high leverage according to Belsley et al.(1980)cite
22、d in Long,J.F.Modern Methods of Data Analysis(p.262).For smaller samples,Vellman and Welsch(1981)suggested that 3p/n is the criterion.第24页/共82页25Cooks D1.Another measure of influence.2.This is a popular one.The formula for it is:Cook and Weisberg(1982)suggested that values of D that exceeded 50%of t
23、he F distribution(df=p,n-p)are large.第25页/共82页26Cooks D in SPSSFinding the influential outliersSelect those observations for which cksd (4*p)/n Belsley suggests 4/(n-p-1)as a cutoffIf cksd (4*p)/(n-p-1);第26页/共82页27What to do with outliers1.Check coding to spot typos2.Correct typos3.If observational
24、outlier is correct,examine the dffits option to see the influence on the fitting statistics.4.This will show the standardized influence of the observation on the fit.If the influence of the outlier is bad,then consider removal or replacement of it with imputation.第27页/共82页28Decomposition of the Sums
25、 of Squares1.Mean deviations are computed when means are subtracted from individual scores.1.This is done for the total,the group mean,and the error terms.2.Mean deviations are squared and these are called sums of squares3.Variances are computed by dividing the Sums of Squares by their degrees of fr
26、eedom.4.The total Variance=Model Variance+error variance第28页/共82页29Formula for Decomposition of Sums of SquaresSS total =SS error +SSmodel第29页/共82页30Variance DecompositionDividing each of the sums of squares by their respective degrees of freedom yields the variances.Total variance=error variance+mo
27、del variance.第30页/共82页31Proportion of Variance ExplainedR2 =proportion of variance explained.SStotal=SSmodel+SSerrrorDivide all sides by SStotalSSmodel/SStotal =1-SSError/SStotalR2=1-SSError/SStotal第31页/共82页32The Omnibus F testThe omnibus F test is a test that all of the means of the levels of the m
28、ain effects and as well as any interactions specified are not significantly different from one another.Suppose the model is a one way anova on breakingpressure of bonds of different metals.Suppose there are three metals:nickel,iron,andCopper.H0:Mean(Nickel)=mean(Iron)=mean(Copper)Ha:Mean(Nickel)ne M
29、ean(Iron)or Mean(Nickel)ne Mean(Copper)or Mean(Iron)ne Mean(Copper)第32页/共82页33Testing different Levels of a Factor against one anotherContrast are tests of the mean of one level of a factor against other levels.第33页/共82页34Contrasts-contdA contrast statement computes The estimated V-is the generalize
30、d inverse of the coefficient matrix of the mixed model.The L vector is the kb vector.The numerator df is the rank(L)and the denominatordf is taken from the fixed effects table unless otherwisespecified.第34页/共82页35Construction of the F tests in different modelsThe F test is a ratio of two variances(M
31、ean Squares).It is constructed by dividing the MS of the effect to betested by a MS of the denominator term.The divisionshould leave only the effect to be tested left over as a remainder.A Fixed Effects model F test for a=MSa/MSerror.A Random Effects model F test for a=MSa/MSabA Mixed Effects model
32、F test for b=MSa/MSabA Mixed Effects model F test for ab=MSab/MSerror第35页/共82页36Data formatThe data format for a GLM is that of wide data.第36页/共82页37Data Format for Mixed Models is Long第37页/共82页38Conversion of Wide to Long Data FormatClick on Data in the header barThen click on Restructure in the po
33、p-down menu第38页/共82页39A restructure wizard appearsSelect restructure selected variables into cases and click on Next第39页/共82页40A Variables to Cases:Number of Variable Groups dialog box appears.We select one and click on next.第40页/共82页41We select the repeated variables and move them to the target var
34、iable box第41页/共82页42After moving the repeated variables into the target variable box,we move the fixed variables into the Fixed variable box,and select a variable for case idin this case,subject.Then we click on Next第42页/共82页43A create index variables dialog box appears.We leave the number of index
35、variables to be created at one and click on next at the bottom of the box第43页/共82页44When the following box appears we just type in time and select Next.第44页/共82页45When the options dialog box appears,we select the option for dropping variables not selected.We then click on Finish.第45页/共82页46We thus o
36、btain our data in long format第46页/共82页47The Mixed Model The Mixed Model uses long data format.It includes fixed and random effects.It can be used to model merely fixed or random effects,by zeroing out the other parameter vector.The F tests for the fixed,random,and mixed models differ.Because the Mix
37、ed Model has the parameter vector for both of these and can estimate the error covariance matrix for each,it can provide the correct standard errors for either the fixed or random effects.第47页/共82页48The Mixed Model第48页/共82页49Mixed Model Theory-contdLittle et al.(p.139)note that u and e are uncorrela
38、ted random variables with 0 means and covariances,G and R,respectively.V-is a generalized inverse.Because V is usually singular and noninvertible AVA=V-is an augmented matrix that is invertible.It can later be transformed back to V.The G and R matrices must be positive definite.In the Mixed procedur
39、e,the covariance type of the random(generalized)effects defines the structure of G and a repeated covariance type defines structure of R.第49页/共82页50Mixed Model AssumptionsA linear relationship between dependent and independent variables第50页/共82页51Random Effects Covariance StructureThis defines the s
40、tructure of the G matrix,the random effects,in the mixed model.Possible structures permitted by current version of SPSS:Scaled IdentityCompound SymmetryAR(1)Huynh-Feldt第51页/共82页52Structures of Repeated effects(R matrix)-contd第52页/共82页53Structures of Repeated Effects(R matrix)第53页/共82页54Structures of
41、 Repeated effects(R matrix)contd第54页/共82页55R matrix,defines the correlation among repeated random effectsOne can specify the nature of the correlation among therepeated random effects.第55页/共82页56GLM Mixed ModelThe General Linear Model is a special case of theMixed Model with Z=0(which means thatZu d
42、isappears from the model)and 第56页/共82页57Mixed Analysis of a Fixed Effects modelSPSS tests these fixed effects just as it does with the GLMProcedure with type III sums of squares.We analyze the breaking pressure of bonds made from three metals.We assume that we do not generalize beyond our sample and
43、 that our effects are all fixed.Tests of Fixed Effects is performed with the help of the L matrix by constructing the following F test:Numerator df=rank(L)Denominator df=RESID(n-rank(X)df=Satherth 第57页/共82页58Estimation:Newton Scoring第58页/共82页59Estimation:Minimization of the objective functionsUsing
44、Newton Scoring,the following functions are minimized第59页/共82页60Significance of Parameters第60页/共82页61Test one covariance structure against the other with the ICThe rule of thumb is smaller is better-2LLAIC AkaikeAICC Hurvich and TsayBIC Bayesian Info CriterionBozdogans CAIC第61页/共82页62Measures of Lack
45、 of fit:The information Criteria-2LL is called the deviance.It is a measure of sum of squared errors.AIC=-2LL+2p(p=#parms)BIC=Schwartz Bayesian Info criterion=2LL+plog(n)AICC=Hurvich and Tsays small sample correction on AIC:-2LL+2p(n/(n-p-1)CAIC=-2LL+p(log(n)+1)第62页/共82页63Procedures for Fitting the
46、Mixed ModelOne can use the LR test or the lesser of the information criteria.The smaller the information criterion,the better the model happens to be.We try to go from a larger to a smaller information criterion when we fit the model.第63页/共82页64LR test1.To test whether one model is significantly bet
47、ter than the other.2.To test random effect for statistical significance3.To test covariance structure improvement4.To test both.5.Distributed as a 6.With df=p2 p1 where pi=#parms in model i第64页/共82页65Applying the LR testWe obtain the-2LL from the unrestricted model.We obtain the-2LL from the restric
48、ted model.We subtract the latter from the larger former.That is a chi-square with df=the difference in the number of parameters.We can look this up and determine whether or not it is statistically significant.第65页/共82页66Advantages of the Mixed Model1.It can allow random effects to be properly specif
49、ied and computed,unlike the GLM.2.It can allow correlation of errors,unlike the GLM.It therefore has more flexibility in modeling the error covariance structure.3.It can allow the error terms to exhibit nonconstant variability,unlike the GLM,allowing more flexibility in modeling the dependent variab
50、le.4.It can handle missing data,whereas the repeated measures GLM cannot.第66页/共82页67Programming A Repeated Measures ANOVA with PROC MixedSelect the Mixed Linear Option in Analysis第67页/共82页68Move subject ID into the subjects box and the repeated variable into the repeated box.Click on continue第68页/共8