The function gives the time-varying coefficients based on a fitted coxtv
or coxtp
subject.
Users can specify the time points to calculate the time-varying coefficients.
get.tvcoef(fit, time)
model from coxtv
or coxtp
.
time points to calculate the time-varying coefficients. If NULL
, the observed event times for fitting the model will be used.
A matrix of the time-varying coefficients. The dimension is the length of time
by nvars
, where nvars
is the number
of covariates in the fitted mode.
Each row represents the time-varying coefficients at the corresponding time.
z <- ExampleData$z
time <- ExampleData$time
event <- ExampleData$event
fit <- coxtv(event = event, z = z, time = time, degree = 2)
#> Iter 1: Obj fun = -3.2996719; Stopping crit = 1.0000000e+00;
#> Iter 2: Obj fun = -3.2930435; Stopping crit = 2.1457947e-02;
#> Iter 3: Obj fun = -3.2930197; Stopping crit = 7.7063460e-05;
#> Iter 4: Obj fun = -3.2930197; Stopping crit = 1.4676554e-09;
#> Algorithm converged after 4 iterations!
coef <- get.tvcoef(fit)