YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Makingpredictions

Page 2: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Sofar...Build,check&selectmodelsfordetectability

Build,check&selectmodelsforabundance

Makesomeecologicalinferenceaboutsmooths

Whataboutpredictions?

Page 3: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Let'stalkaboutmaps

Page 4: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Whatdoesamapmean?Grids!

Cellsareabundanceestimate

“snapshot”

Sumcellstogetabundance

Sumasubset?

Page 5: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Goingbacktotheformula(Count)Model:

Predictions(index ):

Needto“fill-in”valuesfor , and .

= exp[ + s( ) + s( )] +nj Aj p̂j β0 yj Depthj ϵj

r

= exp[ + s( ) + s( )]nr Ar β0 yr Depthr

Ar yr Depthr

Page 6: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

PredictingWiththesevaluescanusepredictinRpredict(model, newdata=data)

Page 7: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Predictiondata x y Depth SST NPP DistToCAS EKE off.set126 547984.6 788254 153.5983 8.8812 1462.521 11788.974 0.0074 1e+08127 557984.6 788254 552.3107 9.2078 1465.410 5697.248 0.0144 1e+08258 527984.6 778254 96.8199 9.6341 1429.432 13722.626 0.0024 1e+08259 537984.6 778254 138.2376 9.6650 1424.862 9720.671 0.0027 1e+08260 547984.6 778254 505.1439 9.7905 1379.351 8018.690 0.0101 1e+08261 557984.6 778254 1317.5952 9.9523 1348.544 3775.462 0.0193 1e+08 LinkID Nhat_tw126 1 0.01417657127 2 0.05123483258 3 0.01118858259 4 0.01277096260 5 0.04180434261 6 0.45935801

Page 8: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

AquickwordaboutrastersWehavetalkedaboutrastersabit

InR,thedata.frameiskingFortunatelyas.data.frameexistsMakeour“stack”andthenconverttodata.frame

Page 9: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Predictors

Page 10: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

MakingapredictionAddanothercolumntothepredictiondata

Plottingtheneasier(inR)

predgrid$Nhat_tw <- predict(dsm_all_tw_rm, predgrid)

Page 11: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Mapsofpredictionsp <- ggplot(predgrid) + geom_tile(aes(x=x, y=y, fill=Nhat_tw)) + scale_fill_viridis() + coord_equal()print(p)

Page 12: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

TotalabundanceEachcellhasanabundance,sumtogettotal

sum(predict(dsm_all_tw_rm, predgrid))

[1] 2491.864

Page 13: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

SubsettingRsubsettingletsyoucalculate“interesting”estimates:

# how many sperm whales at depths less than 2500m?sum(predgrid$Nhat_tw[predgrid$Depth < 2500])

[1] 1006.272

# how many sperm whales North of 0?sum(predgrid$Nhat_tw[predgrid$x>0])

[1] 1383.742

Page 14: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Extrapolation

Page 15: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Whatdowemeanbyextrapolation?Predictingatvaluesoutsidethoseobserved

Whatdoes“outside”mean?

betweentransects?

outside“surveyarea”?

Page 16: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

TemporalextrapolationModelsaretemporallyimplicit(mostly)

Dynamicvariableschangeseasonally

Migrationcanbeanissue

Needtounderstandwhatthepredictionsare

Page 17: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

ExtrapolationExtrapolationisfraughtwithissues

Wanttobepredicting“insidetherug”

Ingeneral,trynottodoit!

(Thinkaboutvariancetoo!)

Page 18: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

RecapUsingpredictGetting“overall”abundance

Subsetting

PlottinginR

Extrapolation(anditsdangers)

Page 19: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Estimatingvariance

Page 20: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

NowwecanmakepredictionsNowwearedangerous.

Page 21: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Predictionsareuselesswithoutuncertainty

Page 22: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Wheredoesuncertaintycomefrom?

Page 23: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

SourcesofuncertaintyDetectionfunction

GAMparameters

Page 24: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Let'sthinkaboutsmoothsfirst

Page 25: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

UncertaintyinsmoothsDashedlinesare+/-2standarderrors

Howdowetranslateto ?N̂

Page 26: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

BacktobasesBeforeweexpressedsmoothsas:

Theorytellsusthat:

where isabitcomplicated

(derivedfromthesmoothermatrix)

s(x) = (x)∑Kk=1 βkbk

β ∼ N( , )β̂ Vβ

Page 27: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Predictionstopredictionvariance(roughly)

“map”dataontofittedvalues

“map”predictionmatrixtopredictions

Here needtotakesmoothsintoaccount

pre-/post-multiplyby to“transformvariance”

linkscale,needtodoanothertransformforresponse

βXp

Xp

Xp

⇒ XTp VβXp

