Week 8, Lectures 1 & 2: Fixed-, Random-, and Mixed-Effects models

Size: px
Start display at page:

Download "Week 8, Lectures 1 & 2: Fixed-, Random-, and Mixed-Effects models"

Transcription

1 Week 8, Lectures 1 & 2: Fixed-, Random-, and Mixed-Effects models 1. The repeated measures design, where each of n Ss is measured k times, is a popular one in Psych. We approach this design in 2 ways: 1. As a generalisation of the paired t-test 2. As an expansion from 1-way to 2-way designs 2. Fixed & random effects; nested & repeated measures designs 3. Using EMS tables to define appropriate F ratios for certain designs 4. Options for modeling random effects in R 1

2 Outline of Lectures 1 & 2 on Mixed- 5. kv0.csv ; skv1.r 6. Expanded HW-5: Effects models 1. range of possible models 2. Use AIC and log(likelihood) to compare models 7. Refs: Howell, Chap. 14; Repeated_Measures/repeated_measures.htm ( ucla ) ( nwu ) 2

3 Reprise of paired t-test This latter analysis aptly finesses the problem introduced by the correlation across Ss between x 0i and x 1i. Each S gives 2 scores, one in Group = 0, and the other in Group = 1. Wrong analysis wd be res1 = t.test(x0, x1, var.equal = T), because it treats the 2 groups as independent! Correct analysis is res2 = t.test(x0, x1, var.equal = T, paired = T) 3

4 Reprise of paired t-test For the i th S, compute the difference: d i = x 1i x 0i. Let s = s.d. of the {d i }. t n 1 = s / d n ; or F 2 1,n 1 = t n 1 = nd 2 s 2. d = x 1 x 0. Grand mean is x + x SS Group = n[(x 1 x) 2 + (x 0 x) 2 ] x. = n(x 1 x 0 ) 2 = nd 2, after simplifying. Thus, F 1,n 1 = nd 2 s 2 = SS Group s 2 = MS Group s 2. Because k 1 =1.

5 Reprise of paired t-test F 1,n 1 = nd 2 How best to interpret s 2? d i is also the slope of each line in the Fig. Thus variation in d i is an index of a Subject x Group interaction. That is, s 2 = var(d i ) = the Subj x Group interaction MS. F 1,n 1 = nd 2 s 2 = MS Group s 2 s 2 = MS Group MS Sub*Group This expression for F generalises to the case, k > 2. 5

6 Introduction to Mixed Models An alternative way to finesse the problem of cor(x 0i, x 1i ) is to use the package lme4 (= Linear Mixed Effects, with S4 classes), and the function, lmer(). First, arrange data in long form, d1 (as for lm()). res3 = lmer(score ~ Group + (1 suid), data = d1). NOT res3i = lm(score ~ Group, data = d1), which is incorrect, because it ignores the grouping/ correlation resulting from the repeated measures design! Of course the linear mixed model, lmer(), can do much more than paired t-tests! [Recent articles tout its efficacy: JPSP 2012, by Judd, Westfall & Kenny; Science, Oct 2013, Biology s Dry Future, by R. Service.]

7 Passage from 1- to 2- & 3-way designs Example 1: How does the Score on a memory test depend on the length of the study period, T (= 1, 2, or 3 units)? We could use a 1-way between-groups design in which, say, 24 participants (Ss) are randomly assigned, n = 8 to each level of T. T = 1 T = 2 T = Source df SS MS F Between 2 MS b MS b /MS w Within 21 MS w Total 23 Even though the data in the table are in rows, there is no Row factor because the 3 Ss in each row have nothing in common. 7

8 Example 2: Same as Ex. 1, except that you now worry that Score might also depend on Ss' verbal Ability (A). So divide Ss into 2 levels of A, lo and hi, 12 Ss at each level. At each level of ability, randomly assign n = 4 Ss to each level of T. This is a 2-way between-groups factorial design. A T = 1 T = 2 T = 3 lo hi 3,5, 4,5, 3,7, 5,1, 5,6, 7,6, Source df SS MS F T 2 MS T /MS w A 1 MS A /MS w A * T 2 MS A*T /MS w Within 18 MS w Total 23 We have a Row (A) & a Col (T) factor, so we can define the A*T interaction. The 4 independent obs in each of the 6 cells are used to estimate MS w, which is the 8 denominator in all 3 F ratios.

9 Example 3: Same as Ex. 2, except that you now decide that the best way to control for Ability (A) is to use each S as her or his own control, and to measure each S s score at all 3 levels of T. Suppose we have 8 Ss. This is a 2-way within-group design, with S and T as the 2 factors. S T = 1 T = 2 T = Source df SS MS F T 2 MS T /MS res S 7 MS S /MS res Residual 14 MS res Total 23 Because n = 1 obs per cell, we cannot estimate the within-cell variance, MS w, separately from the interaction MS. Hence we lump the two sources of variation into MS res, as use this as the denominator in the F ratios for the 2 main effects. 9

10 Example 3 (cont d): One way to finesse the problem that the interaction MS and MS w are confounded is to assume that the interaction MS is 0 and, therefore, that MS res = MS w. Assuming that the interaction MS is 0 is equivalent to assuming that S and T have additive effects. The lm() model would be: rs3 = lm(score ~ subid + time, data=d0), rather than rs3a = lm(score ~ subid * time, data=d0), which wd give an error message! S T = 1 T = 2 T = Source df SS MS F T 2 MS T /MS res S 7 MS S /MS res Residual 14 MS res Total 23 10

11 ANOVA Table for the additive model Source df MS F df of F Row, e.g., gift Column, e.g., income r-1 MS r MS r / MS error c-1 MS c MS c / MS error r-1, df error c-1, df error Within Cell, or Error, or Residual df error = rc(n-1)+ (r-1)(c-1) Total N - 1 = rcn - 1 MS error or MS resid The formulae for the expected MS (EMS) tell us how to define F for testing each effect. n obs per cell. 11

12 ANOVA Table for the interactive model: **Note reduction in df error when we test for RxC interaction; and that df error = 0 if n = 1 Source df MS F df of F Row r-1 MS r MS r / MS error Column c-1 MS c MS c / MS error r-1, df error c-1, df error RxC interaction (r-1)(c-1) MS rc MS rc / MS error (r-1)(c-1), df error Within cell df error = rc(n-1) ** MS error Total N - 1 = rcn

