The Wild Animal Modeling Wiki
Adding fixed effects to a model
Summary
This page illustrates how to add fixed effects, for example sex or population density, to a model and test their significance.
Table of contents
Definitions
Sample code in the following examples includes the following variablesResponse variable: Size
Fixed effects: Intercept (mu), SIZE, SEX and AGE
Random effects: Additive genetic variance
Data containing phenotypic information: phenotypicdata
Data containing pedigree data:pedigreedata
Sample Code
ASReml
To add fixed effects to a univariate model, simply modify the model specification to include any additional fixed effects before the random effects structure. The data file must have a column for each fixed covariate to be fitted. Significance of fixed effects can be tested with conditional or incremental Wald tests.ASReml analysis of size ANIMAL !P SIZE SEX !A #denotes a factor AGE #here treated as a linear effect pedigreedata.ped !skip 1 phenotypicdata.dat !skip 1 !DDF 1 !FCON #specifies method of sig testing SIZE ~ mu AGE SEX AGE.SEX !r ANIMAL
ASReml-R
model<-asreml(fixed=SIZE~1+SEX+AGE ,random=~ped(ANIMAL,var=T,init=1) ,data=phenotypicdata ,ginverse=list(ANIMAL=ainv), na.method.X="omit', na.method.Y="omit') #test significance of fixed effects using wald.asreml(model, ssType="conditional", denDF="numeric")
MCMCglmm
Addition of a fixed effect is most easily accomplished by simply adding it to the fixed effects (so far only occupied by the population mean) section of the model specification. In general, priors on fixed effects will not be necessary.
model1.2<-MCMCglmm(BWT~SEX,random=~animal, pedigree=Ped,data=Data,prior=prior1.1, nitt=65000,thin=50,burnin=15000,verbose=FALSE) posterior.mode(model1.2$Sol[,"SEX2"]) HPDinterval(model1.2$Sol[,"SEX2"],0.95) posterior.mode(model1.2$VCV) posterior.heritability1.2<-model1.2$VCV[,"animal"]/ (model1.2$VCV[,"animal"]+model1.2$VCV[,"units"]) posterior.mode(posterior.heritability1.2) HPDinterval(posterior.heritability1.2,0.95)
WOMBAT
To add fixed effects to a univariate model, simply modify the model specification in the parameter file. For example we might know (or suspect) that size is a sexually dimorphic trait and therefore include the sex of the individual in the model as a fixed effect.MODEL FIX SEX RAN ANIMAL NRM TRAIT SIZE END
WOMBAT will not provide the significance of the fixed effects in your model. However, generalised least-squares solutions for all fixed effects fitted, together with means and the number of observations for each group, can be found in
FixSolutions.out
.