Introduction to the rstpm2 package
Abstract
This vignette outlines the methods and provides some examples for generalised survival models as implemented in the R rstpm2 package.
Keywords: survival, splines
1 Background and theory
Generalised survival models provide a flexible and general approach to modelling survival or time-to-event data. The survival function to time for covariates is defined in terms of a inverse link function and a linear prediction , such that
where is a function of both time and covariates , with regression parameters . We can calculate the hazard from this function, where
We model using a linear predictor for a design matrix . The linear predictor can be constructed in a flexible manner, with the main constraint being that the time effects be smooth and twice differentiable. We calculate the derivative for the linear predictor using finite differences, such that
for a derivative design matrix . This formulation allows for considerable flexibility in the construction of the linear predictor, with possible interactions between time and covariates.
The default smoother for time using natural splines for log(time), which is the flexible parametric survival model developed by Royston and Parmar (2003) and implemented by the Stata command stpm2 11
1
As a technical aside, the Stata implementation uses natural splines using a truncated power basis with orthogonalisation, while the ns() function in R uses a matrix projection of B-splines. Note that we have implemented an extended nsx() function for natural splines that includes cure splines, centering, and a compatibility argument to use Stata stpm2’s unusual specification of quantiles.
| Link description | Inverse link function | Interpretation | link.type |
|---|---|---|---|
| loglog | Proportional hazards | "PH" | |
| logit | Proportional odds | "PO" | |
| probit | Probit | "probit" | |
| log | Additive hazards | "AH" | |
| Aranda-Ordaz | Aranda-Ordaz | "AO" |
The models are estimated using maximum likelihood estimation (MLE) for fully parametric models, penalised MLE for penalised smoothers, maximum marginal likelihood estimation (MMLE) for parametric models with clustered data, or penalised MMLE for penalised models with clustered data. The likelihoods include left truncation, right censoring and interval censoring. For clustered data, we include Gamma frailties and normal random effects. Details on these models are available from https://doi.org/10.1177/0962280216664760 and https://doi.org/10.1002/sim.7451.
2 Syntax
The main functions for fitting the models are stpm2 for parametric models, possibly with clustered data, and pstpm2 for penalised models, possibly with clustered data. A subset of the syntax for stpm2 is:
stpm2(formula, data, smooth.formula = NULL, df = 3, tvc = NULL, link.type=c("PH","PO","probit","AH","AO"), theta.AO=0, bhazard = NULL, robust = FALSE, cluster = NULL, frailty = !is.null(cluster) & !robust, RandDist=c("Gamma","LogN"), ...)
The formula has a Surv object on the left-hand-side and a linear predictor on the right-hand-side that does not include time (for pstpm2, it also does not include penalised functions). The time effects can be specified in several ways: the most general is using smooth.formula, where the right-hand-side of the formula specifies functions for time that are smooth with respect to time. This specification can include interactions between time and covariates. As an example, smooth.formula=~nsx(log(time),df=3)+x:nsx(log(time),df=2) specifies a baseline natural spline smoother of the log of the variable time used in the Surv object with three degrees of freedom, with an interaction between a covariate x and a natural spline smoother of log(time) with two degrees of freedom. Other specifications of time effects have equivalent formulations: for example, df=3 is equivalent to smooth.formula=~nsx(log(time),df=3) for the variable time. Similarly, tvc=list(x=2) is equivalent to smooth.formula=~x:nsx(log(time),df=2). Moreover, for a log-linear interaction between a covariate and time, use smooth.formula=~x:log(time)
A current limitation of the implementation is that the dataset data needs to be specified.
Type of link is specified with the link.type argument; this defaults to a loglog link for proportional hazards (see Table 1). For the Aranda-Ordaz link, the fixed value of the scale term is specified using the theta.AO argument. For relative survival, a vector for the baseline hazard can be specified using the bhazard argument. A vector for the clusters can be specified with the cluster argument. The calculation of robust standard errors can be specified with the robust=TRUE argument; if robust is false, then the model assumes a frailty or random effects model, with either a default Gamma frailty (RandDist="Gamma") or a normal random effect (RandDist="LogN", using notation from the frailtypack package).
The default specification for the additive hazards (link.type=="AH") models follows that for the ahaz package on CRAN: for a model specified as
stpm2(Surv(time,event)~x, data=data, link.type="AH")
we assume natural splines for the baseline time effect and a constant hazard for a unit change in the covariate x; an equivalent specification is
stpm2(Surv(time,event)~1, data=data, link.type="AH", smooth.formula=~nsx(time,df=3)+x:time)
where there is default smoother for time and an interaction between linear x and linear time. The regression coefficient for x:time can be interpreted as the additive rate for a unit change in x.
The syntax for the fitting the penalised models with pstpm2 is very similar. A subset of the arguments are:
pstpm2(formula, data, smooth.formula = NULL, tvc = NULL, bhazard = NULL, sp=NULL, criterion=c("GCV","BIC"), link.type=c("PH","PO","probit","AH","AO"), theta.AO=0, robust=FALSE, frailty=!is.null(cluster) & !robust, cluster = NULL, RandDist=c("Gamma","LogN"), ...)
The penalised smoothers are specified using the s() function from the mgcv package within the smooth.formula argument; by default, not specifying smooth.formula will lead to
smooth.formula=~s(log(time))
Interactions with time (both penalised and unpenalised) and penalised covariate effects should be specified using smooth.formula. Note that the df argument is not included. By default, the smoothing parameter(s) are using the criterion argument; the smoothing parameters can also be fixed using the sp argument. The specifications for relative survival, link type, and clustered data follow that for the stpm2 function.
2.1 Post-estimation
One of the strengths of these models is varied post-estimation. Most of the estimators are described in Tables 2 and 3. These estimators are typically calculated from the predict function or from plot function calls. All of these calls require that the newdata argument is specified (in contrast to prediction in the survival package, which defaults to the average of each covariate).
For contrasts (e.g. survival differences, hazard ratios), the newdata argument is the “unexposed” group, while the exposed group is defined by either: (i) a unit change in a variable in newdata as defined by the var argument (e.g. var="x" for variable x); or (ii) an exposed function that takes a data-frame and returns the “exposed” group; for example
exposed=function(data) transform(data, x=1)
The latter mechanism is quite general and allows for standardised survival, standardised hazards, and attributable fractions under possibly counterfactual exposures.
| Description | Formulation22 2 Notation: is a covariate pattern for the “exposed” group; is a set of possibly counterfactual covariates; is the expectation or average of across the set ; and are sets of possibly counterfactual covariates for the “unexposed” and “exposed” sets, respectively. | type |
| Conditional link | "link" | |
| Conditional survival | "surv" | |
| Conditional odds | "odds" | |
| Conditional failure | "fail" | |
| Conditional cumulative hazard | "cumhaz" | |
| Conditional density | "density" | |
| Conditional hazard | "hazard" | |
| Conditional log hazard | "loghazard" | |
| Conditional survival differences | "survdiff" | |
| Conditional hazard differences | "hazdiff" | |
| Conditional hazard ratios | "hr" | |
| Conditional odds ratios | "or" | |
| Restricted mean survival time | "rmst" | |
| Standardised survival | "meansurv" | |
| Standardised survival differences | "meansurvdiff" | |
| Standardised hazard | "meanhaz" | |
| Standardised hazard ratio | "meanhr" | |
| Attributable fraction | "af" |
| Description | Formulation33 3 Notation: is a random effect or frailty; is a covariate pattern for the “exposed” group; is a set of possibly counterfactual covariates; is the expectation or average of across the set ; and are sets of possibly counterfactual covariates for the “unexposed” and “exposed” sets, respectively. | type |
| Marginal survival | "margsurv" | |
| Marginal hazard | "marghaz" | |
| Marginal survival differences | "margsurvdiff" | |
| Marginal hazard ratios | "marghr" | |
| Standardised marginal survival | "meanmargsurv" | |
| Standardised marginal survival differences | "meansurvdiff" | |
| Attributable fraction | "af" |
Standard errors for the post-estimators are calculated on a possibly transformed scale using the delta method. For the delta method, the partial derivatives of the post-estimators are calculated either directly or using finite differences.
| Functionality | Uncorre-lated param. | Uncorre-lated penal. | Param. gamma frailty | Penal. gamma frailty | Param. normal random effects | Penal. normal random effects |
|---|---|---|---|---|---|---|
| Multiple links | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| Right censoring | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| Left truncation | ⌧ | ⌧ | ⌧44 4 Gradients not currently implemented. | ⌧a | ⌧a | ⌧a |
| Interval censoring | ⌧ | ⌧ | □ | □ | ⌧ | ⌧ |
| Time-varying effects | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| Excess hazards | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| Conditional estimators55 5 Estimators including survival, survival differences, hazards, hazard ratios, hazard differences, density, odds and odds ratios. | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| Conditional standardisation66 6 Standardised estimators include mean survival, mean survival differences, mean hazards and attributable fractions. | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ | ⌧ |
| Frailty/random effects variance | ⌧ | ⌧ | ⌧ | ⌧ | ||
| Marginal estimators77 7 Marginal estimators include survival, survival differences, hazards, hazard ratios and hazard differences. | ⌧ | ⌧ | ⌧ | ⌧ | ||
| Marginal standardisation88 8 Marginal standardised estimators include mean survival, mean survival differences and attributable fractions. | ⌧ | ⌧ | □ | □ | ||
| Random intercept | ⌧ | ⌧ | ⌧ | ⌧ | ||
| Random slope | ⌧ | ⌧ | ||||
| Multiple random effects | □ | □ |
3 Examples: Independent survival analysis
We begin with some simple proportional hazard models using the brcancer dataset. We can fit the models using very similar syntax to coxph, except that we need to specify the degrees of freedom for the baseline smoother. Typical values for df are 3-6. For this model the model parameters include an intercept term, time-invariant log-hazard ratios, and parameters for the baseline smoother. The default for the baseline smoother is to use the nsx function, which is a limited extension to the splines::ns function, with log of the time effect.
> brcancer <- transform(brcancer, recyear=rectime / 365.24)> fit <- stpm2(Surv(recyear,censrec==1)~hormon, data=brcancer, df=4)> summary(fit)
Maximum likelihood estimationCall:stpm2(formula = Surv(recyear, censrec == 1) ~ hormon, data = brcancer, df = 4)Coefficients: Estimate Std. Error z value Pr(z)(Intercept) -6.79773 0.72642 -9.3578 < 2.2e-16 ***hormon -0.36406 0.12491 -2.9144 0.003563 **nsx(log(recyear), df = 4)1 5.69995 0.71677 7.9523 1.830e-15 ***nsx(log(recyear), df = 4)2 4.85614 0.48002 10.1166 < 2.2e-16 ***nsx(log(recyear), df = 4)3 10.13327 1.41267 7.1731 7.331e-13 ***nsx(log(recyear), df = 4)4 4.70626 0.33016 14.2545 < 2.2e-16 ***---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1-2 log L: 1684.412
> ## utility> eform.coxph <- function(object) exp(cbind(coef(object),confint(object)))> fit.cox <- coxph(Surv(recyear,censrec==1)~hormon, data=brcancer)> rbind(cox=eform(fit.cox),+ eform(fit)[2,,drop=FALSE])
2.5 % 97.5 %hormon 0.6948843 0.5438441 0.8878726hormon 0.6948520 0.5636727 0.8449352
We see that the hazard ratios are very similar to the coxph model. The model fit can also be used to estimate a variety of parameters. For example, we can easily estimate survival and compare with the Kaplan-Meier curves:
> plot(fit, newdata=data.frame(hormon=0), xlab="Time since diagnosis (years)")> lines(fit, newdata=data.frame(hormon=1), lty=2)> lines(survfit(Surv(recyear,censrec==1)~hormon, data=brcancer), col="blue", lty=1:2)> legend("topright", c("PH hormon=0","PH hormon=1","KM hormon=0","KM hormon=1"),+ lty=1:2, col=c("black","black","blue","blue")) We can also calculate the hazards.
> plot(fit,newdata=data.frame(hormon=1), type="hazard",+ xlab="Time since diagnosis (years)", ylim=c(0,0.3))> lines(fit, newdata=data.frame(hormon=0), col=2, lty=2, type="hazard")> legend("topright", c("hormon=1","hormon=0"),lty=1:2,col=1:2,bty="n") Usefully, we can also estimate survival differences and hazard differences. We define the survival differences using a reference covariate pattern using the newdata argument, and then define an exposed function which takes the newdata and transforms for the ’exposed’ covariate pattern. As an example:
> plot(fit,newdata=data.frame(hormon=0), type="hdiff",+ exposed=function(data) transform(data, hormon=1),+ main="hormon=1 compared with hormon=0",+ xlab="Time since diagnosis (years)")
> plot(fit,newdata=data.frame(hormon=0), type="sdiff",+ exposed=function(data) transform(data, hormon=1),+ main="hormon=1 compared with hormon=0",+ xlab="Time since diagnosis (years)")
4 Additive hazards
The additive hazards models takes the general form . As a recent change, the default model specification for formula=Surv(t,e)~x without specifying smooth.formula is to use , where is a natural spline design matrix with parameters , and with as the parameters for ; the hazard is then .
The additive hazards have the attractive property that the effects are collapsible: adjusting for an uncorrelated covariate will not change the estimated conditional effect. These models have received some uptake within the causal inference field. This implementation is flexible, where the baseline (cumulative) hazard can be modelled using splines and we can model for both constant hazards and smooth effects over time. One possible issue with their interpretation is whether the rates will be approximately additive for different effects. One approach to conceptualise these models is to consider the effects as being competing risks and where we are adding competing risks together.
For our example using the breast cancer dataset with the randomised assignment to hormonal therapy, we find that hazard for those on hormonal therapy was -0.047 per year (95% confidence interval: -0.066, -0.024) compared with those not on hormonal therapy.
> brcancer <- transform(brcancer, recyear=rectime / 365.24)> fit <- stpm2(Surv(recyear,censrec==1)~hormon, data=brcancer, link.type="AH")> summary(fit)
Maximum likelihood estimationCall:stpm2(formula = Surv(recyear, censrec == 1) ~ hormon, data = brcancer, link.type = "AH")Coefficients: Estimate Std. Error z value Pr(z)nsx(recyear, df = 3)1 0.597287 0.047944 12.4580 < 2.2e-16 ***nsx(recyear, df = 3)2 0.953083 0.067957 14.0249 < 2.2e-16 ***nsx(recyear, df = 3)3 0.984816 0.082322 11.9630 < 2.2e-16 ***hormon:recyear -0.046648 0.015485 -3.0124 0.002592 **---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1-2 log L: 1733.751
> confint(fit)
2.5 % 97.5 %nsx(recyear, df = 3)1 0.53207684 0.65981272nsx(recyear, df = 3)2 0.92489552 0.99226880nsx(recyear, df = 3)3 0.92525566 1.03932668hormon:recyear -0.06608349 -0.02365497
> plot(fit, newdata=data.frame(hormon=0), xlab="Time on study (years)")> lines(fit, newdata=data.frame(hormon=1), lty=2)> lines(survfit(Surv(recyear,censrec==1)~hormon, data=brcancer), col="blue", lty=1:2)> legend("topright", c("AH hormon=0","AH hormon=1","KM hormon=0","KM hormon=1"),+ lty=1:2, col=c("black","black","blue","blue"))
This can be modelled more flexibly using the smooth.formula argument. For example, we could model for sqrt(recyear) and include a natural spline smoother for the effect of hormon:
> fit <- stpm2(Surv(recyear,censrec==1)~1, data=brcancer, link.type="AH",+ smooth.formula=~ns(sqrt(recyear),df=3)+hormon:ns(recyear,df=3))> summary(fit)
Maximum likelihood estimationCall:stpm2(formula = Surv(recyear, censrec == 1) ~ 1, data = brcancer, link.type = "AH", smooth.formula = ~ns(sqrt(recyear), df = 3) + hormon:ns(recyear, df = 3))Coefficients: Estimate Std. Error z value Pr(z)ns(sqrt(recyear), df = 3)1 0.639080 0.051017 12.5268 < 2.2e-16 ***ns(sqrt(recyear), df = 3)2 0.855295 0.060997 14.0220 < 2.2e-16 ***ns(sqrt(recyear), df = 3)3 1.003871 0.086032 11.6685 < 2.2e-16 ***hormon:ns(recyear, df = 3)1 -0.348049 0.084944 -4.0974 4.178e-05 ***hormon:ns(recyear, df = 3)2 -0.307775 0.091428 -3.3663 0.0007618 ***hormon:ns(recyear, df = 3)3 -0.243627 0.128167 -1.9009 0.0573203 .---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1-2 log L: 1705.123
> plot(fit, newdata=data.frame(hormon=0), xlab="Time on study (years)")> suppressWarnings(lines(fit, newdata=data.frame(hormon=1), lty=2))> lines(survfit(Surv(recyear,censrec==1)~hormon, data=brcancer), col="blue", lty=1:2)> legend("topright", c("AH hormon=0","AH hormon=1","KM hormon=0","KM hormon=1"),+ lty=1:2, col=c("black","black","blue","blue")) The square root transform seems to considerably improve the fit at earlier times.
5 Mean survival
This has a useful interpretation for causal inference.
fit <- stpm2(...) predict(fit,type="meansurv",newdata=data)
6 Cure models
For cure, we use the melanoma dataset used by Andersson and colleagues for cure models with Stata’s stpm2 (see http://www.pauldickman.com/survival/).
Initially, we merge the patient data with the all cause mortality rates.
> popmort2 <- transform(rstpm2::popmort,exitage=age,exityear=year,age=NULL,year=NULL)> colon2 <- within(rstpm2::colon, {+ status <- ifelse(surv_mm>120.5,1,status)+ tm <- pmin(surv_mm,120.5)/12+ exit <- dx+tm*365.25+ sex <- as.numeric(sex)+ exitage <- pmin(floor(age+tm),99)+ exityear <- floor(yydx+tm)+ ##year8594 <- (year8594=="Diagnosed 85-94")+ })> colon2 <- merge(colon2,popmort2)>For comparisons, we fit the relative survival model without and with cure.
> fit0 <- stpm2(Surv(tm,status %in% 2:3)~I(year8594=="Diagnosed 85-94"),+ data=colon2,+ bhazard=colon2$rate, df=5)>
> summary(fit <- stpm2(Surv(tm,status %in% 2:3)~I(year8594=="Diagnosed 85-94"),+ data=colon2,+ bhazard=colon2$rate,+ df=5,cure=TRUE))
Maximum likelihood estimationCall:stpm2(formula = Surv(tm, status %in% 2:3) ~ I(year8594 == "Diagnosed 85-94"), data = colon2, bhazard = colon2$rate, df = 5, cure = TRUE)Coefficients: Estimate Std. Error z value Pr(z)(Intercept) -3.977312 0.054778 -72.6076 < 2.2e-16I(year8594 == "Diagnosed 85-94")TRUE -0.155610 0.025088 -6.2026 5.554e-10nsx(log(tm), df = 5, cure = TRUE)1 3.323179 0.053166 62.5062 < 2.2e-16nsx(log(tm), df = 5, cure = TRUE)2 3.628617 0.053160 68.2590 < 2.2e-16nsx(log(tm), df = 5, cure = TRUE)3 1.634845 0.022465 72.7741 < 2.2e-16nsx(log(tm), df = 5, cure = TRUE)4 6.591994 0.111504 59.1190 < 2.2e-16nsx(log(tm), df = 5, cure = TRUE)5 3.371798 0.042788 78.8024 < 2.2e-16(Intercept) ***I(year8594 == "Diagnosed 85-94")TRUE ***nsx(log(tm), df = 5, cure = TRUE)1 ***nsx(log(tm), df = 5, cure = TRUE)2 ***nsx(log(tm), df = 5, cure = TRUE)3 ***nsx(log(tm), df = 5, cure = TRUE)4 ***nsx(log(tm), df = 5, cure = TRUE)5 ***---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1-2 log L: 42190.77
> predict(fit,head(colon2),se.fit=TRUE)
Estimate lower upper1 0.8610827 0.8544629 0.86775382 0.7934653 0.7851995 0.80181813 0.6967404 0.6865295 0.70710314 0.8610827 0.8544629 0.86775385 0.8221243 0.8145059 0.82981406 0.8610827 0.8544629 0.8677538
>The estimate for the year parameter from the model without cure is within three significant figures with that in Stata. For the predictions, the Stata model gives:
+---------------------------------+
| surv surv_lci surv_uci |
|---------------------------------|
1. | .86108264 .8542898 .8675839 |
2. | .79346526 .7850106 .8016309 |
3. | .69674037 .6863196 .7068927 |
4. | .86108264 .8542898 .8675839 |
5. | .82212425 .8143227 .8296332 |
|---------------------------------|
6. | .86108264 .8542898 .8675839 |
+---------------------------------+
We can estimate the proportion of failures prior to the last event time:
> newdata.eof <- data.frame(year8594 = unique(colon2$year8594),+ tm=10)> predict(fit0, newdata.eof, type="fail", se.fit=TRUE)
Estimate lower upper1 0.6060904 0.5910403 0.62058672 0.5512430 0.5364659 0.5655489
> predict(fit, newdata.eof, type="fail", se.fit=TRUE)
Estimate lower upper1 0.5913310 0.5769385 0.60523402 0.5350825 0.5214886 0.5482902
> predict(fit, newdata.eof, type="haz", se.fit=TRUE)
Estimate lower upper1 1.254143e-06 1.081724e-06 1.426561e-062 1.073411e-06 9.235370e-07 1.223286e-06
>We can plot the predicted survival estimates:
> tms=seq(0,10,length=301)[-1]
> plot(fit0,newdata=data.frame(year8594 = "Diagnosed 85-94", tm=tms), ylim=0:1,
+ xlab="Time since diagnosis (years)", ylab="Relative survival")
> plot(fit0,newdata=data.frame(year8594 = "Diagnosed 75-84",tm=tms),
+ add=TRUE,line.col="red",rug=FALSE)
> ## warnings: Predicted hazards less than zero for cure
> plot(fit,newdata=data.frame(year8594 = "Diagnosed 85-94",tm=tms),
+ add=TRUE,ci=FALSE,lty=2,rug=FALSE)
> plot(fit,newdata=data.frame(year8594="Diagnosed 75-84",tm=tms),
+ add=TRUE,rug=FALSE,line.col="red",ci=FALSE,lty=2)
> legend("topright",c("85-94 without cure","75-84 without cure",
+ "85-94 with cure","75-84 with cure"),
+ col=c(1,2,1,2), lty=c(1,1,2,2), bty="n")
>
And the hazard curves:
> plot(fit0,newdata=data.frame(year8594 = "Diagnosed 85-94", tm=tms),
+ ylim=c(0,0.5), type="hazard",
+ xlab="Time since diagnosis (years)",ylab="Excess hazard")
> plot(fit0,newdata=data.frame(year8594 = "Diagnosed 75-84", tm=tms),
+ type="hazard",
+ add=TRUE,line.col="red",rug=FALSE)
> plot(fit,newdata=data.frame(year8594 = "Diagnosed 85-94", tm=tms),
+ type="hazard",
+ add=TRUE,ci=FALSE,lty=2,rug=FALSE)
> plot(fit,newdata=data.frame(year8594="Diagnosed 75-84", tm=tms),
+ type="hazard",
+ add=TRUE,rug=FALSE,line.col="red",ci=FALSE,lty=2)
> legend("topright",c("85-94 without cure","75-84 without cure",
+ "85-94 with cure","75-84 with cure"),
+ col=c(1,2,1,2), lty=c(1,1,2,2), bty="n")
>
The current implementation does not provide a test for differences in cure. We can code this using the predictnl function:
> newdata.eof <- data.frame(year8594 = unique(colon2$year8594),+ tm=10)> test <- predictnl(fit, function(object,newdata=NULL) {+ lp1 <- predict(object, newdata.eof[1,], type="link")+ lp2 <- predict(object, newdata.eof[2,], type="link")+ lp1-lp2+ })> with(test, c(fit=fit,+ se.fit=se.fit,+ statistic=fit/se.fit,+ p=2*pnorm(abs(fit/se.fit), lower.tail=FALSE)))
fit se.fit statistic p1.556104e-01 2.508800e-02 6.202583e+00 5.554391e-10
>
7 Potential limitations and next steps
- •
TODO: investigate whether we can calculate more accurately using the
numDerivpackage. - •
TODO: Extend the generalised survival models to use multiple random effects.
- •
TODO: Extend the generalised survival models to use automatic differentiation.
Affiliation
Mark Clements
Department of Medical Epidemiology and Biostatistics
Karolinska Institutet
Email: mark.clements@ki.se