predict.fit_model | R Documentation |
predict.fit_model
calculates predictions given new data
## S3 method for class 'fit_model'
predict(
x,
what = "D_i",
Lat_i,
Lon_i,
t_i,
a_i,
c_iz = rep(0, length(t_i)),
v_i = rep(0, length(t_i)),
new_covariate_data = NULL,
new_catchability_data = NULL,
do_checks = TRUE,
working_dir = getwd()
)
x |
Output from |
what |
Which output from |
t_i |
Vector of integers, providing the time (e.g., calendar year) for each observation i.
The first modeled interval will be |
a_i |
Vector containing values greater than zero, providing sampled area for each
observation i, e.g., |
c_iz |
Vector of integers ranging from 0 to the number of variables minus 1, providing the category (e.g., species, length-bin) for each observation i. This can be specified as a matrix, such that each observation is associated with multiple categories. Such specification treats samples as arising from the sum across multiple categories, e.g., to account for unlabeled multispecies data. |
v_i |
Vector of integers ranging from 0 to the number of vessels minus 1,
providing sampling category (e.g., vessel or tow) associated with overdispersed variation for each observation i
(by default |
keep_old_covariates |
Whether to add new_covariate_data to existing data. This is useful when predicting values at new locations, but does not work when predicting data are locations with existing data (because the interpolation of covariate values will conflict for existing and new covariate values), e.g., when calculating partial dependence plots for existing data. |
predict.fit_model
is designed with two purposes in mind:
If new_covariate_data=NULL
as by default, then the model uses the covariate values supplied during original model fits,
and interpolates as needed from those supplied values to new predicted locations. This then uses *exactly* the same information
as was available during model fitting.
If new_covariate_data
is supplied with new values (e.g., at locations for predictions), then these values are used in
combination with original covariate values when interpolating to new values. However, supplying new_oovariate_data
at the same Lat-Lon-Year combination as any original covariate value will delete those matches in the latter, such that originally fitted data
can be predicted using alternative values for covariates (e.g., when calculating partial dependence plots)
## Not run:
# Showing use of package pdp for partial dependence plots
pred.fun = function( object, newdata ){
predict( x=object,
Lat_i = object$data_frame$Lat_i,
Lon_i = object$data_frame$Lon_i,
t_i = object$data_frame$t_i,
a_i = object$data_frame$a_i,
what = "P1_iz",
new_covariate_data = newdata,
do_checks = FALSE )
}
library(ggplot2)
library(pdp)
Partial = partial( object = fit,
pred.var = "BOT_DEPTH",
pred.fun = pred.fun,
train = fit$covariate_data )
autoplot(Partial)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.