Fancystuff
DavidLMiller
Awordofwarning
Awayfromtheexponential
family
Modelling"counts"
Countsandcount-likethings
Responseisacount(notalwaysinteger)
Often,it'smostlyzero(that'scomplicated)
Couldalsobecatchperuniteffort,biomassetc
Flexiblemean-variancerelationship
Tweediedistribution
Var(count) = ϕ(count)
q
Commondistributionsare
sub-cases:
q = 1 ⇒Poisson
q = 2 ⇒Gamma
q = 3 ⇒Normal
Weareinterestedin
1<q<2
(here
q = 1.2, 1.3, … , 1.9 )
tw()
Negativebinomial
Var(count) =
2
(count) + κ(count)
Estimateκ
Isquadraticrelationshipa
“strong”assumption?
SimilartoPoisson:
Var(count) = (count)
nb()
Zero-inflateddistributions
Modelstheprobabilityofzerosseperatelyfrommean
countsgiventhatyou'veobservedmorethanzeroata
location.
ziPandziplss(forlocation-scalemodels)
zeroinflationisassessedconditionalonthemodel
iswhatyouhavezeroinflationorjustlotsofzeros?
don'tjustjumpstraighttozeroinflation
Otherdistributions
TheBetadistribution
Proportions;continuous,
boundedat0&1
Betadistributionis
convenientchoice
Twostrictlypositive
shapeparameters,α &β
Hassupporton
x ∈ (0, 1)
Densityatx = 0&x = 1
is∞ ,fudge
betar()familyinmgcv
t-distribution
Modelscontinuousdataw/longertailsthannormal
Farlesssensitivetooutliers
Hasoneextraparameter:df.
biggerdf:tdistapproachesnormal
Orderedcategoricaldata
Dataarecategories,have
order
e.g.:conservationstatus:
“leastconcern”,
“vulnerable”,
“endangered”,“extinct”
fitsalinearlatentmodel
usingcovariates,w/
thresholdforeachlevel
see?ocat
forunorderedcategories,
see?multinom
Otherdistributions(quickly)
Multivariatenormal(family = "mvn")
Multivariateresponse,eachhasdifferentsmooth,
allowcorrelation
Coxproportionalhazards("family = cox.ph")
Censoreddata:timeuntilaneventoccurs,orthestudy
wasstopped
Gaussianlocation-scalemodels("family = gaulss")
mean(“location”)andvariance(“scale”)assmooths
Allofthesedistributionshavequirks!Readthemanual!
?familyand?family.mgcv
Theendofthedistributionzoo
Fancysmoothers
Cyclicsmooths
cyclicsmooths(bs="cc")
whatifsmoothsneedto“mat
ensureupto2ndderivsmatc
needtobecarefulwithendp
?
smooth.construct.cc.s
"Simple"randomeffects
Earlier:“penaltiescanbethoughtofasvariance
components”
Wecanthinkofrandomeffectsassplinestoo!
inmgcvwecansetbs="re"
thesearesimple,non-nestedrandomeffects
Complicatedrandomeffects
gamm—usesspline-randomeffectsequiv.
castsplinesasrandomeffects,fitusingnlme
randomeffectsaresparse,splinesaredense
oftenmodellingproblemswithcomplexmodels
random=...argumentfornestingetc
modelhasa$gamand$lmeparts
Correlationstuctures
again,needtousegamm
correlation=...givesstructure
corAR1,corARMA,corCAR1etc
tendtobehardtofitforSDMs
Fancy2Dsmoothing
Funny-shapedregions
Soapfilmsmoother
(bs="so")
Modeltakesboundary
intoaccountby
construction
Needtospecifya
boundaryandinternal
knots
see?soap
Spatialmodelsusingareas
Markovrandomfields
(bs="mrf")
Needtospecifypolygons
oradjacencymatrix
Notnecessarilythat
usefulformarinework?
see?mrf
Verygeneralmodelling
mgcvcanfitanythingyoucanwriteas(onthelinkscale):
y = Xβ
s.t. ∑ βSj β
j
ifyoucanwriteyourlikelihoodinaquadraticform,itcanbe
partofamodelinmgcv
?paraPen
Modelsforlargedatasets
bamforbigadditivemodels
canhandlesimplecorrelationstructures
parallel(blockQRdecompositions)
fast!(stillexperimental)
Wood,Goude,Shaw(2015)
Fancysummary
Youcandoalotofthingsinmgcv
Startsmall,workuptocomplexmodels
Sometimesconvergenceisagainstyou
Thereisalotofinformationinthemanual
Okay,that'senough
converged.yt/mgcv-workshop
© Copyright 2026 Paperzz