View source: R/generate_predictions.R
| generate_predictions | R Documentation |
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.
generate_predictions(transformed_data, model)
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. |
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.
A data frame with the following additional columns:
Predicted values for the pre-intervention period, calculated using model coefficients.
Predicted values for the entire dataset using the GLS model.
Standard errors for the predictions.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.