Skip to content

Competing Risks Regression with qualitative predictor with more than 2 categories

2 messages · kende jan, Ravi Varadhan

#
Hi,

You can use `model.matrix' to create the apropriate design matrix for factor variables.

set.seed(10)

ftime <- rexp(200)

fstatus <- sample(0:2,200,replace=TRUE)

gg <- factor(sample(1:3,200,replace=TRUE),1:3, c('a','b','c'))

cov <- matrix(runif(600),nrow=200)

dimnames(cov)[[2]] <- c('x1','x2','x3')

cov2 = model.matrix( ~ cov + gg)

print(z <- crr(ftime,fstatus,cov2[, -1]))  # you shouldn't have intercept in the FG model

Hope this helps,
Ravi. 




____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: kende jan <kendejan at yahoo.fr>
Date: Sunday, August 2, 2009 6:01 am
Subject: [R] Competing Risks Regression with qualitative predictor with more than 2 categories
To: r-help at r-project.org
[[elided Yahoo spam]]