cumbasehaz: Cumulative Baseline Hazard of a gamlasso object

Description Usage Arguments Value See Also Examples

View source: R/cumbasehaz.R

Description

This is only used when with family="cox"

Usage

1
cumbasehaz(object)

Arguments

object

fitted model object of the class gamlasso as produced by gamlasso

Value

This function returns the cumulative baseline hazard function of a gamlasso object if fitted using family = "cox". More specifically, cumbasehaz(object) is the cumulative baseline hazard function corresponding to the linear predictor predict(object).

See Also

gamlasso

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library(plsmselect)

data(simData)

## Fit Cox gamlasso model using the formula approach:
## (L1-penalty both on X terms and smooth terms (bs="ts"))
simData$X = model.matrix(~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10, data=simData)[,-1]

cfit = gamlasso(time ~ X +
                  s(z1, bs="ts", k=5) +
                  s(z2, bs="ts", k=5) +
                  s(z3, bs="ts", k=5) +
                  s(z4, bs="ts", k=5),
                data = simData,
                family = "cox",
                weights="status",
                seed=1)

## Obtain and plot predicted cumulative baseline hazard:
H0.pred <- cumbasehaz(cfit)

time.seq <- seq(0, 60, by=1)
plot(time.seq, H0.pred(time.seq), type="l", ylab="Predicted Cumulative Baseline Hazard")

## Obtain predicted survial probabilities at month 1 and 2 (days 30 & 60):

lp <- predict(cfit) # estimated linear predictor

S.pred <- cbind(exp(-H0.pred(30)*exp(lp)), exp(-H0.pred(60)*exp(lp)))

## Obtain predicted survival at month 1 and 2 directly:
S.pred2 <- predict(cfit, type="response", new.event.times=c(30,60))

## Confirm that the two arrived at the same values:
all.equal(S.pred, S.pred2)

# See ?gamlasso for an example fitting a gaussian response model
# See ?summary.gamlasso for an example fitting a binomial response model
# See ?predict.gamlasso for an example fitting a poisson response model

plsmselect documentation built on Dec. 1, 2019, 1:11 a.m.