Learn R Programming

SSN (version 1.1.7)

splitPredictions: Split Prediction Sets in a SpatialStreamNetwork Object

Description

The splitPrediction function is used to split prediction sets in a SpatialStreamNetwork object into smaller prediction sets. It returns a SpatialStreamNetwork object with additional prediction sets based on equal interval splits, a factor value stored within the prediction set, or a logical expression.

Usage

splitPredictions(ssn, predpointsID, chunksof, by, subset, new.id)

Arguments

ssn
predpointsID
a character string representing the prediction points ID
chunksof
numeric value representing the size of the new prediction sets. The existing prediction set is split equally to produce multiple prediction sets of this size
by
character string representing the column name of type factor or integer that the split will be based on
subset
logical expression indicating which elements or rows to keep; missing values are taken as false
new.id
character string representing the new prediction points ID. This value is only specified when the subset method is used

Value

The splitPredictions function returns an object of class SpatialStreamNetwork that contains one or more new prediction sets. Shapefiles of the new prediction sets are written to the .ssn directory designated in the ssn@path slot. Distances matrices for the predicted and observed locations are also calculated and stored in the .ssn directory.

Details

Three methods have been provided to split prediction sets: chunksof, by, and subset. The chunksof method is used to split the existing prediction set into multiple equally-sized prediction sets. The by method is used if the prediction set is to be split into multiple new prediction sets based on an existing column of type factor or integer. The subset method is used to create one new prediction setbased on a logical expression. When the subset method is used, the prediction points ID may be specified using the new.id argument. Note that, only one method may be specified when the splitPredictions function is called.

See Also

SpatialStreamNetwork, subsetSSN

Examples

Run this code
library(SSN)

# for examples, copy MiddleFork04.ssn directory to R's temporary directory
copyLSN2temp()

## Import the SpatialStreamNetwork object
mf04 <- importSSN(paste0(tempdir(),'/MiddleFork04.ssn'),
  predpts = "pred1km")

# Split using the chunksof method
split1 <- splitPredictions(mf04, "pred1km", chunksof = 100)
summary(split1)

## Split using the by method
split2 <- splitPredictions(mf04, "pred1km", by = "netID")
summary(split2)

## Split using the subset method
split3 <- splitPredictions(mf04, "pred1km", subset = netID == 1,
     new.id="netID-1")
summary(split3)

## Split the predictions after creating a glmssn object
mf04.glmssn <- glmssn(Summer_mn ~ ELEV_DEM + SLOPE, mf04,
    CorModels = c("Exponential.tailup", "Exponential.taildown",
    "Exponential.Euclid"),addfunccol = "afvArea")
mf04.glmssn$ssn.object <- splitPredictions(mf04.glmssn$ssn.object, "pred1km",
    subset = netID == 1, new.id="netID-1")
pred.split<- predict(mf04.glmssn, "netID-1")
plot(pred.split)

Run the code above in your browser using DataLab