Skip to main content

LaggedFrame

Struct LaggedFrame 

Source
pub struct LaggedFrame { /* private fields */ }
Expand description

Pre-materialized lagged frame: one contiguous column per (variable, lag).

Layout is column-major over slots variable_slot * (max_lag + 1) + lag. Per-column ValidityBitmaps record whether each effective row’s source sample passed analysis-mask ∩ column-validity (under the build options).

Implementations§

Source§

impl LaggedFrame

Source

pub fn from_series( data: &TimeSeriesData, variables: &[VariableId], max_lag: u32, policy: &KernelPolicy, ) -> Result<Self, DataError>

Materialize all lags 0..=max_lag for variables from data.

Uses LaggedFrameOptions::default (Honor analysis mask + CompleteCase).

§Errors

Empty variable list, invalid lag map, missing/non-float64 columns, or ErrorOnMissing when a source column has nulls.

Source

pub fn from_series_with_reference( data: &TimeSeriesData, variables: &[VariableId], max_lag: u32, reference: ReferencePointPolicy, policy: &KernelPolicy, ) -> Result<Self, DataError>

Materialize lagged columns under an explicit reference-point policy.

§Errors

Empty variable list, invalid lag map, missing/non-float64 columns, or ErrorOnMissing when a source column has nulls.

Source

pub fn from_series_with_options( data: &TimeSeriesData, variables: &[VariableId], max_lag: u32, reference: ReferencePointPolicy, options: LaggedFrameOptions, policy: &KernelPolicy, ) -> Result<Self, DataError>

Materialize lagged columns with explicit mask / missingness policies.

§Errors

Empty variable list, invalid lag map, missing/non-float64 columns, or ErrorOnMissing when a source column has nulls.

Source

pub fn variables(&self) -> &[VariableId]

Variables in slot order.

Source

pub const fn max_lag(&self) -> u32

Maximum lag materialised (inclusive).

Source

pub const fn n_effective(&self) -> usize

Effective aligned sample count.

Source

pub fn ncols(&self) -> usize

Number of columns (n_vars * (max_lag + 1)).

Source

pub fn is_fully_valid(&self) -> bool

Whether every lagged column is fully valid (fast path for unmasked series).

Source

pub fn values_bytes(&self) -> u64

Byte size of the gathered value buffer.

Source

pub fn column_index(&self, variable: VariableId, lag: Lag) -> Option<usize>

Dense column index for (variable, lag), or None if unknown / out of range.

Source

pub fn column(&self, idx: usize) -> &[f64]

Borrow column at dense index.

§Panics

Panics if idx >= ncols.

Source

pub fn column_valid(&self, idx: usize) -> &ValidityBitmap

Borrow per-row validity for lagged column idx.

§Panics

Panics if idx >= ncols.

Source

pub fn keep_mask_for_columns( &self, cols: &[usize], ) -> Result<Vec<bool>, DataError>

Keep-mask for a set of lagged column indexes: AND of their validity bitmaps.

§Errors

Empty column list or out-of-range index.

Source

pub fn retain_effective(&self, keep: &[bool]) -> Result<Self, DataError>

Compact to effective rows where keep[i] is true.

Used for regime-masked CI: the full series is materialized first so lag alignment is correct, then only windows wholly inside a regime are retained.

§Errors

Length mismatch or empty keep set.

Source

pub fn stack(frames: &[Self]) -> Result<Self, DataError>

Vertically stack frames that share the same variable list and max lag.

Used for multi-environment pooling without lag windows crossing env boundaries.

§Errors

Empty input, or mismatched variables / max_lag across frames.

Source

pub fn append_constant_lag_columns( &self, columns: &[(VariableId, Vec<f64>)], ) -> Result<Self, DataError>

Append variables whose values are constant across lags (space/time dummies).

Each entry is (variable_id, contemporaneous column) of length n_effective. The same values are copied into every lag slot so MCI can index any lag; link assumptions should still forbid lagged parents of space/time dummies. Appended columns are marked all-valid.

§Errors

Length mismatch, duplicate variable id, or empty column list.

Trait Implementations§

Source§

impl Clone for LaggedFrame

Source§

fn clone(&self) -> LaggedFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LaggedFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ForeignBufferOwner for T
where T: Send + Sync + Debug + 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.