\(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\R}[1]{ {\rm #1} }\)
csv.covariate_spline¶
View page sourceCreate Spline Functions For Covariates¶
Prototype¶
# at_cascade.csv.covariate_spline
def covariate_spline(covariate_table , node_set) :
assert type( covariate_table ) == list
assert type( covariate_table[0] ) == dict
assert type( node_set ) == set
# ...
assert type(age_grid) == list
assert type(time_grid) == list
assert type(spline_cov) == dict
return age_grid, time_grid, spline_cov
covariate_table¶
Is a list of dict representation of a
covariate.csv file.
All of the keys in this dict are covariate names except for
node_name , sex, age , time and omega .
All of the columns have been converted to type float except
for node_name and sex which have type str .
node_set¶
This is the set of nodes in node.csv
age_grid¶
This is a sorted list of float containing the age values that are present for each node_name and sex.
time_grid¶
This is a sorted list of float containing the time values that are present for each node_name and sex.
spline_cov¶
This is a dict of dict of dict. Let spline be defined by
- for node_name in covariate_table
- for sex in covariate_table
- for cov_name a covariate name or omega
spline = spline_cov[node_name][sex][cov_name]
Then spline is the corresponding function of age and time; i.e.,
z = spline(age, time)
sets z to the value of the covariate or omega for the specified age, time, node_name, and sex where age, time, and z are floats.
Side Effects¶
This routine aborts with an assert if covariate.csv does not have the same rectangular grid in age and time for each (node_name, sex) pair.