epinowcast
Loading...
Searching...
No Matches
hazard.stan
Go to the documentation of this file.
1
15
vector
prob_to_hazard
(vector p) {
16
int
l = num_elements(p);
17
// h[i] = p[i] / (1 - sum(p[1:(i-1)])), with h[l] = 1 by definition
18
return
append_row(
19
p[1:(l-1)] .* inv(1 - append_row(0.0, cumulative_sum(p[1:(l-2)]))),
20
1.0
21
);
22
}
23
41
vector
cumulative_converse_log_hazard
(vector h,
int
l) {
42
// Shift hazards by one time unit: [0, h[1], h[2], ..., h[l-1]]
43
// Then compute cumulative sum of log(1 - h_shifted) for survival probability
44
return
cumulative_sum(log1m(append_row(0.0, h[1:(l-1)])));
45
}
46
69
vector
hazard_to_log_prob
(vector h,
int
l) {
70
return
(log(h) +
cumulative_converse_log_hazard
(h, l));
71
}
prob_to_hazard
vector prob_to_hazard(vector p)
Definition
hazard.stan:15
cumulative_converse_log_hazard
vector cumulative_converse_log_hazard(vector h, int l)
Definition
hazard.stan:41
hazard_to_log_prob
vector hazard_to_log_prob(vector h, int l)
Definition
hazard.stan:69
functions
hazard.stan
Generated by
1.12.0