Title: Statistics
1Statisticsrevisited
2Standard statistics revisited
Bolker
3Standard statistics revisitedSimple Variance
Structures
4Standard statistics revisited
5General linear models
- Predictions are a linear function of a set of
parameters. - Includes
- Linear models
- ANOVA
- ANCOVA
- Assumptions
- Normally distributed, independent errors
- Constant variance
- Not to be confused with generalized linear
models! - Distinction between factors and covariates.
6Linear regression
Standard R code gtlm.reglt-lm(YX) gtsummary(lm) gta
nova(lm.reg)
Likelihood R code gtlmfunlt-function(a, b,
sigma) Y.predlt-abx -sum(dnorm(Y,
meanY.pred, sdsigma, logTRUE))
7Analysis of variance (ANOVA)
Standard R code gtlm.onewayaovlt-lm(Yf1) gtsummary
(lm.aov) gtanova(lm.aov) will give you an ANOVA
table
Likelihood R code gtaovfunlt-function(a11, a12,
sigma) Y.predlt-c(a11,a12) -sum(dnorm(DBH,
meanY.pred, sdsigma, logTRUE))
8Analysis of covariance (ANCOVA)
Standard R code gtlm.anclt-lm(YfX) gtsummary(lm.a
nc) gtstr(summary(lm.anc))
Likelihood R code gtancfunlt-function(a11, a12,
slope1, slope2, sigma) Y.predlt-c(a11,a12)f
c(slope1, slope2)fX -sum(dnorm(Y,
meanY.pred, sdsigma, logTRUE))
9Standard statistics revisited
10Nonlinearlity Non-linear least squares
Uses numerical methods similar to those use in
likelihood
Standard R code gtnls(yaxb,
startlist(a1,b1) gtsummary(nls) gtstr(summary(lns
))
Likelihood R code gtnlsfunlt-function(a, b,
sigma) Y.predlt-axb -sum(dnorm(Y,
meanY.pred, sdsigma, logTRUE))
11Standard statistics revisited
12Generalized linear models
- Assumptions
- Non-normal distributed errors ( but still
independent and only certain kinds of
non-normality) - Non-linear relationships are allowed but only if
they have a linearizing transformation (the link
function). - Linearizing transformations
- Non-normal distributed errors ( but still
independent and only certain kinds of
non-normality). These include the exponential
family and are typically used with a specific
linearizing function. - Poisson loglink
- Binomial logit transfomation
- Gamma inverse Gaussian
- Fit by iteratively reweighed least square
methods estimate variance associated with each
point for each estimate of parameter(s). - Not to be confused with general linear models!
13GML Poisson regression
Standard R code gtglm.poislt-glm(YX,
familypoisson) gtsummary(gml.pois)
Likelihood R code gtpoisregfunfunction(a,b) Y.
predlt-exp(abX) -sum(dpois(Y, lambdaY.pred,
logTRUE))
14GML Logistic regression
Standard R code gtglm2lt-glm(yx,
familybinomial) gtsummary(gml2)
Likelihood R code gtlogregfunfunction(a,b,N) p
.predlt-exp(a bX))/(1exp(a
bX)) -sum(dbinom(Y, sizeN, probp.pred,
logTRUE))
15Standard statistics revisited
16Generalized (non)linear least-squares
modelsVariance changes with a covariate or
among groups
Standard R code gtglslt-gls(y1,weightsvarIdent(f
orm1f) gtsummary(gls)
Likelihood R code gtvardifffunfunction(a,
sd1,sd2) sdvallt-c(sd1,sd2)f -sum(dbinom(Y,
meana, sdsdval, logTRUE)
17Standard statistics revisited Complex Variance
Structures
18Complex error structures
- Error structures are not independent
- Complex likelihood functions
- Includes
- Time series analysis
- Spatial correlation
- Repeated measures analysis
Variance-covariance matrix
x
x
Vector of means (pred)
Vector of data
19Complex error structures
(x
x
Increasing variance
General case
Independent
20Complex error structures
- Variance/covariance matrix is symmetric so we
need to specify at most n(n-1)/2 parameters. - V/C matrix must also be positive definite
(logical), this translates to having a positive
eigenvalue or positive diagonal values. - Select elements of matrix that define the error
structure and ensure positive definite. - In this example, correlation drops off with the
number ofd steps between sites.c
21Complex error structures An exampleSpatially-cor
related errors
R code gtrho0.5 gtmmatrix(nrow5,
ncol5) gtmlt-rho(abs(row(m)-col(m))
OR gtmabs(row(m)-col(m))1rho mvliklt-functi
on(a,b, rho) pred.radabdbh nlength(radius
) mdiag(n) generates diag matrix of n rows, n
columns mabs(row(m)-col(m))1rho
-dmvnorm(radius, pred.rad, Sigmam, logTRUE)
mle(mvlik, startlist(a0.5, b3,rho0.5),
method"L-BFGS-B", lower0.001)
22Mixed models Generalized linear mixed models
(GLMM)
- Samples within a group (block, site) are equally
correlated with each other. - Fixed effects effects of covariates
- Random effects block, site etc.
- GLMMs are generalized linear models with random
effects
23Complex variance structures
- So how do you incorporate all potential sources
of variance? - Block effects
- Individual effects (repeated measures includes
both individual and temporal correlation) - Measurement vs. process error
- ..
24Bolker