-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of github.com:PredictiveEcology/fireSenseU…
…tils into development
- Loading branch information
Showing
2 changed files
with
18 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
#' Predictions from ignition model | ||
#' | ||
#' @param model formula of fitted model (`sim$fireSense_IgnitionFitted[["formula"]][-2]`) | ||
#' @param model the model used to fit ingition data - must have a predict method | ||
#' @param data data for prediction | ||
#' @param coefs model coefficients (`sim$fireSense_IgnitionFitted$coef`) | ||
#' @param rescaleFactor spatial rescaling factor when predicted and fitted data are at different scales. | ||
#' Calculaed as: (predResolution/fitResolution)^2 | ||
#' Calculated as: (predResolution/fitResolution)^2 | ||
#' @param lambdaRescaleFactor If the data for fitting has been sampled for pseudo-absences, | ||
#' this imposes a new baseline probability of fire occurrences, hence predictions need to be adjusted. | ||
#' If the original fire prob. is (total no. fires)/(total no. fires + total no. absences), and the fire | ||
#' probability imposed by sampling is (total no. fires)/(total no. fires + no. sampled pseudo-absences), to | ||
#' adjust predicted values, one needs to multiply them by (total no. fires + no. sampled pseudo-absences/(total no. fires + total no. absences) | ||
#' @param linkinv family link function (`sim$fireSense_IgnitionFitted$family$linkinv`) | ||
#' | ||
#' @return vector of predicted values. | ||
#' | ||
#' @export | ||
|
||
predictIgnition <- function(model, data, coefs, rescaleFactor, lambdaRescaleFactor, linkinv) { | ||
mm <- model.matrix(model, data) | ||
pred <- mm %*% coefs | ||
pred <- drop(pred) | ||
pred <- linkinv(pred) | ||
pred <- pred * rescaleFactor | ||
pred * lambdaRescaleFactor | ||
predictIgnition <- function(model, data, rescaleFactor, lambdaRescaleFactor) { | ||
|
||
ignitions <- predict(model, newdata = data) | ||
ignitions <- ignitions * rescaleFactor * lambdaRescaleFactor | ||
return(ignitions) | ||
|
||
# mm <- model.matrix(model, data) | ||
# pred <- mm %*% coefs | ||
# pred <- drop(pred) | ||
# pred <- linkinv(pred) | ||
# pred <- pred * rescaleFactor | ||
# pred * lambdaRescaleFactor | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.