BlockPredict | R Documentation |
Block prediction for objects of class glmssn-class
BlockPredict(object, predpointsID)
object |
an object of class glmssn |
predpointsID |
a valid prediction points ID |
This function operates on glmssn
objects in much the same
way as the predict
function. BlockPredict
uses the
locations in the predpointsID data set to compute the average prediction
value in the area defined by the prediction locations. These prediction
locations are used to approximate the integral over that area, so they
should be evenly spaced and dense in the area where block prediction is
desired. The user needs to create these prediction locations and include
them in the SSN object prior to fitting the model with glmssn.
A data.frame with one row and two columns. The first column, BlockPredEst, is the average prediction value, and the second column, BlockPredSE, is the standard error of the block prediction.
Jay Ver Hoef support@SpatialStreamNetworks.com
Ver Hoef, J. M.. Peterson, E. E. and Theobald, D. (2006) Spatial statistical models that use flow and stream distance. Environmental and Ecological Statistics 13, 449-464. DOI: 10.1007/s10651-006-0022-8.
## Not run: library(SSN) #for examples, copy MiddleFork04.ssn directory to R's temporary directory copyLSN2temp() # NOT RUN # Create a SpatialStreamNetork object that also contains prediction sites #mf04p <- importSSN(paste0(tempdir(),'/MiddleFork04.ssn'), # predpts = "pred1km", o.write = TRUE) #use mf04p SpatialStreamNetwork object, already created data(mf04p) #for examples only, make sure mf04p has the correct path #if you use importSSN(), path will be correct mf04p <- updatePath(mf04p, paste0(tempdir(),'/MiddleFork04.ssn')) # Not needed: already added, # add densely gridded prediction points for two stream segments # mf04p <- importPredpts(mf04p, "Knapp", "ssn") # mf04p <- importPredpts(mf04p, "CapeHorn", "ssn") names(mf04p) # see densely gridded prediction points on stream plot(mf04p, PredPointsID = "Knapp") # you could fit the model #fitSpBk <- glmssn(Summer_mn ~ ELEV_DEM + netID, # ssn.object = mf04p, EstMeth = "REML", family = "Gaussian", # CorModels = c("Exponential.tailup","Exponential.taildown", # "Exponential.Euclid"), addfunccol = "afvArea") # or load the pre-fit model data(modelFits) fitSpBk$ssn.object <- updatePath(fitSpBk$ssn.object, paste0(tempdir(),'/MiddleFork04.ssn')) # one-at-a-time predictions for CapeHorn stream ## NOTE: need the amongpreds distance matrices for block prediction createDistMat(mf04p, predpts = "CapeHorn", o.write = TRUE, amongpreds = TRUE) fitSpPredC <- predict(fitSpBk, "CapeHorn") # plot densely gridded prediction points on stream plot(fitSpPredC, "Summer_mn") # block prediction for CapeHorn stream BlockPredict(fitSpBk, "CapeHorn") ## Another example # one-at-a-time predictions for Knapp stream createDistMat(mf04p, predpts = "Knapp", o.write = TRUE, amongpreds = TRUE) fitSpPredK <- predict(fitSpBk, "Knapp") # plot densely gridded prediction points on stream plot(fitSpPredK, "Summer_mn") # block prediction for Knapp stream BlockPredict(fitSpBk, "Knapp") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.