
Generate Predictions from a Transformed Dataset and a Model
generate_predictions.RdThis function generates predictions and standard errors for a given transformed dataset using the provided generalized least squares (GLS) model. It also calculates pre-intervention predictions based on model coefficients.
Value
A data frame with the following additional columns:
- pre_intervention_predictions
Predicted values for the pre-intervention period, calculated using model coefficients.
- predictions
Predicted values for the entire dataset using the GLS model.
- se
Standard errors for the predictions.
Details
The function first computes pre-intervention predictions using model coefficients, specifically the intercept, `time_index`, and interaction terms. It ensures that predictions for the pre-intervention period (`level_pre_intervention == 1`) are set to `NA`. Then, it uses the `AICcmodavg::predictSE.gls()` function to calculate predictions and standard errors from the provided GLS model.
Examples
if (FALSE) { # \dontrun{
# Assuming `transformed_data` is a prepared data frame and `model` is a GLS model:
predictions_df <- generate_predictions(transformed_data, model)
head(predictions_df)
} # }