78 questions
4
votes
1
answer
94
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
48
views
Is there a stepwise selection package in R for COX Mixed model?
Can stepwise selection method be used in COX Mixed model with R? lmerTest and cAIC4 packages both don't work.
In addition, is LASSO a better process to select predictors for regression models, ...
0
votes
1
answer
63
views
How to add shapefiles and raster files as covariates in spatstat kppm function
I encountered various errors while running the spatstat package. Here is a summary of my data: a shapefile of landslide point events, a watershed shapefile as the observation window, and several ...
1
vote
0
answers
31
views
Removing 10th smallest and 10th largest filter in package rms graphing
I am using the "rms" package to graph predicted values of a coxph model. However, my graphs do not show my entire range of values. Upon inspection, the package vignette under the "...
0
votes
1
answer
138
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 ...
2
votes
0
answers
149
views
Difference between C-score calculated by sksurv.metrics vs lifeline
I am currently trying to train a deep learning model with CoxPh loss, (kind of like deepSurv but different model. The thing is when I evaluate the model using C-statistics, the s-score from sksurv is ...
1
vote
2
answers
3k
views
Facing an error that an id statement is required for multi-state models while running cox model in R
i am trying to run cox regression model in R studio but facing same error every time.
cox.model <-coxph(Surv(dat$los, dat$died) ~ gender, data=dat)
Error in coxph(Surv(dat$los, dat$died) ~ gender, ...
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
109
views
Fisher transformation
I have data on earthquake epicenters. While I am trying to fit a LGCP to it, I get the error message as below when I print the result of my model:
Inhomogeneous Cox point process model
Fitted to point ...
0
votes
0
answers
237
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-...
2
votes
1
answer
125
views
How to reproduce Cox survival model results from Stata in R?
I am attempting to reproduce in R Cox survival model results originally obtained in Stata. Here is the Stata code:
stset t, id(leadid) failure(c_coup)
stcox legislature lgdp_1 growth_1 ...
1
vote
0
answers
30
views
spss query HRs for time dependent covariate at multiple periods of follow-up
Consider the model: h(t, X) = h0(t) exp [clin2 + prison + dose + clin2gt] where the variables are defined as follows: clin2 is time dependent (categorical coded 1/0); survt follow-up time in days; ...
2
votes
1
answer
1k
views
R modelsummary output: robust standard errors from coxph model
Im running a series of coxph models in R and compiling the output into latex tables using the modelsummary package and command. The coxph provides SE and robust se as outputs and the p-value is based ...
1
vote
1
answer
337
views
How can I change coef to exp(coef) in modelsummary table?
I am trying to create a summary table for my Cox model. However, when I use modelsummary function, it gives me a table that shows coef. But I want to display exp(coef) on my summary table. How can I ...
1
vote
1
answer
667
views
Error when model diagnostics on stratified variable with coxph (survival package) in R
I have a dataset where 3 groups have recieved exposure to different media. One group is exposed to 1 of the 3 media. Therefore, my coxph model is stratified:
# My treatment variable is loaded as a ...
0
votes
0
answers
215
views
Cox PH model, how to control for multiple events
I´m working on a time-to-event model in R using the coxph function in the survival package. I´m analysing animal movements until they pass the study area which consists of 2 zones. Each individual can ...
1
vote
0
answers
670
views
How to plot survival probability calibration with Lifelines?
I am trying to use survival_probability_calibration to visualize the performance of Cox model but the calibration curve would always stay flat as shown in the following plot:
Calibration curve with ...
0
votes
2
answers
1k
views
Loop in Cox regression
I am trying to run a cox regression for 1000 variables (exposure) as below
varlist <- names(dataset)[275:1275]
sumtables <- lapply(varlist, function(i) {
iformula <- as.formula(...
4
votes
0
answers
563
views
How to draw a forest plot for coxph considering subject ids in R?
I am trying to draw a forest plot for the results of cox model with repeated measures considering subjects ids; here is a part of my big data;
data <- read.table(header=TRUE, text="
Id ...
3
votes
0
answers
1k
views
What is the output of predict.coxph() using type = "survival"?
I am trying to learn what the various outputs of predict.coxph() mean. I am currently attempting to fit a cox model on a training set then use the resulting coefficients from the training set to make ...
0
votes
1
answer
800
views
Export coefficients from a loop for multiple cox regression
I need your help! I have a data set with 100,000 cases and 81 variables and I run a loop for multiple regression for each variable adjusted for age and sex in r:
covariates <- c(var1, var2, ... ...
0
votes
0
answers
107
views
Comparing graph of stratified cox model to others in R
I'm looking at the bfeed dataset in R:
library(survival)
library(KMsurv)
data(bfeed)
dput(head(bfeed))
structure(list(duration = c(16L, 1L, 4L, 3L, 36L, 36L), delta = c(1L,
1L, 0L, 1L, 1L, 1L), race =...
3
votes
2
answers
1k
views
ggforest returns error Error in `[.data.frame`(cbind(allTermsDF, coef[inds, ]), , c("var", "level", : undefined columns selected
I am using the ovarian dataset from the survival package using the following standard code:
ovarian$rx <- factor(ovarian$rx, levels = c("1", "2"), labels = c("A", &...
0
votes
0
answers
755
views
Cox Hazard Model: why multiple factor levels are reference?
When conducting a multivariate Coxph model with categorical predictors, and after releveling all predictor variables (function= relevel()), two of my predictor variables have multiple levels that are "...
1
vote
1
answer
2k
views
Multivariable cox regression analysis in R with non-binary categorical variables
I have questions about multivariable cox regression analysis including non-binary categorical variables.
My data consists of several variables, and some of them are binary (like sex, and age over 70, ...