generate_predictions: Generate Predictions from a Transformed Dataset and a Model

View source: R/generate_predictions.R

generate_predictionsR Documentation

Generate Predictions from a Transformed Dataset and a Model

Description

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.

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.

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.

Examples

## Not run: 
  # Assuming `transformed_data` is a prepared data frame and `model` is a GLS model:
  predictions_df <- generate_predictions(transformed_data, model)
  head(predictions_df)

## End(Not run)


multipleITScontrol documentation built on April 4, 2026, 1:08 a.m.