Post on 01-Jan-2016
GENERAL LINEAR MODELS
Oneway ANOVA, GLM Univariate (n-way ANOVA,
ANCOVA)
BASICS Dependent variable is continuous Independent variables are nominal,
categorical (factor, CLASS) or continuous (covariate)
Are the group means of the dependent variable different across groups defined by the independents
Main effects, interactions and nested effects
Often used for testing hypotheses with experimental data
BASICSFactor A (industry)Level 1 (manufact)
Factor A (industry)Level 2 (trade)
Factor B (size)Level 1 (small)
Cell
Factor B (size)Level 2 (medium)
Factor B (size)Level 3 (large)
3 X 2 full factorial design (full: each cell has observations)
Balanced design: each cell has equal number of observations
ASSUMPTIONS Enough observations in each group? (n
>20) Independence of observations Similarity of variance-covariance matrices
(no problem if largest group variance < 1.5*smallest group variance, 4* if balanced design)
Normality Linearity No outlier-observations
STEPS OF INTERPRETATION
Model significance? F-test and R square Welch, if unequal group variances
(this can be tested using Levene or Brown-Forsythe test)
Significance of effects? (F-test and partial eta squared)
Which group differences are significant? Post hoc or contrast tests
What are the group differences like? Estimated marginal means for groups
Oneway ANOVA A continuous dependent variable (y) and
one categorical independent variable (x), with min. 3 categories, k= number of categories
assumptions: y normally distributed with equal variance in each x category
H0: mean of y is the same in all x categories
Variance of y is divided into two components: within groups (error) and between groups (model, treatment)
Test statistic= between mean square / within mean square follows F-distribution with k-1, n-k degrees of freedom
F-test can be replaced by Welch if variances are unequal
Oneway ANOVA If the F test is significant, you
can use post hoc tests for pairwise comparison of means across the groups
Alternatively (in experiments) you can define contrasts ex ante
Contrast Coefficients
1 0 -1 0
,5 ,5 -1 0
Contrast1
2
vaalea tumma punainen kalju
hiusten väri
SAS: oneway ANOVA
SAS: oneway ANOVA
BF or Levene, H0: group variances are equal
Use this instead of F if variances are not equal
SAS: oneway ANOVA
Post hoc -tests
SAS: oneway ANOVA
SAS: oneway ANOVA
MODEL FIT
Source DFSum of
Squares Mean Square F Value Pr > F
Model 3 298.3992640 99.4664213 13.41 <.0001
Error 68 504.4139305 7.4178519
Corrected Total 71 802.8131944
R-Square Coeff Var Root MSE deathrate Mean
0.371692 34.10981 2.723573 7.984722
Class Level Information
Class Levels Values
class_popgrowth 4 1 2 3 4
EQUALITY OF VARIANCESLevene's Test for Homogeneity of deathrate VarianceANOVA of Squared Deviations from Group Means
Source DFSum of
SquaresMean
Square F Value Pr > F
class_popgrowth 3 3004.3 1001.4 4.23 0.0084
Error 68 16110.6 236.9
Welch's ANOVA for deathrate
Source DF F Value Pr > F
class_popgrowth 3.0000 13.00 <.0001
Error 18.9519
GROUP MEANS
Level ofclass_popgrowth N
deathrate
Mean Std Dev
1 27 10.5666667 3.01457996
2 22 6.9272727 1.60064922
3 17 5.9705882 1.87941637
4 6 5.9500000 5.61809576
POST HOC TESTComparisons significant at the 0.05 level are indicated by ***.
class_popgrowthComparison
DifferenceBetween
MeansSimultaneous 95% Confidence Limits
1 - 2 3.6394 1.5135 5.7653 ***
1 - 3 4.5961 2.3044 6.8877 ***
1 - 4 4.6167 1.2760 7.9573 ***
2 - 1 -3.6394 -5.7653 -1.5135 ***
2 - 3 0.9567 -1.4335 3.3468
2 - 4 0.9773 -2.4317 4.3862
3 - 1 -4.5961 -6.8877 -2.3044 ***
3 - 2 -0.9567 -3.3468 1.4335
3 - 4 0.0206 -3.4942 3.5353
4 - 1 -4.6167 -7.9573 -1.2760 ***
4 - 2 -0.9773 -4.3862 2.4317
4 - 3 -0.0206 -3.5353 3.4942
BOXPLOTS
Multiway ANOVA, GLM A continuous dependent variable y, two or
more categorical independent variables (factorial design)
ANCOVA, if there are continuous independents (covariates)
main effects and interaction effects can be modeled
fixed factor, if all groups are present and random factor, if only some groups are randomly represented in the data
Eta squared = SSK/SST expresses how many % of the variance in y is explained by x (not in EG! SAS code: model y = x1 x2 / ss3 EFFECTSIZE;)
INTERACTION EFFECT Synergy of two factors, the effect
of one factor is different in the groups of the other factor
Crossing effect = interaction effect Ordinal (lines in means plot have
different slopes, but do not cross) Disordinal (lines cross in the
means plot)
NO INTERACTION
Size and industry both have a significant main effect
No interaction, homogeneity of slopes
mean of profitability
0
10
20
30
40
small medium large
manufact
trade
INTERACTIONS
Ordinal interaction (the effect of size is stronger in manufacturing than in trade)
Dis-ordinal interaction (the effect of size has a different sign in manufacturing and trade)
mean of profitability
0
10
20
30
40
50
small medium large
manufact
trade
mean of profitability
0
10
20
30
40
50
small medium large
manufact
trade
NESTED EFFECTS Nested effect B(A) ”B nested within A” size (industry): the effect of size is
estimated separately for each industry group
Difference between nested and interaction effect is that the main effect of B (size) is not included
The slope of B (size) is different in each category of A (industry)
ESTIMATED GROUP MEANS
Estimated marginal means or LS (least squares) means
Predicted group means are calculated using the estimated model coefficients
The effects of other independent variables are controlled for
Is not equal to the group means from the sample
SUM OF SQUARES
Type I SS does not control for the effects of other independent variables which are specified later into the model
Type II SS controls for the effects of all other independents
Types III and IV SS are better in unbalanced designs, IV if there are empty cells
POST HOC TESTS Multiple comparison procedures, mean
separation tests The idea is to avoid the risk of Type I error
which results from doing many pairwise tests, each at 5% risk level
E.g. Bonferroni, Scheffe, Sidak,… Tukey-Kramer is most powerful H0: equal group means -> rejection means
that group means are not equal, but failure to reject does not necessarily mean that they are equal (small sample size -> low power -> failure to reject the null)
ANCOVA The model includes a covariate (= continuous
independent variable, often one whose effect you want to control for)
Regress y on the covariate -> then ANOVA with factors explaining the residual
The relationship between covariate and y must be linear, and the slope is assumed to be the same at all factor levels
The covariate and factor should not be too much related to each other
Do not include too many covariates, max 0.1*n – (k-1)
SAS: analyze – ANOVA – linear models
Effects to be estimated
Interaction here, first select both variables, then click Cross
Sums of squares
Other options, defaults ok
Post hoc-tests
Plots
SAS - codePROC GLM DATA=libname.datafilename
PLOTS(ONLY)=DIAGNOSTICS(UNPACK)PLOTS(ONLY)=RESIDUALSPLOTS(ONLY)=INTPLOT
;CLASS Elinkaari Perheyr;MODEL growthorient= ln_hlo Elinkaari Perheyr Elinkaari*Perheyr
/SS3SOLUTIONSINGULAR=1E-07EFFECTSIZE
;LSMEANS Elinkaari Perheyr Elinkaari*Perheyr / PDIFF ADJUST=BON ;RUN;
QUIT;
Model significance and fitClass Level Information
Class Levels ValuesElinkaari phase 3 2 3 4Perheyr family 2 0 1
Number of Observations Read 181Number of Observations Used 132
Source DFSum of
Squares Mean Square F Value Pr > FModel 6 13.03085542 2.17180924 3.59 0.0026Error 125 75.69810081 0.60558481Corrected Total 131 88.72895623
R-Square Coeff Var Root MSE growthorient Mean0.146861 21.79382 0.778193 3.570707
Significance of predictors
Source DF Type III SS Mean Square F Value Pr > Fln_hlo employees 1 2.88693851 2.88693851 4.77 0.0309Elinkaari phase 2 9.52176337 4.76088169 7.86 0.0006Perheyr family 1 0.28960870 0.28960870 0.48 0.4905Elinkaari*Perheyr
Phase*Family
2 1.99071120 0.99535560 1.64 0.1974
EFFECT SIZE OF PREDICTORS
Source
Total Variation Accounted For Partial Variation Accounted For
Semipartial Eta-Square
Semipartial Omega-Square
Conservative95% Confidence Li
mitsPartial Eta-
Square
Partial Omega-Square
95% Confidence Limits
ln_hlo 0.0325 0.0255 0.0000 0.1112 0.0367 0.0277 0.0000
0.1158
Elinkaari 0.1073 0.0930 0.0219 0.2056 0.1117 0.0942 0.0225
0.2073
Perheyr 0.0033 -0.0035 0.0000 0.0488 0.0038 -0.0040 0.0000
0.0503
Elinkaari*Perheyr
0.0224 0.0087 0.0000 0.0842 0.0256 0.0097 0.0000
0.0887
Parameter estimates
Parameter EstimateStandard
Error t Value Pr > |t|Intercept 3.196306815 B 0.49826714 6.41 <.0001ln_hlo employees 0.161079578 0.07377500 2.18 0.0309Elinkaari 2 growth 0.372704251 B 0.49030119 0.76 0.4486Elinkaari 3 mature -0.041166136 B 0.46224369 -0.09 0.9292Elinkaari 4 decline 0.000000000 B . . .Perheyr 0 non family -0.862973482 B 0.92404272 -0.93 0.3522Perheyr 1 family 0.000000000 B . . .Elinkaari*Perheyr 2 0 1.250588328 B 0.98491805 1.27 0.2065Elinkaari*Perheyr 2 1 0.000000000 B . . .Elinkaari*Perheyr 3 0 0.654885600 B 0.94241380 0.69 0.4884Elinkaari*Perheyr 3 1 0.000000000 B . . .Elinkaari*Perheyr 4 0 0.000000000 B . . .Elinkaari*Perheyr 4 1 0.000000000 B . . .
38
Prediction for 6 cells Elinkaari=2 & perheyr=0 (growth phase, non family)
Growth = 3.20 + 0.16*ln_hlo + 0.37 – 0.86 + 1.25= 3.96 + 0.16*ln_hlo
Elinkaari=3 & perheyr=0 (mature phase, non family)Growth = 3.20 + 0.16*ln_hlo – 0.04 – 0.86 + 0.65
= 2.95 + 0.16*ln_hlo Elinkaari=4 & perheyr=0 (decline phase, non family)
Growth = 3.20 + 0.16*ln_hlo + 0.00 – 0.86 + 0.00= 2.34 + 0.16*ln_hlo
Elinkaari=2 & perheyr=1 (growth phase, family)Growth = 3.20 + 0.16*ln_hlo + 0.37 + 0.00 + 0.00
= 3.57 + 0.16*ln_hlo Elinkaari=3 & perheyr=1 (mature phase, family)
Growth = 3.20 + 0.16*ln_hlo - 0.04 + 0.00 + 0.00= 3.16 + 0.16*ln_hlo
Elinkaari=4 & perheyr=1 (decline phase, family)Growth = 3.20 + 0.16*ln_hlo + 0.00 + 0.00 + 0.00
= 3.20 + 0.16*ln_hlo
39
Parameter estimates
The X'X matrix has been found to be singular, and a generalized inverse was used to solve the normal equations. Terms whose estimates are followed by the letter 'B' are not uniquely estimable.
This warning always occurs if you have categorical independent variables in the model, SAS can however estimate the coefficients
Homoskedasticity
Outlier diagnostics
Residual distribution
Model fit
Influence diagnostics
Residual vs. covariate
Significance of group differences, main effects
Elinkaari
phasegrowthorient
LSMEANLSMEAN
Number2 growth 4.14643211 13 mature 3.43471035 24 decline 3.14843369 3
Least Squares Means for effect ElinkaariPr > |t| for H0: LSMean(i)=LSMean(j)
Dependent Variable: growthorienti/j 1 2 31 0.0006 0.12252 0.0006 1.00003 0.1225 1.0000
Perheyr
Familygrowthorient
LSMEAN
H0:LSMean1=LSMean2
Pr > |t|0 3.46261763 0.4905
1 3.69043314
Significance of group differences, interaction
Phase Familygrowthorient
LSMEANLSMEAN
Number2 growth 0 4.34023953 12 1 3.95262468 23 mature 0 3.33066641 33 1 3.53875430 44 decline 0 2.71694695 54 1 3.57992043 6
Least Squares Means for effect Elinkaari*PerheyrPr > |t| for H0: LSMean(i)=LSMean(j)
Dependent Variable: growthorienti/j 1 2 3 4 5 61 1.000
00.016
10.105
20.847
41.0000
2 1.0000
0.1040
0.8177
1.0000
1.0000
3 0.0161
0.1040
1.0000
1.0000
1.0000
4 0.1052
0.8177
1.0000
1.0000
1.0000
5 0.8474
1.0000
1.0000
1.0000
1.0000
6 1.0000
1.0000
1.0000
1.0000
1.0000
Non-family firms in growth phase differ from non-family firms in mature phase
REPORTING GLM Model fit: F + df + p and R Square Nature and significance of effects:
parameter estimates B+s.e.+t+p and F+p
estimated group means (means plot)
post hoc test results
Means plot
kasvuvaihe vakiintunut loppumassa1
1.5
2
2.5
3
3.5
4
4.5
5
perheyrei-perheyr
kasvuhakuis
uus
Employees at its mean value (20)