predict: Predict allocation suitability

Description Usage Arguments Details Value See Also Examples

Description

Estimate allocation suitability with predictive models.

Usage

1
2
3
## S3 method for class 'PredictiveModelList'
predict(object, newdata,
  data.frame = FALSE, ...)

Arguments

object

a PredictiveModelList object

newdata

data.frame containing new data

data.frame

logical indicating whether the function should return a matrix (default) or data.frame

...

additional arguments to predict methods

Details

This function is usually called from allocate to calculate land use suitability at each timestep. However, it may also be used to produce suitability maps (see examples).

Value

A matrix.

See Also

predict, allocate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Not run: 

## Plum Island Ecosystems

lu <- DiscreteLulcRasterStack(x=stack(pie[1:3]),
                              categories=c(1,2,3),
                              labels=c("Forest","Built","Other"),
                              t=c(0,6,14))

idx <- data.frame(var=c("ef_001","ef_002","ef_003"),
                  yr=c(0,0,0),
                  dynamic=c(FALSE,FALSE,FALSE))
ef <- ExpVarRasterStack(x=stack(pie[4:6]), index=idx)

part <- partition(x=lu, size=0.1, spatial=TRUE, t=0)
train.data <- getPredictiveModelInputData(lu=lu,
                                          ef=ef,
                                          cells=part[["train"]],
                                          t=0)

forest.form <- as.formula("Forest ~ ef_001 + ef_002")
built.form <- as.formula("Built ~ ef_001 + ef_002 + ef_003")
other.form <- as.formula("Other ~ ef_001 + ef_002")

forest.glm <- glm(forest.form, family=binomial, data=train.data)
built.glm <- glm(built.form, family=binomial, data=train.data)
other.glm <- glm(other.form, family=binomial, data=train.data)
glm.mods <- PredictiveModelList(list(forest.glm, built.glm, other.glm),
                                categories=lu@categories,
                                labels=lu@labels)

all.data <- as.data.frame(x=ef, cells=part[["all"]]) 
probmaps <- predict(object=glm.mods, 
                    newdata=all.data, 
                    data.frame=TRUE) 

points <- rasterToPoints(lu[[1]], spatial=TRUE) 
probmaps <- SpatialPointsDataFrame(points, probmaps) 
probmaps <- rasterize(x=probmaps, y=lu[[1]], 
                      field=names(probmaps))
plot(probmaps)


## End(Not run)

simonmoulds/lulcc2 documentation built on Dec. 23, 2021, 2:24 a.m.