13 CAVEAT: When n = 1, one cannot test for interaction! cat('interactive Model ) rs3a = lm(score ~ subid * time, data=d0) print(anova(rs3a)) Response: score Df Sum Sq Mean Sq F value Pr(>F) ability time ability:time Residuals #Note Residuals: ALL 12 residuals are 0: no residual degrees of freedom! Warning message: In anova.lm(rs3a) : ANOVA F-tests on an essentially perfect fit are unreliable 13

14 Design Differences between Ex. 2 & 3 A T = 1 T = 2 T = 3 lo 3,5, 4,5, 3,7, hi 5,1, 5,6, 7,6, S T = 1 T = 2 T = Both are 2-way factorial designs: A by T, and S by T. However, because we are rarely interested in S per se as an explanatory factor (Why?), but are interested in A, we refer to the S by T design as a 1-factor, within-s design! The number of levels of A is small ; that of S is large (more a symptom than a principled diff). 14

15 Design Differences between Ex. 2 & 3 A T = 1 T = 2 T = 3 lo 3,5, 4,5, 3,7, hi 5,1, 5,6, 7,6, S T = 1 T = 2 T = We are rarely interested in the levels S per se (i.e., in john vs mary vs ); these are merely random selections (or effects ) from a large popn of possible values. We wish to make inferences about this popn of S levels. We are interested in the levels of A ( lo vs hi ). These are fixed effects to be interpreted. 15

16 Design Differences between Ex. 2 & 3 A T = 1 T = 2 T = 3 S T = 1 T = 2 T = 3 lo hi 3,5, 4,5, 3,7, 5,1, 5,6, 7,6, In the A by T design, all obs at each level of A come from different Ss and, therefore, are statistically independent (i.e., uncorrelated) In the S by T design, all obs at each level of S come from the same S and, therefore, are correlated. That is, the correlation between scores when, e.g., T=1 and T=2 shd be positive. 16

17 Design Differences between Ex. 2 & 3 A T = 1 T = 2 T = 3 lo 3,5, 4,5, 3,7, hi 5,1, 5,6, 7,6, S T = 1 T = 2 T = The S by T design is also called a repeated measures design. The within-s correl between scores introduces complexities into the calculation of F ratios for this design To solve these complexities, we assume that the within-s correls satisfy certain simplifying conditions, e.g., Compound Symmetry. 17

18 Defn of Compound Symmetry (CS) We assume that the correlation across Ss between the scores at T = 1 and T = 2, cor(x 1i, x 2i ) = cor(x 1i, x 3i ) = cor(x 3i, x 2i ). If there is a between-ss factor, A, we also assume that the correls, cor(x 1i, x 2i ), cor(x 1i, x 3i ) and cor(x 3i, x 2i ), are the same when A = 1 as when A = 2. An almost equivalent set of conditions, known as sphericity, is that the variance of the differences between scores at T = i and T = j is the same for all i and j. 18

19 Mixed Models Fixed effect factors, e.g., gender, A (lo/ med/hi). For quant, B, fixed effects are the linear ( slope ) and quadratic effects of B Random effect factors, e.g., subject (suid), word, school, classroom Mixed models (MM) contain fixed and random effects. F ratios have to be defined carefully Subject is often present in a mixed model; subjects usually give > 1 obs (i.e., there is a within-s factor), and are often nested within a between-s factor. Hence MM analysis is often complicated by nesting and within-s correls 19

20 Example 4: 1 between-s factor, A, 1 within- S factor, T; Ss are thus nested within A The research questions are the same as before. Ss are classified as Low or High ability (A); n Ss at each A level, and each S is tested at all levels of T. A varies between Ss; and T varies within Ss - thus we have a repeated measures design. In addition to the fixed effects factors, A and T, there is the (unmentioned) random effects factor, S. But S 1 at Low A is not the same person as S 1 at High Ability. Thus, S is not crossed with A. We say that Subject is nested within Ability. 20

21 We need to be able to recognise a nested design (as opposed to a factorial design). Some R and SPSS functions require that we specify the nested factors; other functions do not. The data for n = 3 might be: Ability T Subject Low High

22 Structural (or formal) models are useful for calculating the EMS The structural model for the 2-way additive, fixed effects model is: X ijk = µ + a i + b j + e ijk, where a i is the fixed effect of Row i, b j is the fixed effect of Column j, Σ i a i = 0, Σ j b j = 0, etc. var(e ijk ) is labeled σ e2. The overall Row and Column effects are defined by parameters, θ a and θ b, that are quasivariances: θ a = a i=1 a i 2 a 1, θ b = b j =1 b j 2 b 1 22

23 Under H 0, each a i = 0, implying θ a = 0, and each b j = 0, implying θ b = 0. Under H 1, θ a > 0. Indeed θ a is the key determinant of E(MS r ), the Expected Mean Square for Rows. It can be shown that: E(MS r ) = σ e 2 + nbθ a, and E(MS c ) = σ e 2 + naθ b. Whether H 0 is true or not, E(MS error ) = σ e2. Good estimates of θ a and θ b are: θ a = (MS r - MS error )/nb, and θ b = (MS c - MS error )/na. In random effects models, a i is a random variable and θ a is replaced by var(a i ) = σ 2 a, etc. 23

24 Mixed-Effects Modeling in R Various functions in R can be used to analyse mixed models aov() in the base package; ideal for balanced designs with no missing data lme() and gls() in nlme, with p-values! lmer() in lme4, with the latest tricks, no p s! Use pvals.fnc {languager} or {lmertest} for p-values fastrml.lmm() in lmm, with improved est of the random effects Each function has its own syntax for distinguishing fixed from random effects See R script, srepmeas0.r 24

25 Drug Responses 1-1, 0, 1, 2, 1, -2, 3, 0 2 2, 3, 2, 0, 6, 1, 1, 5 3 4, 6, 3, 5, 3, 2, 5, 6 Drug may be a fixed- or randomeffects factor, as discussed earlier. 25

26 srepmeas0.r library(nlme) library(lme4) library(languager) # see also {lmertest} plot(d0) cat( 1. Fixed Effects model ) rs.fix = aov(score ~ drug, d0) print(summary(rs.fix)) print(model.tables(rs.fix, means,digits = 3) cat( 2. Random Effects model with aov() ) rs.ran = aov(score ~ drug + Error(drug), d0) #Drug random print(summary(rs.ran)) 26

27 cat( 3. Random Effects model with lme() ) rs.lme1 = lme(score ~ 1, random = ~ 1 drug, d0) #Package nlme print(summary(rs.lme1)) cat( 4. Random Effects model with lmer() ) rs.lmer1 = lmer(score ~ (1 drug), d0) #Package lme4 print(summary(rs.lmer1)) #To get p-values rs.mcmc = pvals.fnc(rs.lmer1, nsim = 10000, addplot = T) print(rs.mcmc) 27

28 Compare outputs from different functions in mixed-models analysis Our preferred function for analysing mixedmodels is lmer {lme4}. However, it is helpful to have some knowledge of others, esp lme {nlme}, because its syntax is sometimes used in yet other functions. A broad survey shows that the fixed effects are characterised by estimates and p-values, and the random effects by variances and covariances/correlations. 28

29 1. Drug as a fixed effects factor, using aov Df Sum Sq Mean Sq F value Pr(>F) drug ** Residuals Redo aov with Drug as random effects factor Error: drug Df Sum Sq Mean Sq drug Error: Within Df Sum Sq Mean Sq F value Pr(>F) Residuals Notes: MS drug = and MS resid = in both analyses. In 1-way designs, the F ratio is the same for the 2 models. 29

30 3. Redo random effects model with lme() Linear mixed-effects model fit by REML (Default: method=reml ) Data: d0 AIC BIC loglik Random effects: Formula: ~1 drug (Intercept) Residual StdDev: Fixed effects: score ~ 1 Value Std.Error DF t-value p-value (Intercept) Notes: MS resid = = 3.024, as found previously. Recall that E(MS b ) = σ e 2 + n σ b 2 = * = 28.2, as found previously. 30

31 4. Output from lmer() (default is REML=T ) Formula: score ~ 1 + (1 drug) Data: d0 [deviance = -2*logLik] AIC BIC loglik deviance REMLdev Random effects: Groups Name Variance Std.Dev. drug (Intercept) Residual Number of obs: 24, groups: drug, 3 Fixed effects: Estimate Std. Error t value (Intercept) These results are consistent with earlier ones. 31

32 $fixed Estimate MCMCmean HPD95lower HPD95upper pmcmc Pr(> t ) $random Groups Name StDev MCMCmedn MCMCmean HPD95lower HPD95upr drug (Int) Residual [Comments on loglik, deviance, REMLdev, Highest Posterior density (HPD); AIC = deviance + 2(p + 1)] Output from lme() AIC BIC loglik Output from lmer() AIC BIC loglik deviance REMLdev

33 Week 8, Lec 2: Issues in Mixed Models Review of various issues, preliminary to the introduction of lmer(), that arose in Lec. 1. Describe kv0.csv in HW-5: DV = score; attn is a between-s factor (2 levels); nsol is a within-s factor (3 levels); 10 Ss nested in each level of attn. What is the set of plausible (mixed) models for use in analysing the data? What is the theoretical rationale for these models? How to implement and test/compare models in R? 33

34 Preliminary Issues in Mixed Models S T = 1 T = 2 T = Source df SS MS F T 2 MS T /MS res S 7 MS S /MS res Residual 14 MS res Total 23 Subject (suid) is usually a random effects factor (unless we re interested in the roles of the specific Ss); is the variance, σ a2, of these random effects (e.g., of the overall mean or intercept of each S) significantly different from 0? σ 2 a is a parameter to be est. We are interested in the effect associated with each level of T; thus T is a fixed effects factor. If T is categorical with 2 df, there is a fixed effect associated with each df; this is a parameter to be est. If T is quantitative, the linear effect of T (i.e., the slope ) is a fixed effect with 1 df; and the quadratic effect of T (i.e., the non-linearity ) is also a fixed effect with 1 df; ; these are parameters to be est. 34

35 Preliminary Issues in Mixed Models When we have repeated obs for each S, S T = 1 T = 2 T = 3 this introduces a correl across Ss between, e.g., score at T=1 and score at T=2. This correl complicates the definition of test statistics for the different null hypotheses lmer() is designed to take account of these correls in defining appropriate testing procedures. Models with only fixed effects are analysed using lm(). Models with both fixed and random effects are called mixed models and are analysed using lmer() (or lme() or aov(), ). Subject (or suid) is sometimes referred to as the grouping factor. In linguistic studies, stimuli (e.g., words) can also be a random effect if each speaker responds to each word. Subjects can vary randomly in their overall average score (or intercept ); but they can also vary in their sensitivity to T (or slope ). How to specify and test these models with lmer()? 35

36 Preliminary Issues in Mixed Models The issue of p-values. We will discuss this issue more fully later on. Note that lme() gives p-values for fixed and random effects parameters, whereas lmer() gives t statistics, but no p-values, and only for fixed effects parameters. This is sometimes inconvenient (but never more than that!) For intercept only mixed models (the simplest type), pvals.fnc() {languager} does give p-values. See also {lmertest}. The recommendation is that we use, e.g., anova(rs1, rs2), to compare nested models, one containing the variance parameter of interest, and the other omitting this parameter. This comparison yields a p-value. Or the 36 rule-of-thumb: Reject if t > 2!

37 A simple example: 1-way design rs.lmer1 = lmer(score ~ (1 drug), d0) print(summary(rs.lmer1)) #To get p-values rs.mcmc = pvals.fnc(rs.lmer1, nsim = 10000, addplot = T) print(rs.mcmc) In this simple, 1-way design, the results are the same whether we regard drug as a fixed- or a random-effects factor. This is far from true for more complex models. Let us discuss the terms in the lmer() output. 37

38 Formula: score ~ 1 + (1 drug) Data: d0 AIC BIC loglik deviance REMLdev Random effects: Groups Name Variance Std.Dev. drug (Intercept) Residual Number of obs: 24, groups: drug, 3 Fixed effects: Estimate Std. Error t value (Intercept)

39 rs.mcmc = pvals.fnc(rs.lmer1, nsim = 10000, addplot = T) $fixed Estimate MCMCmean HPD95lower HPD95upper pmcmc Pr(> t ) $random Groups Name StDev MCMCmedn MCMCmean HPD95lower HPD95upr drug (Int) Residual [Comments on loglik, deviance, REMLdev, Highest Posterior density (HPD)] 39

40 Assessing an Intervention 50 patients enrolled in a weight loss program note their weights at the start of an intervention, at the end of Week 1, and at the end of Week 2. Let W 0, W 1 and W 2 be the initial, end-wk1, and end-wk2 weights. Data in wtloss1.csv. R script in srepmeas3.r Weights at the 3 time-points are correlated, because each person gives 3 weights, i.e., 3 repeated measures. So it wd be incorrect to treat this design as a 1-way design with time as group. 40

41 id w1 w2 w How to test H 0 : E(W 1 ) = E(W 2 ) = E(W 2 ), taking account of cor(w i, W j ), i j? Ans. Reshape the data into long form, and use lmer().

42 melt(), lm(), lmer() d1 = melt(d0, id.vars = c('id'), measure.vars = c('w1', 'w2', 'w3'), variable.name = 'time', value.name = 'weight') d1$id = factor(d1$id) # The random effects factors have to be defined as factors d1$time = as.numeric(d1$time) # Change 'time' from factor to quantitative variable, 1:3; for use in ggplot(). But CHECK that this line of code gives the correct coding for 'time'! 42

43 id w1 w2 w3 Data in long form, using melt() id time weight res2a = lmer(weight ~ time + (1 id), d1)

44 Plot data for each Subject to guage how Ss vary: Is there appreciable variation in intercept, as well as in slope? Data has to be in long form for ggplot2() g2 = (qplot(time, weight, facets = ~ id, geom = c('point', 'smooth'), method = lm, data = d1) + ) theme_bw() + ylim(40, 90) ggsave('wtloss1a.pdf', plot = g2) 44

45 weight time 45

46 Mixed models analyses with lmer() There appears to be appreciable variation in both intercept and slope across Ss. We start with intercept-only mixed models, then consider an intercept + slope model. ( slope = linear effect of time for each S. intercept is approx the mean wt of each S.) res3 = lmer(weight ~ time + (1 id), d1) print(summary(res3)) res4 = lmer(weight ~ poly(time, 2) + (1 id), d1) print(summary(res4)) print(anova(res3, res4))

47 Discuss results! res3 = lmer(weight ~ time + (1 id), d1) print(summary(res3)) Random effects: Groups Name Variance Std.Dev. id (Intercept) Residual Number of obs: 150, groups: id, 50 Fixed effects: Estimate Std. Error t value (Intercept) time

48 Discuss results! res4 = lmer(weight ~ poly(time, 2) + (1 id), d1) print(summary(res4)) Random effects: Groups Name Variance Std.Dev. id (Intercept) Residual Number of obs: 150, groups: id, 50 Fixed effects: Estimate Std. Error t value (Intercept) poly(time, 2) poly(time, 2)

49 Compare res3 & res4: Is the quadratic effect of time sig? No, because the coeff of poly(time, 2)2 in the lmer() output is not sig (t < 1). For another answer: print(anova(res3, res4)) Models: res3: weight ~ time + (1 id) res4: weight ~ poly(time, 2) + (1 id) Df AIC BIC loglik Chisq ChiDf Pr(>Chisq) res res res4 is not sig better than res3, so keep simpler model, res3. 49

50 Intercept + slope model res5 = lmer(weight ~ time + (1 + time id), d1) print(summary(res5)) print(anova(res3, res5)) Models: res3: weight ~ time + (1 id) res5: weight ~ time + (1 + time id) Df AIC BIC loglik Chisq ChiDf Pr(>Chisq) res res e-05 *** The variation in slope is sig, and this parameter shd be included in mixed models analyses of these data. 50

51 Summary of mixed models analyses The individual-s plots show that the time effect is approx linear for all Ss. A formal test of the relevant coefficient, and a formal model comparison using anova() show that the quadratic effect of time is not sig. The individual-s plots show appreciable variation in both intercept and slope across Ss. A formal model comparison using anova() shows that the variation in slope is sig, and shd be included in any mixed models analysis of these data. 51

52 HW-5 using kv0.csv The fictitious data set, kv0.csv, is based on Dr. Katerina Velanova s FYP data that she shared with us when she was a Psych 252 student. I found this acknowledgement in an old handout: Data and analyses courtesy of Katerina Velanova, to whom Psy 252 owes a debt of gratitude [11/8/96].! Relevant R script: skv1.r 52

53 Ten subjects were run in a divided attention condition (attn = 1), and 10 different subjects were run in a focused attention condition (attn = 2). Each subject was then tested on a word task (anagrams) that had a unique solution (numsol = 1), two solutions (numsol = 2), or multiple solutions (numsol = 3). The dependent measure was a memory score (higher numbers reflect better performance). This design involves both between- and withinfactors and is probably the most useful design for psychologists. 53

54 Attention SubjID Numsol=1 Numsol=2 Numsol= Attn = Attn =

55 55

56 #Scripts to analyse kv0.csv; in skv1.r source('makerm.r') library(lme4) library(nlme) d0 = read.csv('kv0.csv', header = TRUE) con1 = cbind(c(-2,1,1), c(0,-1,1)) #Convert d0 into long form with make.rm() #Now we know how to use melt() {ggplot2}! dl1 = make.rm(constant = 1:2, repeated = 3:5, data = d0) colnames(dl1) = c('suid','atten','score','nsol') 56

57 dl1$nsol = factor(dl1$nsol, labels=c('one','two','many')) dl1$atten = factor(dl1$atten, labels=c('div','foc')) dl1$suid = factor(dl1$suid) contrasts(dl1$atten) = c(-1,1) contrasts(dl1$nsol) = cbind(lin=c(-1,0,1), quad=c(-1,2,-1)) 57

58 rs.aov = aov(score ~ atten*nsol + Error(suid), dl1) print(summary(rs.aov)) Error: suid Df Sum Sq Mean Sq F value Pr(>F) atten *** Residuals Error: Within Df Sum Sq Mean Sq F value Pr(>F) nsol ** atten:nsol ** Residuals

59 rs.lme1 = lmer(score ~ atten*nsol + (1 suid), dl1) print(summary(rs.lme1)) Linear mixed model fit by REML Formula: score ~ atten * nsol + (1 suid) Data: dl1 AIC BIC loglik deviance REMLdev Random effects: Groups Name Variance Std.Dev. suid (Intercept) Residual Number of obs: 60, groups: suid, 20 Fixed effects: Estimate Std. Error t value (Intercept) atten nsollin nsolquad atten1:nsollin atten1:nsolquad

60 rs.lme2a = lmer(score ~ atten * nsol + (1 + nsol suid), dl1) print(summary(rs.lme2a)) Linear mixed model fit by REML Formula: score ~ atten * nsol + (1 + nsol suid) Data: dl1 AIC BIC loglik deviance REMLdev Random effects: Groups Name Variance Std.Dev. Corr suid (Intercept) nsollin nsolquad Residual Number of obs: 60, groups: suid, 20 60

61 Fixed effects: Estimate Std. Error t value (Intercept) atten nsollin nsolquad atten1:nsollin atten1:nsolquad Describe the data! 61

lme4 Luke Chang Last Revised July 16, Fitting Linear Mixed Models with a Varying Intercept

lme4 Luke Chang Last Revised July 16, Fitting Linear Mixed Models with a Varying Intercept lme4 Luke Chang Last Revised July 16, 2010 1 Using lme4 1.1 Fitting Linear Mixed Models with a Varying Intercept We will now work through the same Ultimatum Game example from the regression section and

More information

Workshop 9.3a: Randomized block designs

Workshop 9.3a: Randomized block designs -1- Workshop 93a: Randomized block designs Murray Logan November 23, 16 Table of contents 1 Randomized Block (RCB) designs 1 2 Worked Examples 12 1 Randomized Block (RCB) designs 11 RCB design Simple Randomized

More information

Introduction and Background to Multilevel Analysis

Introduction and Background to Multilevel Analysis Introduction and Background to Multilevel Analysis Dr. J. Kyle Roberts Southern Methodist University Simmons School of Education and Human Development Department of Teaching and Learning Background and

More information

A brief introduction to mixed models

A brief introduction to mixed models A brief introduction to mixed models University of Gothenburg Gothenburg April 6, 2017 Outline An introduction to mixed models based on a few examples: Definition of standard mixed models. Parameter estimation.

More information

Outline. Mixed models in R using the lme4 package Part 3: Longitudinal data. Sleep deprivation data. Simple longitudinal data

Outline. Mixed models in R using the lme4 package Part 3: Longitudinal data. Sleep deprivation data. Simple longitudinal data Outline Mixed models in R using the lme4 package Part 3: Longitudinal data Douglas Bates Longitudinal data: sleepstudy A model with random effects for intercept and slope University of Wisconsin - Madison

More information

Solution pigs exercise

Solution pigs exercise Solution pigs exercise Course repeated measurements - R exercise class 2 November 24, 2017 Contents 1 Question 1: Import data 3 1.1 Data management..................................... 3 1.2 Inspection

More information

20. REML Estimation of Variance Components. Copyright c 2018 (Iowa State University) 20. Statistics / 36

20. REML Estimation of Variance Components. Copyright c 2018 (Iowa State University) 20. Statistics / 36 20. REML Estimation of Variance Components Copyright c 2018 (Iowa State University) 20. Statistics 510 1 / 36 Consider the General Linear Model y = Xβ + ɛ, where ɛ N(0, Σ) and Σ is an n n positive definite

More information

Correlated Data: Linear Mixed Models with Random Intercepts

Correlated Data: Linear Mixed Models with Random Intercepts 1 Correlated Data: Linear Mixed Models with Random Intercepts Mixed Effects Models This lecture introduces linear mixed effects models. Linear mixed models are a type of regression model, which generalise

More information

A Handbook of Statistical Analyses Using R 2nd Edition. Brian S. Everitt and Torsten Hothorn

A Handbook of Statistical Analyses Using R 2nd Edition. Brian S. Everitt and Torsten Hothorn A Handbook of Statistical Analyses Using R 2nd Edition Brian S. Everitt and Torsten Hothorn CHAPTER 12 Analysing Longitudinal Data I: Computerised Delivery of Cognitive Behavioural Therapy Beat the Blues

More information

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

MIXED MODELS FOR REPEATED (LONGITUDINAL) DATA PART 2 DAVID C. HOWELL 4/1/2010 MIXED MODELS FOR REPEATED (LONGITUDINAL) DATA PART 2 DAVID C. HOWELL 4/1/2010 Part 1 of this document can be found at http://www.uvm.edu/~dhowell/methods/supplements/mixed Models for Repeated Measures1.pdf

More information

R Output for Linear Models using functions lm(), gls() & glm()

R Output for Linear Models using functions lm(), gls() & glm() LM 04 lm(), gls() &glm() 1 R Output for Linear Models using functions lm(), gls() & glm() Different kinds of output related to linear models can be obtained in R using function lm() {stats} in the base

More information

Outline. Statistical inference for linear mixed models. One-way ANOVA in matrix-vector form

Outline. Statistical inference for linear mixed models. One-way ANOVA in matrix-vector form Outline Statistical inference for linear mixed models Rasmus Waagepetersen Department of Mathematics Aalborg University Denmark general form of linear mixed models examples of analyses using linear mixed

More information

36-463/663: Hierarchical Linear Models

36-463/663: Hierarchical Linear Models 36-463/663: Hierarchical Linear Models Lmer model selection and residuals Brian Junker 132E Baker Hall brian@stat.cmu.edu 1 Outline The London Schools Data (again!) A nice random-intercepts, random-slopes

More information

Value Added Modeling

Value Added Modeling Value Added Modeling Dr. J. Kyle Roberts Southern Methodist University Simmons School of Education and Human Development Department of Teaching and Learning Background for VAMs Recall from previous lectures

More information

ANOVA in SPSS. Hugo Quené. opleiding Taalwetenschap Universiteit Utrecht Trans 10, 3512 JK Utrecht.

ANOVA in SPSS. Hugo Quené. opleiding Taalwetenschap Universiteit Utrecht Trans 10, 3512 JK Utrecht. ANOVA in SPSS Hugo Quené hugo.quene@let.uu.nl opleiding Taalwetenschap Universiteit Utrecht Trans 10, 3512 JK Utrecht 7 Oct 2005 1 introduction In this example I ll use fictitious data, taken from http://www.ruf.rice.edu/~mickey/psyc339/notes/rmanova.html.

More information

Hierarchical Linear Models (HLM) Using R Package nlme. Interpretation. 2 = ( x 2) u 0j. e ij

Hierarchical Linear Models (HLM) Using R Package nlme. Interpretation. 2 = ( x 2) u 0j. e ij Hierarchical Linear Models (HLM) Using R Package nlme Interpretation I. The Null Model Level 1 (student level) model is mathach ij = β 0j + e ij Level 2 (school level) model is β 0j = γ 00 + u 0j Combined

More information

36-309/749 Experimental Design for Behavioral and Social Sciences. Dec 1, 2015 Lecture 11: Mixed Models (HLMs)

36-309/749 Experimental Design for Behavioral and Social Sciences. Dec 1, 2015 Lecture 11: Mixed Models (HLMs) 36-309/749 Experimental Design for Behavioral and Social Sciences Dec 1, 2015 Lecture 11: Mixed Models (HLMs) Independent Errors Assumption An error is the deviation of an individual observed outcome (DV)

More information

Repeated Measures ANOVA Multivariate ANOVA and Their Relationship to Linear Mixed Models

Repeated Measures ANOVA Multivariate ANOVA and Their Relationship to Linear Mixed Models Repeated Measures ANOVA Multivariate ANOVA and Their Relationship to Linear Mixed Models EPSY 905: Multivariate Analysis Spring 2016 Lecture #12 April 20, 2016 EPSY 905: RM ANOVA, MANOVA, and Mixed Models

More information

Introduction to Linear Mixed Models: Modeling continuous longitudinal outcomes

Introduction to Linear Mixed Models: Modeling continuous longitudinal outcomes 1/64 to : Modeling continuous longitudinal outcomes Dr Cameron Hurst cphurst@gmail.com CEU, ACRO and DAMASAC, Khon Kaen University 4 th Febuary, 2557 2/64 Some motivational datasets Before we start, I

More information

A Handbook of Statistical Analyses Using R 2nd Edition. Brian S. Everitt and Torsten Hothorn

A Handbook of Statistical Analyses Using R 2nd Edition. Brian S. Everitt and Torsten Hothorn A Handbook of Statistical Analyses Using R 2nd Edition Brian S. Everitt and Torsten Hothorn CHAPTER 12 Analysing Longitudinal Data I: Computerised Delivery of Cognitive Behavioural Therapy Beat the Blues

More information

Outline. Example and Model ANOVA table F tests Pairwise treatment comparisons with LSD Sample and subsample size determination

Outline. Example and Model ANOVA table F tests Pairwise treatment comparisons with LSD Sample and subsample size determination Outline 1 The traditional approach 2 The Mean Squares approach for the Completely randomized design (CRD) CRD and one-way ANOVA Variance components and the F test Inference about the intercept Sample vs.

More information

Sleep data, two drugs Ch13.xls

Sleep data, two drugs Ch13.xls Model Based Statistics in Biology. Part IV. The General Linear Mixed Model.. Chapter 13.3 Fixed*Random Effects (Paired t-test) ReCap. Part I (Chapters 1,2,3,4), Part II (Ch 5, 6, 7) ReCap Part III (Ch

More information

Wheel for assessing spinal block study

Wheel for assessing spinal block study Wheel for assessing spinal block study Xue Han, xue.han@vanderbilt.edu Matt Shotwell, matt.shotwell@vanderbilt.edu Department of Biostatistics Vanderbilt University December 13, 2012 Contents 1 Preliminary

More information

Homework 3 - Solution

Homework 3 - Solution STAT 526 - Spring 2011 Homework 3 - Solution Olga Vitek Each part of the problems 5 points 1. KNNL 25.17 (Note: you can choose either the restricted or the unrestricted version of the model. Please state

More information

These slides illustrate a few example R commands that can be useful for the analysis of repeated measures data.

These slides illustrate a few example R commands that can be useful for the analysis of repeated measures data. These slides illustrate a few example R commands that can be useful for the analysis of repeated measures data. We focus on the experiment designed to compare the effectiveness of three strength training

More information

Coping with Additional Sources of Variation: ANCOVA and Random Effects

Coping with Additional Sources of Variation: ANCOVA and Random Effects Coping with Additional Sources of Variation: ANCOVA and Random Effects 1/49 More Noise in Experiments & Observations Your fixed coefficients are not always so fixed Continuous variation between samples

More information

WU Weiterbildung. Linear Mixed Models

WU Weiterbildung. Linear Mixed Models Linear Mixed Effects Models WU Weiterbildung SLIDE 1 Outline 1 Estimation: ML vs. REML 2 Special Models On Two Levels Mixed ANOVA Or Random ANOVA Random Intercept Model Random Coefficients Model Intercept-and-Slopes-as-Outcomes

More information

y response variable x 1, x 2,, x k -- a set of explanatory variables

y response variable x 1, x 2,, x k -- a set of explanatory variables 11. Multiple Regression and Correlation y response variable x 1, x 2,, x k -- a set of explanatory variables In this chapter, all variables are assumed to be quantitative. Chapters 12-14 show how to incorporate

More information

over Time line for the means). Specifically, & covariances) just a fixed variance instead. PROC MIXED: to 1000 is default) list models with TYPE=VC */

