Skip to content

Instantly share code, notes, and snippets.

id time event
1 253 0
2 385 0
3 720 1
id sex tstart tstop had_event contacted_support
1 female 0 253 0 0
2 female 0 385 0 0
3 male 0 100 0 0
3 male 100 720 1 1
newdata <- tmerge(base, support, id = id, contacted_support = tdc(time, contacted_support))
base <- tmerge(customer, event, id = id, tstop = time, had_event = event(time, event))
library(survival)
customer <- read.csv("C:/Users/dbatten/Desktop/customer.csv")
event <- read.csv("C:/Users/dbatten/Desktop/event.csv")
support <- read.csv("C:/Users/dbatten/Desktop/support.csv")
id time contacted_support
1 0 0
2 0 0
3 0 0
3 100 1
id sex
1 female
2 female
3 male
// Add to the list of imports
import org.apache.hadoop.mapreduce.lib.input.*;
// Add to the fields of the LineRecordReader class
private boolean fileBroken;
private String splitName;
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
# Function to get hazard ratio for males vs. baseline at any given time
y = function(x) exp(-.4667783 - .0008827 * x)
# Plot it
plot(y, ylim=c(0,1), xlim=c(0,1000), xlab = 'Time', ylab = 'Hazard Ratio')
title('Hazard Ratio for Male')