Skip to contents

This 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.

Usage

generate_predictions(transformed_data, model)

Arguments

transformed_data

A data frame containing the transformed dataset. Output from `transform_data()`.

model

A GLS model object used to make predictions. The model should include coefficients used to generate pre-intervention predictions.

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)
} # }