#COX REGRESSION cox=read.table("C:\\Users\\Pam\\Google Drive\\Binghamton\\Classes\\Spring 2014\\Biostats with R\\Projects\\scoxreg.txt",header=T) attach(cox) #must install a package before you begin #survival #and splines #factor the variables in question Ftreat=factor(cox$Treat) Fblock=factor(cox$block) #this tells R that both treatment and block are factors #Assign the rest of the variables Day=cox$Day Dead=cox$Dead SampleSize=cox$SS coxreg=coxph(Surv(Day,Dead)~Fblock+Ftreat+SampleSize) coxreg #create a model with y=surv, based on day and number dead flies. The variables that are being compared are block, treatment, and sample size #creating this model compares all treatments against the control treatment (treat 1) #it also compares block 1 against block 2 #in addition, it compares samplesize 1 against sample size 2 #because the p values of all these parts of the model are less tha 0.05, this suggests that they all contribute to the model and should be kept in #if this was not the case and there was a variable with a p value higher than 0.05, this means that the model can probably be run without that variable summary(coxreg) #the summary functions shows pairwise t-tests of the different variables, saying which are significantly different from the controls in each case