A step of the survnnr_native implementation. No other function in the package calls it. See the file header for the source the module follows. the source it follows.
Usage
morie_survnnr_fit(
X,
times,
events,
hidden = c(),
activation = "tanh",
l2 = 0,
lr = 0.1,
n_epochs = 400,
seed = 0,
tol = 1e-10
)Arguments
- X
A vector; its length is taken and its elements indexed.
- times
A vector; its length is taken.
- events
A vector; its length is taken.
A vector; its length is taken. Defaults to
c().- activation
Passed to
morie_survnnr_forward. Defaults to"tanh".- l2
Numeric; combined arithmetically in the body. Defaults to
0.- lr
Numeric; combined arithmetically in the body. Defaults to
0.1.- n_epochs
Coerced to integer by the body, with
as.integer. Defaults to400.- seed
Passed to
.survnnr_init. Defaults to0.- tol
Passed to
<. Defaults to1e-10.
Value
A list with estimate, W, b, activation,
hidden, l2, loss_history, risk, centred_risk,
coefficients, times, events, epochs, ties,
scale_note, method.
Examples
set.seed(1); n <- 40
X <- lapply(seq_len(n), function(i) rnorm(3)); tm <- rexp(n); ev <- rbinom(n, 1, .7)
fit <- morie_survnnr_fit(X, tm, ev, hidden = c(4L), n_epochs = 20)
fit$risk
#> [1] -0.32640504 -0.60752765 -0.31352296 -0.78335959 1.06495740 0.32448003
#> [7] -0.06223376 -0.50703415 -0.09953326 0.54851534 0.10621854 0.73067078
#> [13] 0.41448858 -0.07688100 -0.63732879 0.11705313 -0.45815199 -0.42508112
#> [19] -1.05628547 -0.30963818 0.17095295 0.54771506 -0.54025078 -0.61397448
#> [25] 0.07432222 0.27620593 0.17481015 -0.66410312 0.13833775 -0.13422592
#> [31] -0.31938237 -0.77603448 -0.08786969 0.48366342 -0.25361076 -0.11744949
#> [37] -0.96878400 -0.75150303 0.16627580 -0.37677602
fit$epochs >= 2
#> [1] TRUE
