Asset panel concat
Join panels along the observation axis
vcat joins AssetPanels of one universe, for example the panel of 2024 and the panel of
- It joins the values and the observed mask of each field of the panel, and both universe masks.
The parts must hold the same assets, the same fields in the same order, and the same schema for each field. The schema of a categorical field is its levels. The schema of a tensor field is its axis name, its labels and its groups. A part that differs throws an error that names the part and the field.
Base.vcat — Method
vcat(a::AssetPanel, bs::AssetPanel...) -> AssetPanelConcatenates Asset Panels of one universe along the observation axis, a first.
Each part holds the same Panel Fields, and the function joins the values, the observed mask and the placeholder mask of each field, the active mask and the estimation mask. It refuses a part whose schema differs from the schema of a. A static panel has no observation axis and states the same values at each observation, so the concatenation of equal static panels is a.
The panel holds no asset names and no timestamps. The ReturnsResult or the PricesResult that holds the panel holds them, and each of the two refuses a repeated timestamp. To join two blocks of returns data, concatenate X, ts and each other series with vcat, concatenate the panels with this function, and make a new ReturnsResult.
The element types promote as vcat promotes them: a Float32 part and a Float64 part give a Float64 field. A field that each part lifts from the same static array stays a lazy RepeatedLeading array, and masks that are true everywhere stay an AllTrueMask.
Algorithm
The method that Julia selects is the algorithm.
- Check each part
bagainstawithassert_panel_concat: the shape, the asset count, the Panel Field names in their order, and the schema of each field. ais static: check that each Panel Field of each part holds the data of its field ina, withpanel_field_isequal. A field with no observed mask equals a field whose observed mask istrueeverywhere, and a field with no placeholder mask equals a field whose placeholder mask isfalseeverywhere, as in step 3. Returna.ais time-varying: concatenate the parts of each Panel Field withpanel_field_vcat, and the parts of each mask withpanel_mask_vcat. Make theAssetPanelof the results.
Arguments
a: The panel of the first observations.bs: The panels of the later observations, in the order of their observations.
Validation
- Every part is static, or every part is time-varying. An
ArgumentErroris thrown otherwise. - Every part has the asset count of
a. ADimensionMismatchis thrown otherwise. - Every part has the Panel Field names of
a, in the same order. AnArgumentErroris thrown otherwise. - Each Panel Field has the kind of its field in
a, and a categorical field has the same levels. A tensor field has the same axis name, labels and groups. AnArgumentErroris thrown otherwise. - A static part equals
a. AnArgumentErroris thrown otherwise.
Returns
pnl::AssetPanel: The panel of the observations ofa, followed by the observations of each part ofbs.
Examples
julia> a = AssetPanel(; pf = [NumericPanelField(; name = "mcap", vals = [1.0 2.0; 3.0 4.0])], amsk = trues(2, 2), emsk = trues(2, 2));julia> b = AssetPanel(; pf = [NumericPanelField(; name = "mcap", vals = [5.0 6.0])], amsk = trues(1, 2), emsk = [true false]);julia> pnl = vcat(a, b);julia> panel_field(pnl, "mcap").vals3×2 Matrix{Float64}: 1.0 2.0 3.0 4.0 5.0 6.0julia> pnl.emsk3×2 BitMatrix: 1 1 1 1 1 0Related
AssetPanelpanel_field_isequalport_opt_view: the inverse operation, which takes observations out of a panel.vcat_observations