over Time line for the means). Specifically, & covariances) just a fixed variance instead. PROC MIXED: to 1000 is default) list models with TYPE=VC */ CLP 944 Example 4 page 1 Within-Personn Fluctuation in Symptom Severity over Time These data come from a study of weekly fluctuation in psoriasis severity. There was no intervention and no real reason

More information

Stat 579: Generalized Linear Models and Extensions

Stat 579: Generalized Linear Models and Extensions Stat 579: Generalized Linear Models and Extensions Linear Mixed Models for Longitudinal Data Yan Lu April, 2018, week 14 1 / 64 Data structure and Model t1 t2 tn i 1st subject y 11 y 12 y 1n1 2nd subject

More information

Longitudinal Data Analysis

Longitudinal Data Analysis Longitudinal Data Analysis Mike Allerhand This document has been produced for the CCACE short course: Longitudinal Data Analysis. No part of this document may be reproduced, in any form or by any means,

More information

Mixed effects models

Mixed effects models Mixed effects models The basic theory and application in R Mitchel van Loon Research Paper Business Analytics Mixed effects models The basic theory and application in R Author: Mitchel van Loon Research

More information

Random and Mixed Effects Models - Part II

Random and Mixed Effects Models - Part II Random and Mixed Effects Models - Part II Statistics 149 Spring 2006 Copyright 2006 by Mark E. Irwin Two-Factor Random Effects Model Example: Miles per Gallon (Neter, Kutner, Nachtsheim, & Wasserman, problem

More information

Mixed models in R using the lme4 package Part 7: Generalized linear mixed models

Mixed models in R using the lme4 package Part 7: Generalized linear mixed models Mixed models in R using the lme4 package Part 7: Generalized linear mixed models Douglas Bates University of Wisconsin - Madison and R Development Core Team University of

More information

Regression: Main Ideas Setting: Quantitative outcome with a quantitative explanatory variable. Example, cont.

Regression: Main Ideas Setting: Quantitative outcome with a quantitative explanatory variable. Example, cont. TCELL 9/4/205 36-309/749 Experimental Design for Behavioral and Social Sciences Simple Regression Example Male black wheatear birds carry stones to the nest as a form of sexual display. Soler et al. wanted

More information

Topic 20: Single Factor Analysis of Variance

Topic 20: Single Factor Analysis of Variance Topic 20: Single Factor Analysis of Variance Outline Single factor Analysis of Variance One set of treatments Cell means model Factor effects model Link to linear regression using indicator explanatory

More information

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn A Handbook of Statistical Analyses Using R Brian S. Everitt and Torsten Hothorn CHAPTER 10 Analysing Longitudinal Data I: Computerised Delivery of Cognitive Behavioural Therapy Beat the Blues 10.1 Introduction

More information

PLS205 Lab 2 January 15, Laboratory Topic 3

PLS205 Lab 2 January 15, Laboratory Topic 3 PLS205 Lab 2 January 15, 2015 Laboratory Topic 3 General format of ANOVA in SAS Testing the assumption of homogeneity of variances by "/hovtest" by ANOVA of squared residuals Proc Power for ANOVA One-way

More information

Lecture 9 STK3100/4100

Lecture 9 STK3100/4100 Lecture 9 STK3100/4100 27. October 2014 Plan for lecture: 1. Linear mixed models cont. Models accounting for time dependencies (Ch. 6.1) 2. Generalized linear mixed models (GLMM, Ch. 13.1-13.3) Examples

More information

Design of Experiments. Factorial experiments require a lot of resources

Design of Experiments. Factorial experiments require a lot of resources Design of Experiments Factorial experiments require a lot of resources Sometimes real-world practical considerations require us to design experiments in specialized ways. The design of an experiment is

More information

36-309/749 Experimental Design for Behavioral and Social Sciences. Sep. 22, 2015 Lecture 4: Linear Regression

36-309/749 Experimental Design for Behavioral and Social Sciences. Sep. 22, 2015 Lecture 4: Linear Regression 36-309/749 Experimental Design for Behavioral and Social Sciences Sep. 22, 2015 Lecture 4: Linear Regression TCELL Simple Regression Example Male black wheatear birds carry stones to the nest as a form

More information

Exploring Hierarchical Linear Mixed Models

Exploring Hierarchical Linear Mixed Models Exploring Hierarchical Linear Mixed Models 1/49 Last time... A Greenhouse Experiment testing C:N Ratios Sam was testing how changing the C:N Ratio of soil affected plant leaf growth. He had 3 treatments.

More information

De-mystifying random effects models

De-mystifying random effects models De-mystifying random effects models Peter J Diggle Lecture 4, Leahurst, October 2012 Linear regression input variable x factor, covariate, explanatory variable,... output variable y response, end-point,

More information

Independent Samples ANOVA

Independent Samples ANOVA Independent Samples ANOVA In this example students were randomly assigned to one of three mnemonics (techniques for improving memory) rehearsal (the control group; simply repeat the words), visual imagery

More information

STAT3401: Advanced data analysis Week 10: Models for Clustered Longitudinal Data

STAT3401: Advanced data analysis Week 10: Models for Clustered Longitudinal Data STAT3401: Advanced data analysis Week 10: Models for Clustered Longitudinal Data Berwin Turlach School of Mathematics and Statistics Berwin.Turlach@gmail.com The University of Western Australia Models

More information

SPH 247 Statistical Analysis of Laboratory Data

SPH 247 Statistical Analysis of Laboratory Data SPH 247 Statistical Analysis of Laboratory Data March 31, 2015 SPH 247 Statistical Analysis of Laboratory Data 1 ANOVA Fixed and Random Effects We will review the analysis of variance (ANOVA) and then

More information

WELCOME! Lecture 13 Thommy Perlinger

WELCOME! Lecture 13 Thommy Perlinger Quantitative Methods II WELCOME! Lecture 13 Thommy Perlinger Parametrical tests (tests for the mean) Nature and number of variables One-way vs. two-way ANOVA One-way ANOVA Y X 1 1 One dependent variable

More information

Answer to exercise: Blood pressure lowering drugs

Answer to exercise: Blood pressure lowering drugs Answer to exercise: Blood pressure lowering drugs The data set bloodpressure.txt contains data from a cross-over trial, involving three different formulations of a drug for lowering of blood pressure:

More information

UNIVERSITY OF TORONTO. Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS. Duration - 3 hours. Aids Allowed: Calculator

UNIVERSITY OF TORONTO. Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS. Duration - 3 hours. Aids Allowed: Calculator UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS Duration - 3 hours Aids Allowed: Calculator LAST NAME: FIRST NAME: STUDENT NUMBER: There are 27 pages

More information

Mixed models in R using the lme4 package Part 2: Longitudinal data, modeling interactions

Mixed models in R using the lme4 package Part 2: Longitudinal data, modeling interactions Mixed models in R using the lme4 package Part 2: Longitudinal data, modeling interactions Douglas Bates Department of Statistics University of Wisconsin - Madison Madison January 11, 2011

More information

Lecture 22 Mixed Effects Models III Nested designs

Lecture 22 Mixed Effects Models III Nested designs Lecture 22 Mixed Effects Models III Nested designs 94 Introduction: Crossed Designs The two-factor designs considered so far involve every level of the first factor occurring with every level of the second

More information

> nrow(hmwk1) # check that the number of observations is correct [1] 36 > attach(hmwk1) # I like to attach the data to avoid the '$' addressing

> nrow(hmwk1) # check that the number of observations is correct [1] 36 > attach(hmwk1) # I like to attach the data to avoid the '$' addressing Homework #1 Key Spring 2014 Psyx 501, Montana State University Prof. Colleen F Moore Preliminary comments: The design is a 4x3 factorial between-groups. Non-athletes do aerobic training for 6, 4 or 2 weeks,

More information

ST 732, Midterm Solutions Spring 2019

ST 732, Midterm Solutions Spring 2019 ST 732, Midterm Solutions Spring 2019 Please sign the following pledge certifying that the work on this test is your own: I have neither given nor received aid on this test. Signature: Printed Name: There

More information

Explanatory Variables Must be Linear Independent...

Explanatory Variables Must be Linear Independent... Explanatory Variables Must be Linear Independent... Recall the multiple linear regression model Y j = β 0 + β 1 X 1j + β 2 X 2j + + β p X pj + ε j, i = 1,, n. is a shorthand for n linear relationships

More information

Topic 17 - Single Factor Analysis of Variance. Outline. One-way ANOVA. The Data / Notation. One way ANOVA Cell means model Factor effects model

Topic 17 - Single Factor Analysis of Variance. Outline. One-way ANOVA. The Data / Notation. One way ANOVA Cell means model Factor effects model Topic 17 - Single Factor Analysis of Variance - Fall 2013 One way ANOVA Cell means model Factor effects model Outline Topic 17 2 One-way ANOVA Response variable Y is continuous Explanatory variable is

More information

This document contains 3 sets of practice problems.

This document contains 3 sets of practice problems. P RACTICE PROBLEMS This document contains 3 sets of practice problems. Correlation: 3 problems Regression: 4 problems ANOVA: 8 problems You should print a copy of these practice problems and bring them

More information

Difference in two or more average scores in different groups

Difference in two or more average scores in different groups ANOVAs Analysis of Variance (ANOVA) Difference in two or more average scores in different groups Each participant tested once Same outcome tested in each group Simplest is one-way ANOVA (one variable as

More information

Introduction to SAS proc mixed

Introduction to SAS proc mixed Faculty of Health Sciences Introduction to SAS proc mixed Analysis of repeated measurements, 2017 Julie Forman Department of Biostatistics, University of Copenhagen Outline Data in wide and long format

More information

Mixed Model Theory, Part I

Mixed Model Theory, Part I enote 4 1 enote 4 Mixed Model Theory, Part I enote 4 INDHOLD 2 Indhold 4 Mixed Model Theory, Part I 1 4.1 Design matrix for a systematic linear model.................. 2 4.2 The mixed model.................................

More information

Introduction to SAS proc mixed

Introduction to SAS proc mixed Faculty of Health Sciences Introduction to SAS proc mixed Analysis of repeated measurements, 2017 Julie Forman Department of Biostatistics, University of Copenhagen 2 / 28 Preparing data for analysis The

More information

Non-Gaussian Response Variables

Non-Gaussian Response Variables Non-Gaussian Response Variables What is the Generalized Model Doing? The fixed effects are like the factors in a traditional analysis of variance or linear model The random effects are different A generalized

More information

STA 303H1F: Two-way Analysis of Variance Practice Problems

STA 303H1F: Two-way Analysis of Variance Practice Problems STA 303H1F: Two-way Analysis of Variance Practice Problems 1. In the Pygmalion example from lecture, why are the average scores of the platoon used as the response variable, rather than the scores of the

More information

Mixed models in R using the lme4 package Part 5: Generalized linear mixed models

Mixed models in R using the lme4 package Part 5: Generalized linear mixed models Mixed models in R using the lme4 package Part 5: Generalized linear mixed models Douglas Bates Madison January 11, 2011 Contents 1 Definition 1 2 Links 2 3 Example 7 4 Model building 9 5 Conclusions 14

More information

Mixed models in R using the lme4 package Part 5: Generalized linear mixed models

Mixed models in R using the lme4 package Part 5: Generalized linear mixed models Mixed models in R using the lme4 package Part 5: Generalized linear mixed models Douglas Bates 2011-03-16 Contents 1 Generalized Linear Mixed Models Generalized Linear Mixed Models When using linear mixed

More information

Outline. Mixed models in R using the lme4 package Part 5: Generalized linear mixed models. Parts of LMMs carried over to GLMMs

Outline. Mixed models in R using the lme4 package Part 5: Generalized linear mixed models. Parts of LMMs carried over to GLMMs Outline Mixed models in R using the lme4 package Part 5: Generalized linear mixed models Douglas Bates University of Wisconsin - Madison and R Development Core Team UseR!2009,

More information

Supplemental Materials. In the main text, we recommend graphing physiological values for individual dyad

Supplemental Materials. In the main text, we recommend graphing physiological values for individual dyad 1 Supplemental Materials Graphing Values for Individual Dyad Members over Time In the main text, we recommend graphing physiological values for individual dyad members over time to aid in the decision

More information

Introduction to the Analysis of Hierarchical and Longitudinal Data

Introduction to the Analysis of Hierarchical and Longitudinal Data Introduction to the Analysis of Hierarchical and Longitudinal Data Georges Monette, York University with Ye Sun SPIDA June 7, 2004 1 Graphical overview of selected concepts Nature of hierarchical models

More information

Notes on Maxwell & Delaney

Notes on Maxwell & Delaney Notes on Maxwell & Delaney PSY710 12 higher-order within-subject designs Chapter 11 discussed the analysis of data collected in experiments that had a single, within-subject factor. Here we extend those

More information

Outline for today. Two-way analysis of variance with random effects

Outline for today. Two-way analysis of variance with random effects Outline for today Two-way analysis of variance with random effects Rasmus Waagepetersen Department of Mathematics Aalborg University Denmark Two-way ANOVA using orthogonal projections March 4, 2018 1 /

More information

Review of Multiple Regression

Review of Multiple Regression Ronald H. Heck 1 Let s begin with a little review of multiple regression this week. Linear models [e.g., correlation, t-tests, analysis of variance (ANOVA), multiple regression, path analysis, multivariate

More information

One-Way ANOVA. Some examples of when ANOVA would be appropriate include:

One-Way ANOVA. Some examples of when ANOVA would be appropriate include: One-Way ANOVA 1. Purpose Analysis of variance (ANOVA) is used when one wishes to determine whether two or more groups (e.g., classes A, B, and C) differ on some outcome of interest (e.g., an achievement

More information

Extensions of One-Way ANOVA.

Extensions of One-Way ANOVA. Extensions of One-Way ANOVA http://www.pelagicos.net/classes_biometry_fa18.htm What do I want You to Know What are two main limitations of ANOVA? What two approaches can follow a significant ANOVA? How

More information

SAS Code for Data Manipulation: SPSS Code for Data Manipulation: STATA Code for Data Manipulation: Psyc 945 Example 1 page 1

SAS Code for Data Manipulation: SPSS Code for Data Manipulation: STATA Code for Data Manipulation: Psyc 945 Example 1 page 1 Psyc 945 Example page Example : Unconditional Models for Change in Number Match 3 Response Time (complete data, syntax, and output available for SAS, SPSS, and STATA electronically) These data come from

More information

Recall that a measure of fit is the sum of squared residuals: where. The F-test statistic may be written as:

Recall that a measure of fit is the sum of squared residuals: where. The F-test statistic may be written as: 1 Joint hypotheses The null and alternative hypotheses can usually be interpreted as a restricted model ( ) and an model ( ). In our example: Note that if the model fits significantly better than the restricted

More information

Orthogonal contrasts for a 2x2 factorial design Example p130

Orthogonal contrasts for a 2x2 factorial design Example p130 Week 9: Orthogonal comparisons for a 2x2 factorial design. The general two-factor factorial arrangement. Interaction and additivity. ANOVA summary table, tests, CIs. Planned/post-hoc comparisons for the

More information

An Introduction to Multilevel Models. PSYC 943 (930): Fundamentals of Multivariate Modeling Lecture 25: December 7, 2012

An Introduction to Multilevel Models. PSYC 943 (930): Fundamentals of Multivariate Modeling Lecture 25: December 7, 2012 An Introduction to Multilevel Models PSYC 943 (930): Fundamentals of Multivariate Modeling Lecture 25: December 7, 2012 Today s Class Concepts in Longitudinal Modeling Between-Person vs. +Within-Person

More information

13. October p. 1

13. October p. 1 Lecture 8 STK3100/4100 Linear mixed models 13. October 2014 Plan for lecture: 1. The lme function in the nlme library 2. Induced correlation structure 3. Marginal models 4. Estimation - ML and REML 5.

More information

General Linear Model (Chapter 4)

General Linear Model (Chapter 4) General Linear Model (Chapter 4) Outcome variable is considered continuous Simple linear regression Scatterplots OLS is BLUE under basic assumptions MSE estimates residual variance testing regression coefficients

More information

UNIVERSITY OF TORONTO Faculty of Arts and Science

UNIVERSITY OF TORONTO Faculty of Arts and Science UNIVERSITY OF TORONTO Faculty of Arts and Science December 2013 Final Examination STA442H1F/2101HF Methods of Applied Statistics Jerry Brunner Duration - 3 hours Aids: Calculator Model(s): Any calculator

More information

The One-Way Repeated-Measures ANOVA. (For Within-Subjects Designs)

The One-Way Repeated-Measures ANOVA. (For Within-Subjects Designs) The One-Way Repeated-Measures ANOVA (For Within-Subjects Designs) Logic of the Repeated-Measures ANOVA The repeated-measures ANOVA extends the analysis of variance to research situations using repeated-measures

More information

Introduction to Within-Person Analysis and RM ANOVA

Introduction to Within-Person Analysis and RM ANOVA Introduction to Within-Person Analysis and RM ANOVA Today s Class: From between-person to within-person ANOVAs for longitudinal data Variance model comparisons using 2 LL CLP 944: Lecture 3 1 The Two Sides

More information

Random and Mixed Effects Models - Part III

Random and Mixed Effects Models - Part III Random and Mixed Effects Models - Part III Statistics 149 Spring 2006 Copyright 2006 by Mark E. Irwin Quasi-F Tests When we get to more than two categorical factors, some times there are not nice F tests

More information

Mixed Model: Split plot with two whole-plot factors, one split-plot factor, and CRD at the whole-plot level (e.g. fancier split-plot p.

Mixed Model: Split plot with two whole-plot factors, one split-plot factor, and CRD at the whole-plot level (e.g. fancier split-plot p. STAT:5201 Applied Statistic II Mixed Model: Split plot with two whole-plot factors, one split-plot factor, and CRD at the whole-plot level (e.g. fancier split-plot p.422 OLRT) Hamster example with three

More information

STAT 510 Final Exam Spring 2015

STAT 510 Final Exam Spring 2015 STAT 510 Final Exam Spring 2015 Instructions: The is a closed-notes, closed-book exam No calculator or electronic device of any kind may be used Use nothing but a pen or pencil Please write your name and

More information

Using R formulae to test for main effects in the presence of higher-order interactions

Using R formulae to test for main effects in the presence of higher-order interactions Using R formulae to test for main effects in the presence of higher-order interactions Roger Levy arxiv:1405.2094v2 [stat.me] 15 Jan 2018 January 16, 2018 Abstract Traditional analysis of variance (ANOVA)

More information

Analysis of binary repeated measures data with R

Analysis of binary repeated measures data with R Analysis of binary repeated measures data with R Right-handed basketball players take right and left-handed shots from 3 locations in a different random order for each player. Hit or miss is recorded.

More information

One-way between-subjects ANOVA. Comparing three or more independent means

One-way between-subjects ANOVA. Comparing three or more independent means One-way between-subjects ANOVA Comparing three or more independent means Data files SpiderBG.sav Attractiveness.sav Homework: sourcesofself-esteem.sav ANOVA: A Framework Understand the basic principles

More information

2 Prediction and Analysis of Variance

2 Prediction and Analysis of Variance 2 Prediction and Analysis of Variance Reading: Chapters and 2 of Kennedy A Guide to Econometrics Achen, Christopher H. Interpreting and Using Regression (London: Sage, 982). Chapter 4 of Andy Field, Discovering

More information

Written Exam (2 hours)

Written Exam (2 hours) M. Müller Applied Analysis of Variance and Experimental Design Summer 2015 Written Exam (2 hours) General remarks: Open book exam. Switch off your mobile phone! Do not stay too long on a part where you

More information

Wolf River. Lecture 19 - ANOVA. Exploratory analysis. Wolf River - Data. Sta 111. June 11, 2014

Wolf River. Lecture 19 - ANOVA. Exploratory analysis. Wolf River - Data. Sta 111. June 11, 2014 Aldrin in the Wolf River Wolf River Lecture 19 - Sta 111 Colin Rundel June 11, 2014 The Wolf River in Tennessee flows past an abandoned site once used by the pesticide industry for dumping wastes, including

More information

COMPARING SEVERAL MEANS: ANOVA

COMPARING SEVERAL MEANS: ANOVA LAST UPDATED: November 15, 2012 COMPARING SEVERAL MEANS: ANOVA Objectives 2 Basic principles of ANOVA Equations underlying one-way ANOVA Doing a one-way ANOVA in R Following up an ANOVA: Planned contrasts/comparisons

More information

Simple, Marginal, and Interaction Effects in General Linear Models

Simple, Marginal, and Interaction Effects in General Linear Models Simple, Marginal, and Interaction Effects in General Linear Models PRE 905: Multivariate Analysis Lecture 3 Today s Class Centering and Coding Predictors Interpreting Parameters in the Model for the Means

More information

1-Way ANOVA MATH 143. Spring Department of Mathematics and Statistics Calvin College

1-Way ANOVA MATH 143. Spring Department of Mathematics and Statistics Calvin College 1-Way ANOVA MATH 143 Department of Mathematics and Statistics Calvin College Spring 2010 The basic ANOVA situation Two variables: 1 Categorical, 1 Quantitative Main Question: Do the (means of) the quantitative

More information

Factorial Independent Samples ANOVA

Factorial Independent Samples ANOVA Factorial Independent Samples ANOVA Liljenquist, Zhong and Galinsky (2010) found that people were more charitable when they were in a clean smelling room than in a neutral smelling room. Based on that

More information

Step 2: Select Analyze, Mixed Models, and Linear.

Step 2: Select Analyze, Mixed Models, and Linear. Example 1a. 20 employees were given a mood questionnaire on Monday, Wednesday and again on Friday. The data will be first be analyzed using a Covariance Pattern model. Step 1: Copy Example1.sav data file

More information

Multivariate Statistics in Ecology and Quantitative Genetics Summary

Multivariate Statistics in Ecology and Quantitative Genetics Summary Multivariate Statistics in Ecology and Quantitative Genetics Summary Dirk Metzler & Martin Hutzenthaler http://evol.bio.lmu.de/_statgen 5. August 2011 Contents Linear Models Generalized Linear Models Mixed-effects

More information

An Introduction to Path Analysis

An Introduction to Path Analysis An Introduction to Path Analysis PRE 905: Multivariate Analysis Lecture 10: April 15, 2014 PRE 905: Lecture 10 Path Analysis Today s Lecture Path analysis starting with multivariate regression then arriving

More information

Topic 18: Model Selection and Diagnostics

Topic 18: Model Selection and Diagnostics Topic 18: Model Selection and Diagnostics Variable Selection We want to choose a best model that is a subset of the available explanatory variables Two separate problems 1. How many explanatory variables

More information

Univariate analysis. Simple and Multiple Regression. Univariate analysis. Simple Regression How best to summarise the data?

Univariate analysis. Simple and Multiple Regression. Univariate analysis. Simple Regression How best to summarise the data? Univariate analysis Example - linear regression equation: y = ax + c Least squares criteria ( yobs ycalc ) = yobs ( ax + c) = minimum Simple and + = xa xc xy xa + nc = y Solve for a and c Univariate analysis

More information

Wrap-up. The General Linear Model is a special case of the Generalized Linear Model. Consequently, we can carry out any GLM as a GzLM.

Wrap-up. The General Linear Model is a special case of the Generalized Linear Model. Consequently, we can carry out any GLM as a GzLM. Model Based Statistics in Biology. Part V. The Generalized Linear Model. Analysis of Continuous Data ReCap. Part I (Chapters 1,2,3,4), Part II (Ch 5, 6, 7) ReCap Part III (Ch 9, 10, 11), Part IV (Ch13,

More information