Displaying 2 results from an estimated 2 matches for "maketestdf".
Did you mean:
maketest
2007 Nov 08
2
mapply, coxph, and model formula
...-
I am wanting to create some Cox PH models with coxph (in package
survival) using different datasets.
The code below illustrates my current approach and problem with
completing this.
### BEGIN R SAMPLE CODE ##############################
library(survival)
#Define a function to make test data
makeTestDF <- function(n) {
times <- sample(1:200, n, replace = TRUE)
event <- rbinom(n, 1, prob = .1)
trt <- rep(c("A","B"), each = n/2)
testdf <- data.frame(times,event,trt)
}
#Create two sets of test data of different sizes
testdf1 <- makeTestDF(100)...
2007 Nov 09
2
wrapper for coxph with a subset argument
...gressions.
I can already achieve my goal, I just would like to know more details
about how others do things like this.
I've simplified my code below to focus on where I feel I'm confused.
Here is some code along with comments:
#### BEGIN R SAMPLE CODE
#Function for producing test data
makeTestDF <- function(n) {
times <- sample(1:200, n, replace = TRUE)
event <- rbinom(n, 1, prob = .1)
trt <- rep(c("A","B"), each = n/2)
sex <- factor(c("M","F"))
sex <- rep(sex, times = n/2)
testdf <- data.frame(times,...