491 questions
Advice
0
votes
1
replies
30
views
Check assumptions of mixed effects cox model
I am running a mixed effects cox model using coxme in R, and I cannot find any information on how to check model assumptions for this type of model. I have seen the older chats, which have recommended ...
0
votes
0
answers
44
views
Why does `estat phtest` return missing values (.) when testing proportional hazards assumption in Cox PH regression using Stata?
I am fitting a Cox proportional hazards model in Stata and checking the proportional hazards (PH) assumption using estat phtest.
Here is how I set up my survival data:
stset time, failure(event)
...
0
votes
0
answers
99
views
Restricted cubic splines with R RMS package and multiple imputation from MICE
I am trying to create a restricted cubic splines plot with the R RMS package and imputed data from the R MICE package.
I could not find information on how to combine the different imputations from ...
4
votes
1
answer
95
views
Predict function in Clogit (Conditional logit)
I am trying to understand how the predict function works for conditional logit. I tried to calculate it manually but it does not work. Any help would be greatly appreciated.
library(survival)
set....
0
votes
0
answers
50
views
How do I manually set the reference category for a Cox PH Model in python?
I'm running a Cox PH Model to examine survival times among a population, and my model outputs fine, except I want to change the categories its using as the reference/baseline (i.e. right now it's ...
0
votes
1
answer
138
views
How do I train a penalized CoxPH model with restricted cubic splines in R?
I am trying to train a time-independent Cox model on a dataset of ~750,000 rows, as well as a time-dependent one on several million rows. I have 19 variables, some of which are binary and some ...
2
votes
1
answer
66
views
Y-axis of mgcv::gam cox.ph model: rate or ratio?
I am plotting a nonlinear generalized additive model (gam) using R's mgcv package:
library(mgcv)
V <- rep(1, nrow(dt)
fit <- gam(cbind(V, group_number) ~ s(time_elapsed, exposure_group, bs='fs'...
0
votes
0
answers
16
views
How to explain discrepancy between a Cox PH model output and sjPlot:tab_model() output?
In a model we are developping for a project, we use a Cox Proportional Hazard model.
We compared the table from the summary
and the tab_model() of the model.
What we have observed is the ...
4
votes
2
answers
122
views
How to identify relevant strings in this emmeans() output
I am interested in plotting the HR from a coxph() model for a categorical-continuous interaction. Basically estimating the binary HR at multiple values of the continuous predictor and then plotting ...
0
votes
0
answers
24
views
Interpolating daily persistence probabilities in package carcass
Disclaimer: I am new to R and survival analyses so apologies if I don't use the right terms or coding etiquette-figuring it out.
In the carcass package, I've used function persistence.prob to develop ...
0
votes
0
answers
87
views
StepReg with missing imputation
I'm trying to do a stepwise Cox regression imputing missing values.
As a first step I tried a simple stepwise procedure using the StepReg package but I ran into the following issue:
set.seed(123)
...
0
votes
1
answer
63
views
How to transform 'panel data' structure into a data structure suitable for Cox Regression?
I made up some dummy data that has a very similar structure as our internal data I cannot share.
I would like to know how to prepare it for the Cox Regression.
Could you help me to pre-process the ...
1
vote
0
answers
46
views
Can the DynNom function in R create a dynamic nomogram from a Cox model with time varying coefficients
Recently, I learnt about DynNom function which allows one to generate a dynamic nomogram. When I attempted to generate a dynamic nomogram from a Cox model allowing for time varying coefficient after ...
1
vote
1
answer
280
views
How to plot hazard ratio from coxph model with tt() term
This question is related to another that I posted here:
How to visually assess tt() suitability in coxph?
If we have a time-varying HR that arises from a time-dependent coefficient because we have ...
0
votes
1
answer
377
views
How to add a number at risk table beneath survival curves from multivariate Cox model with clustering?
My first question here. I would like to add a number at risk table to the survival curves from multivariate Cox proportional hazards models that use clustering.
ggadjustedcurves will produce the ...
1
vote
1
answer
118
views
How to pass parameters to this sklearn Cox model in a Pipeline?
If I run the following Python code it works well:
target = 'churn'
tranOH = ColumnTransformer([ ('one', OneHotEncoder(drop='first', dtype='int'),
make_column_selector(dtype_include='category', ...
0
votes
0
answers
75
views
Error in joint modeling of the JM package in R
I am running a joint modeling of a linear mixed model and a Cox model as below.
rbcLME <- lme(log(RBC.counts+1)~time+time:DAC, random = ~1|ID,
data=no.missing.rbc)
rbcSURV <- coxph(...
1
vote
0
answers
74
views
CoxTimeVaryingFitter - Baseline Hazards Using Strata in Python
I am applying strata on the Rossi dataset using CoxTimeVaryingFitter and when I call ctv.baseline_survival_ I am getting a dataframe with only one column, but expected two columns - one for each ...
1
vote
1
answer
1k
views
How to include a time-dependent coefficient for a categorical covariate in a Cox survival model in R?
I am building a Cox PH model using the survival package in R and would like to include a time-dependent coefficient for my categorical variable. Reproducible data set up:
library(survival)
# Data
...
1
vote
0
answers
272
views
Calibration curves from coxph() in R
I am running cox PH survival analyses for diabetes as an outcome, with <10 variables and no interaction terms. The c stats are all consistent with the literature sitting at around 0.75-0.80, as ...
1
vote
0
answers
48
views
Adding mortality rate (/1000 patients-years) + 95CI in a tbl_regression (gtsummary) from Cox regression mode?
I used the following code:
library(survival)
library(gtsummary)
library(dplyr)
df <- data.frame(
time = sample(1:10, 20, replace = TRUE),
status = sample(0:1, 20, replace = TRUE),
age = ...
0
votes
1
answer
140
views
Assessing time dependent categorical variable in cox ph survival model
I am trying to calculate the hazard rate of two treatments, which have more risk early in time compared to later. I've provided an example dataset and analysis below to highlight my situation.
I've ...
0
votes
0
answers
90
views
Splitting data in R by time and occurence of a incident, proportional hazard model
I have a question where I am trying to build a proportional hazard model with a time-varying constant.
Effectively the question is the occurance of an illness following a traumatic event. The ...
0
votes
1
answer
131
views
How to convert Y-axis to HR on smooth scaled schoenfeld residual plot? [closed]
I have tried to visualise the proportional hazard (ph) assumption for my cox-ph model by plotting the smooth scaled schoenfeld residual plot. I'm working in R.
The residual plot is computed in R like ...
0
votes
0
answers
137
views
Different interval confidences on the same forest plot (R, survival)
I'm currently working on survival functions and especially on forest plots. I would like to plot the different levels of confidence intervals on the same line, with different colors or shades.
To do ...
1
vote
1
answer
82
views
How to plot a case-cohort object, a cch object
Do you know how to plot a case-cohort study where we perform a Cox regression to estimate HR of different covariates, in which I am specially interested in potential molecular biomarkers and its ...
0
votes
1
answer
347
views
Cox Regression with multiple predictors; How to avoid NA result on last predictor
I got a problem with the results of my cox model in R. Anytime I put in multiple predictors, the last one (alphabetically) turns out with NA's and I don't know how to fix it. I tried with various ...
1
vote
0
answers
95
views
I am trying to find brier score of survival data using risk regression pacakge, but its giving an error
xy = Score(list(cox_ph), formula=Surv(time,status)~1,data=cox.train, metrics=c("brier","auc"), null.model=FALSE,times=time.int,debug = TRUE)
Extracted test set and prepared output ...
0
votes
1
answer
297
views
Penalized regression with cph() function of rms package in R
I am little bit crazy trying to run a penalized cox ph regression model with functions of rms package. I’ve done it with glmnet package but I would like to analize the outputs with rms and Hmisc ...
1
vote
1
answer
198
views
Error in colMeans(hazard) : 'x' must be an array of at least two dimensions
I'm trying to develop estimated survival curves from my Cox PH Model in R. Since it is a multi-state model I have added a new data argument where I've kept covariates constant except for the 1 for ...
1
vote
1
answer
222
views
Extract the position of knots from penalized spline in cox regression in R
I am calculating a cox model with two predictor variables (var1 and var2). var1 is a numeric variable and enters the cox regression without any modification. var2 on the other hand enters the cox ...
1
vote
1
answer
208
views
Survival analysis using cox returns "The truth value of a Series is ambiguous."
So I'm working with a dataset of Stroke cases from an hospital, and I would like to use Cox regression to make a survival analysis using time of arrival in the hospital, time of leave and survival or ...
0
votes
0
answers
17
views
Potential issue with regression model
A very broad question I had asked but my set up like this. So I took a data that was published in 2013-14 when nejm paper for AML came out, so the criteria i took is FAB classification then , ...
0
votes
0
answers
52
views
R Coxph Timescale at Risk
library(survival)
set.seed(1)
STARTAGE = sample(20:60, 100, T)
ENDAGE = sample(5:20, 100, T)
STATUS = sample(0:1, 100, T)
X1 = sample(1:3, 100, T)
X2 = sample(1:10, 100, T)
MODEL1 = survfit(Surv(...
2
votes
0
answers
297
views
How code a three-levels cox model for hierarchical data in R?
I have data I would like to analyze using a Cox proportional hazards model. The dataset contains an outcome variable (e.g. alive/dead), a follow-up time variable, quantitative and qualitative ...
2
votes
1
answer
471
views
Predicting survival and 95% confidence interval from a mixed effects Cox model (coxme)
I fitted a mixed effects cox model using the package coxme. The model includes a two-level variable as fixed effect and a random intercept.
I want to predict survival probability and 95% confidence ...
0
votes
1
answer
1k
views
How to calculate baseline hazard in R?
I have a Cox regression model as follows:
library(dplyr)
library(survival)
library(eha)
df <- data.frame(id = c("a", "a", "a", "b", "b", "c&...
3
votes
1
answer
2k
views
Plotting adjusted survival curve for a mixed-effects cox regression and/or time interaction?
I have created a mixed effects cox regression using coxme.
Q1) I would like to plot the coefficients of the fixed effects in an adjusted survival curve. However, it seems this functionality in ...
0
votes
0
answers
151
views
Using Surv() function in R for left censored data and cox regression
I want to do a survival analysis and cox regression for metastasis data to see if there are any significant genes associated with early metastasis.
The data set has gene names as columns, time at ...
0
votes
1
answer
1k
views
Cox regression with interaction term - which p value to use?
hoping the hive can help me understand this.
I want to study the effect of a continuous variable (x1) on survival, accounting for interaction between x1 and another continuous variable (x2). My full ...
0
votes
0
answers
146
views
Model using different random seeds leads to different interpretation result
I'm currently utilizing the shap library to interpret a hybrid model that combines a Cox proportional hazards model with a Multi-Layer Perceptron (MLP) using the pycox library. Interestingly, the ...
0
votes
1
answer
153
views
Where is the number of observations per level stored in a Cox regression object?
I need to extract into a new column the number of observations per level from a Cox regression object. If I run:
res <- coxph(Surv(age, status) ~ score, data = df)
res %>% tbl_regression(exp = T)...
0
votes
1
answer
235
views
Numerical Differences in Survival Probability Estimates between coxph and cph Functions
I am currently working on obtaining survival probabilities from Cox proportional hazard models. Initially, I utilized the coxph function, but for large data, it proved to be slow when predicting at ...
0
votes
0
answers
122
views
How do I use the outputs from a Cox Proportional Hazard model in R (with time-dependent covariates) to make user-level forecasts?
I have a pretty standard survival analysis set-up with right-censoring, and tracking users at regular time intervals measured from a relative t=0 time.
I have two static covariates X1 and X2, but one ...
0
votes
1
answer
291
views
How to effectively loop variables in univariate analysis?
I have written below code to run cox regression and output them to a table. I want to run univariate on many variables. Can you help me to use a loop to make it faster. variables are Grade, DCIS, LVE, ...
1
vote
1
answer
408
views
How to convert cox regression output into a dataframe?
I ran univariate cox regression model using following code.
res <- coxph(Surv(DFS, DFS.Event) ~ Grade, data = Grade)
summary(res)
It output as follows:
Call:
coxph(formula = Surv(DFS, DFS.Event) ~ ...
0
votes
1
answer
41
views
R: tidy_add_n() doesn't work when looping over many columns for Cox models with reformulate/as.formula
I would like to run a loop for Cox models that adjust for different subsets of covariates. The desired output should include number of events, person-years, hazards ratios, and 95%CI. If I call coxph ...
0
votes
1
answer
256
views
How to get predicted and observed risk estimates from riskRegression::FGR() subdistribution competing risk model object?
I want to extract observed and predicted estimates from time to event riskRegression::FGR() competing risk model object.
Below is some simulated data:
library(simstudy)
library(data.table)
library(...
0
votes
0
answers
88
views
Dealing with variables violating proportional hazard assumption, is it okay to use both step function and time-transform function simultaneously?
I tried to fit survival model with 4 variables violating proportional hazard assumption. I read following vignette (https://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf) and seared ...
0
votes
0
answers
241
views
Way to handle multiple variables that violate porportional hazard assumption. Step function and time transformation
I tried to fit survival model with several variables violating proportional hazard assumption.
I read following vignette thoroughly, but cannot get satisfactory answers for my case.
(https://cran.r-...