Summary
There are no dedicated conversion methods between multivariate and univariate forecast types. Some conversions already work via default methods, but others need new methods.
What already works
Promoting univariate to multivariate works via the .default constructors:
as_forecast_multivariate_sample(forecast_sample_obj, joint_across = "location") works because the .default method calls as_forecast_generic() which strips/rebuilds the object, then ensure_mv_grouping() adds .mv_group_id.
as_forecast_multivariate_point(forecast_point_obj, joint_across = "location") works the same way.
Existing univariate conversions for reference:
as_forecast_quantile.forecast_sample converts samples to quantiles
as_forecast_point.forecast_quantile extracts the median as a point forecast
No new methods needed for the promotion cases.
What needs new methods
as_forecast_multivariate_point.forecast_multivariate_sample
Summarise samples to multivariate point predictions (e.g. via mean or median per forecast unit). Should follow the as_forecast_point.forecast_quantile pattern:
- Assert input is valid multivariate sample
- Aggregate
predicted values per forecast unit (configurable summary function, default mean)
- Remove
sample_id column
- Preserve
.mv_group_id and grouping structure
- Return
forecast_multivariate_point object
as_forecast_point.forecast_multivariate_sample
Same as above but also drops the multivariate grouping:
- Aggregate
predicted values per forecast unit
- Remove
sample_id and .mv_group_id columns
- Return
forecast_point object
Could be implemented as: convert to multivariate point first, then drop grouping. Or directly in one step.
as_forecast_point.forecast_multivariate_point
Downgrade by stripping multivariate grouping:
- Remove
.mv_group_id column
- Return
forecast_point object
as_forecast_quantile.forecast_multivariate_sample
Analogous to the existing as_forecast_quantile.forecast_sample but drops the multivariate grouping. Could delegate to the existing sample-to-quantile method after stripping .mv_group_id.
References
This was opened by a bot. Please ping @seabbs for any questions.
Summary
There are no dedicated conversion methods between multivariate and univariate forecast types. Some conversions already work via default methods, but others need new methods.
What already works
Promoting univariate to multivariate works via the
.defaultconstructors:as_forecast_multivariate_sample(forecast_sample_obj, joint_across = "location")works because the.defaultmethod callsas_forecast_generic()which strips/rebuilds the object, thenensure_mv_grouping()adds.mv_group_id.as_forecast_multivariate_point(forecast_point_obj, joint_across = "location")works the same way.Existing univariate conversions for reference:
as_forecast_quantile.forecast_sampleconverts samples to quantilesas_forecast_point.forecast_quantileextracts the median as a point forecastNo new methods needed for the promotion cases.
What needs new methods
as_forecast_multivariate_point.forecast_multivariate_sampleSummarise samples to multivariate point predictions (e.g. via mean or median per forecast unit). Should follow the
as_forecast_point.forecast_quantilepattern:predictedvalues per forecast unit (configurable summary function, defaultmean)sample_idcolumn.mv_group_idand grouping structureforecast_multivariate_pointobjectas_forecast_point.forecast_multivariate_sampleSame as above but also drops the multivariate grouping:
predictedvalues per forecast unitsample_idand.mv_group_idcolumnsforecast_pointobjectCould be implemented as: convert to multivariate point first, then drop grouping. Or directly in one step.
as_forecast_point.forecast_multivariate_pointDowngrade by stripping multivariate grouping:
.mv_group_idcolumnforecast_pointobjectas_forecast_quantile.forecast_multivariate_sampleAnalogous to the existing
as_forecast_quantile.forecast_samplebut drops the multivariate grouping. Could delegate to the existing sample-to-quantile method after stripping.mv_group_id.References
as_forecast_point.forecast_quantileinR/class-forecast-quantile.Rfor the conversion patternas_forecast_quantile.forecast_sampleinR/class-forecast-sample.Rfor the sample-to-quantile patternThis was opened by a bot. Please ping @seabbs for any questions.