Predictions from a Fitted SIR Model
predict.sir.RdGenerates predictions from a fitted SIR model for the training data or for new data. Predictions can be on the link scale (linear predictor) or the response scale (expected counts, probabilities, or means).
Arguments
- object
A fitted
sirobject fromsir.- newdata
Optional named list with components
W(3D or 4D array),X(3D array), and/orZ(3D or 4D array) for counterfactual prediction. Dimensions must match the original fit. Any component not supplied is taken from the original fit. If NULL (default), returns predictions for the training data. Note: unlike many R predict methods,newdatais a list of arrays, not a data frame.- type
Character string:
"link"for linear predictor (eta) or"response"for expected values on the original scale. Default is"response".- ...
Additional arguments (unused).
Details
For scenario (counterfactual) analysis, supply modified arrays in
newdata. For example, to see how the network would change if a
covariate increased by one unit, pass the modified Z array while keeping
W and X from the original fit.
Examples
if (FALSE) { # \dontrun{
model <- sir(Y, W, X, Z = Z, family = "poisson")
# In-sample fitted values
pred <- predict(model)
# Scenario: what if Z increases by 1 unit?
Z_shift <- Z + 1
pred_scenario <- predict(model, newdata = list(Z = Z_shift))
# Compare mean predictions
mean(pred, na.rm = TRUE)
mean(pred_scenario, na.rm = TRUE)
} # }