Join the newly launched Discord
community for real-time discussions, peer support, and direct interaction with the Meridian team!
meridian.model.knots.get_knot_info
Stay organized with collections
Save and categorize content based on your preferences.
Returns the number of knots, knot locations, and weights.
meridian
.
model
.
knots
.
get_knot_info
(
n_times
:
int
,
knots
:
(
int
|
Collection
[
int
]
|
None
),
enable_aks
:
bool
=
False
,
data
:
(
meridian
.
data
.
input_data
.
InputData
|
None
)
=
None
,
is_national
:
bool
=
False
)
->
meridian
.
model
.
knots
.
KnotInfo
The number of time periods in the data.
An optional integer or a collection of integers indicating the knots
used to estimate time effects. When knots
is a collection of integers,
the knot locations are provided by that collection. Zero corresponds to a
knot at the first time period, one corresponds to a knot at the second
time, ..., and (n_times - 1)
corresponds to a knot at the last time
period. When knots
is an integer, then there are knots with locations
equally spaced across the time periods (including knots at zero and (n_times - 1)
. When knots
is 1
, there is a single common regression
coefficient used for all time periods. If knots
is None
, then the
numbers of knots used is equal to the number of time periods. This is
equivalent to each time period having its own regression coefficient.
A boolean indicating whether to use the Automatic Knot Selection
algorithm to select optimal number of knots for running the model instead
of the default 1 for national and n_times for non-national models.
An Optional InputData object used by the Automatic Knot Selection
algorithm to calculate optimal number of knots from the provided Input
Data.
A boolean indicator whether to adapt the knot information for a
national model.
A KnotInfo that contains the number of knots, the location of knots, and the
weights used to multiply with the knot values to get time-varying
coefficients.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-05 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-05 UTC."],[[["\u003cp\u003eThis function, \u003ccode\u003eget_knot_info\u003c/code\u003e, determines the necessary information about knots used for estimating time effects, including the number of knots, their locations, and associated weights.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003en_times\u003c/code\u003e argument specifies the total number of time periods in the dataset that the knots refer to.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eknots\u003c/code\u003e argument can be an integer, a collection of integers, or \u003ccode\u003eNone\u003c/code\u003e, controlling the number and placement of knots across the time periods; when it is an integer, they will be equally spaced, when a collection, it directly indicates their locations, when \u003ccode\u003eNone\u003c/code\u003e, each time period gets its own coefficient.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eis_national\u003c/code\u003e boolean argument indicates if the knot information will need to be adjusted for a national model.\u003c/p\u003e\n"],["\u003cp\u003eThe function ultimately returns a \u003ccode\u003eKnotInfo\u003c/code\u003e object, which encapsulates the calculated knot count, locations, and the corresponding weights.\u003c/p\u003e\n"]]],["The function `get_knot_info` determines knot-related information for time-effect estimation. It takes `n_times` (number of time periods), optional `knots` (locations or count), and `is_national` (national model indicator) as input. If `knots` is a collection, these are used directly as locations; if an integer, knots are equally spaced; `None` equals each time period having its own knot. The output includes the total number of knots, their locations, and associated weights.\n"],null,["\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/google/meridian/blob/v1.2.0/meridian/model/knots.py#L152-L235) |\n\nReturns the number of knots, knot locations, and weights. \n\n meridian.model.knots.get_knot_info(\n n_times: int,\n knots: (int | Collection[int] | None),\n enable_aks: bool = False,\n data: (../../../meridian/data/input_data/InputData.md | None) = None,\n is_national: bool = False\n ) -\u003e ../../../meridian/model/knots/KnotInfo.md\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `n_times` | The number of time periods in the data. |\n| `knots` | An optional integer or a collection of integers indicating the knots used to estimate time effects. When `knots` is a collection of integers, the knot locations are provided by that collection. Zero corresponds to a knot at the first time period, one corresponds to a knot at the second time, ..., and `(n_times - 1)` corresponds to a knot at the last time period. When `knots` is an integer, then there are knots with locations equally spaced across the time periods (including knots at zero and `(n_times - 1)`. When `knots` is `1`, there is a single common regression coefficient used for all time periods. If `knots` is `None`, then the numbers of knots used is equal to the number of time periods. This is equivalent to each time period having its own regression coefficient. |\n| `enable_aks` | A boolean indicating whether to use the Automatic Knot Selection algorithm to select optimal number of knots for running the model instead of the default 1 for national and n_times for non-national models. |\n| `data` | An Optional InputData object used by the Automatic Knot Selection algorithm to calculate optimal number of knots from the provided Input Data. |\n| `is_national` | A boolean indicator whether to adapt the knot information for a national model. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A KnotInfo that contains the number of knots, the location of knots, and the weights used to multiply with the knot values to get time-varying coefficients. ||\n\n\u003cbr /\u003e"]]