Page 28: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Addingindetectionfunctions

Page 29: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

GAM+detectionfunctionuncertainty(Gettingalittlefast-and-loosewiththemathematics)

( ) ≈ (GAM) +CV2 N̂ CV2

(detectionfunction)CV2

Page 30: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Notthatsimple...AssumesdetectionfunctionandGAMareindependent

Maybethisisokay?

(Probablynottrue?)

Page 31: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

VariancepropagationIncludethedetectabilityasterminGAM

Randomeffect,meanzero,varianceofdetectionfunction

Uncertainty“propagated”throughthemodel

Detailsinbibliography(toomuchtodetailhere)

Underdevelopment

(Cancoverinspecialtopic)

Page 32: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Thatseemedcomplicated...

Page 33: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Rtotherescue

Page 34: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

InR...Functionsindsmtodothis

dsm.var.gamassumesspatialmodelanddetectionfunctionareindependent

dsm.var.proppropagatesuncertaintyfromdetectionfunctiontospatialmodel

onlyworksforcountmodels(moreorless)

Page 35: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

VarianceofabundanceUsingdsm.var.gam

dsm_tw_var_ind <- dsm.var.gam(dsm_all_tw_rm, predgrid, off.set=predgrid$off.set)summary(dsm_tw_var_ind)

Summary of uncertainty in a density surface model calculated analytically for GAM, with delta method

Approximate asymptotic confidence interval: 2.5% Mean 97.5% 1539.018 2491.864 4034.643 (Using log-Normal approximation)

Point estimate : 2491.864 CV of detection function : 0.2113123 CV from GAM : 0.1329 Total standard error : 622.0389 Total coefficient of variation : 0.2496

Page 36: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

VarianceofabundanceUsingdsm.var.prop

dsm_tw_var <- dsm.var.prop(dsm_all_tw_rm, predgrid, off.set=predgrid$off.set)summary(dsm_tw_var)

Summary of uncertainty in a density surface model calculated by variance propagation.

Probability of detection in fitted model and variance model Fitted.model Fitted.model.se Refitted.model1 0.3624567 0.07659373 0.3624567

Approximate asymptotic confidence interval: 2.5% Mean 97.5% 1556.898 2458.634 3882.646 (Using log-Normal approximation)

Point estimate : 2458.634 Standard error : 581.0379 Coefficient of variation : 0.2363

Page 37: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Plotting-dataprocessingCalculateuncertaintyper-cell

dsm.var.*thinkspredgridisone“region”Needtosplitdataintocells(usingsplit())(Couldbearbitrarysetsofcells,seeexercises)

Needwidthandheightofcellsforplotting

Page 38: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Plotting(code)predgrid$width <- predgrid$height <- 10*1000predgrid_split <- split(predgrid, 1:nrow(predgrid))head(predgrid_split,3)

$`1` x y Depth SST NPP DistToCAS EKE off.set126 547984.6 788254 153.5983 8.8812 1462.521 11788.97 0.0074 1e+08 LinkID Nhat_tw height width126 1 0.01417657 10000 10000

$`2` x y Depth SST NPP DistToCAS EKE off.set127 557984.6 788254 552.3107 9.2078 1465.41 5697.248 0.0144 1e+08 LinkID Nhat_tw height width127 2 0.05123483 10000 10000

$`3` x y Depth SST NPP DistToCAS EKE off.set258 527984.6 778254 96.8199 9.6341 1429.432 13722.63 0.0024 1e+08 LinkID Nhat_tw height width258 3 0.01118858 10000 10000

dsm_tw_var_map <- dsm.var.prop(dsm_all_tw_rm, predgrid_split, off.set=predgrid$off.set)

Page 39: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

CVplotp <- plot(dsm_tw_var_map, observations=FALSE, plot=FALSE) + coord_equal() + scale_fill_viridis()print(p)

Page 40: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

InterpretingCVplotsPlottingcoefficientofvariation

Standardisestandarddeviationbymean

(percell)

Canbeusefultooverplotsurveyeffort

CV = se( )/N̂ N̂

Page 41: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Effortoverplotted

Page 42: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

BigCVsHereCVsare“wellbehaved”

Notalwaysthecase(hugeCVspossible)

Thesecanbeapaintoplot

Usecut()inRtomakecategoricalvariable

e.g.c(seq(0,1, len=100), 2:4, Inf)orsomesuch

Page 43: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

RecapHowdoesuncertaintyariseinaDSM?

Estimatevarianceofabundanceestimate

Mapcoefficientofvariation

Page 44: Making predictions - GitHub · Predictions to prediction variance (roughly) “map” data onto fitted values “map” prediction matrix to predictions Here need to take smooths

Let'strythat!


Related Documents