Cross-Basis Construction

Construct cross-basis matrices for Distributed Lag Non-Linear Models in R.

Updated Mar 7, 2026
One-click install
npx skills add https://github.com/ntluong95/agent-skills-statistics --skill cross-basis-construction
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: Cross-Basis Construction
Source: https://github.com/ntluong95/agent-skills-statistics/tree/main/skills/dlnm/crossbasis
Command: npx skills add https://github.com/ntluong95/agent-skills-statistics --skill cross-basis-construction

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies the complex process of constructing bi-dimensional cross-basis matrices, which are essential for modeling both exposure-response and lag-response relationships simultaneously in Distributed Lag Non-Linear Models (DLNMs).

Core Features & Use Cases

  • Flexible Basis Functions: Supports various basis functions like natural cubic splines (ns), B-splines (bs), and penalized splines (ps) for both exposure and lag dimensions.
  • Optimized Knot Placement: Provides guidance on placing knots effectively for both exposure (e.g., percentiles) and lag (e.g., log scale) dimensions to avoid overfitting.
  • Key Argument Guidance: Explains crucial arguments like lag, argvar, and arglag for accurate model specification.
  • Use Case: When analyzing the impact of daily temperature on mortality, use this Skill to define how temperature variations and their effects over subsequent days are modeled.

Quick Start

Construct a cross-basis matrix for a daily temperature exposure with a 21-day lag, using natural cubic splines for both dimensions with appropriate knot placements.

Frequently Asked Questions about Cross-Basis Construction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a cross-basis matrix for a distributed lag non-linear model in R?▼

To build a cross-basis matrix for a distributed lag non-linear model, use the dlnm::crossbasis() function in R to define basis functions and knot placements for both exposure and lag dimensions simultaneously.

When should I use cross-basis functions for exposure-lag-response relationships?▼

Use cross-basis functions for exposure-lag-response relationships when you need to model the bi-dimensional impact of a predictor, such as daily temperature, and its effects across subsequent days simultaneously.

What is the best way to place knots for natural cubic splines in DLNM?▼

The best way to place knots for natural cubic splines in DLNM is using percentiles for the exposure dimension and a log scale for the lag dimension, which helps avoid overfitting the bi-dimensional relationship.

Can I use penalized splines or B-splines for both exposure and lag dimensions in dlnm?▼

Yes, you can use penalized splines or B-splines for both exposure and lag dimensions in dlnm, as the function supports various basis types including ns, bs, and ps for flexible model specification.

How do I specify the lag period and arguments for a DLNM cross-basis?▼

To specify the lag period and arguments for a DLNM cross-basis, define the lag length and use the argvar and arglag parameters to pass specific basis function and knot placement guidance for accurate modeling.