Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1.  
  2. #Crump 2014 Season of birth and other perinatal risk factors for melanoma
  3. #Int. J. Epidemiol. (2014) doi: 10.1093/ije/dyt277
  4. #Table 1 Data
  5. dat<-structure(list(`Birth Month` = c("January", "February", "March",
  6. "April", "May", "June", "July", "August", "September", "October",
  7. "November", "December"), Births = c(297241L, 291749L, 334787L,
  8. 331520L, 324466L, 305267L, 310043L, 300578L, 291196L, 278533L,
  9. 252598L, 253596L), `Person-years (Millions)` = c(5.47, 5.36,
  10. 6.2, 6.09, 5.88, 5.45, 5.44, 5.26, 5.13, 4.84, 4.41, 4.42), `CMM cases` = c(144L,
  11. 139L, 162L, 170L, 166L, 127L, 131L, 126L, 116L, 115L, 99L, 100L
  12. ), `Cases per 100 000 person-years` = c(2.63, 2.59, 2.61, 2.79,
  13. 2.82, 2.33, 2.41, 2.4, 2.26, 2.37, 2.25, 2.26)), .Names = c("Birth Month",
  14. "Births", "Person-years (Millions)", "CMM cases", "Cases per 100 000 person-years"
  15. ), row.names = c(NA, 12L), class = "data.frame")
  16.  
  17. #Table 2 Data
  18. age.brackets<-seq(0,30,by=5)+2
  19. age.cases<-c(4,6,32,181,395,505,472)
  20.  
  21.  
  22.  
  23. #Simulate researcher behaviour
  24. bday<-sample(1:360, 100000, replace=T)
  25. tday<-sample(120:210, 100000, replace=T)
  26.  
  27. age.sim<-cbind(bday,tday,0,NA)
  28. colnames(age.sim)[3]<-"Age at Test"
  29. age.sim[which(age.sim[,1]<=age.sim[,2]),3]<-1
  30. age.sim<-age.sim[sort(age.sim[,1], index.return=T)$ix,]
  31.  
  32. mo<-1
  33. for(i in seq(0,330,by=30)){
  34. age.sim[which(age.sim[,1]>i & age.sim[,1]<=(i+30)),4]<-mo
  35. mo=mo+1
  36. }
  37.  
  38. pred.ages=NULL
  39. for(i in 1:12){
  40. pred.ages<-rbind(pred.ages,mean(age.sim[which(age.sim[,4]==i),3]))
  41. }
  42.  
  43.  
  44.  
  45.  
  46. #estimate cases by month
  47. rate.per.yr<-(395-181)/5
  48. rate.per.month<-rate.per.yr/12
  49. agesize<-3595055/7
  50. dec.cases<-rate.per.month*6 + 181
  51. births.per.mo<-dat[1:12,2]
  52. mo<-12*pred.ages
  53. est<-((dec.cases+mo*rate.per.month)/agesize)*births.per.mo
  54.  
  55.  
  56. #plots
  57. plot(1000000*dat[,3]/dat[,2], type="b", xlab="", xaxt="n",
  58. ylab= "person-years of follow up per birth",
  59. main= "Average age?")
  60. axis(side=1,at=1:12,labels=dat[,1])
  61. lines(1:12,17.4+pred.ages, type="l", col="Red", lwd=3)
  62.  
  63. par(mfrow=c(2,1))
  64. plot(age.brackets,age.cases, type="b",
  65. xlab="Age Bracket (Middle Value)", ylab="# of Cases")
  66. abline(v=c(17.5,18.5), lty=2, lwd=3)
  67. abline(h=seq(0,500,by=100),lty=1)
  68. abline(h=seq(0,500,by=50),lty=3)
  69.  
  70. plot(age.brackets,age.cases/agesize, type="b",
  71. xlab="Age Bracket (Middle Value)", ylab="Estimated Prevalence")
  72. abline(v=c(17.5,18.5), lty=2, lwd=3)
  73. abline(h=seq(0,1,by=.2)/1000,lty=1)
  74. abline(h=seq(0,1,by=.1)/1000,lty=3)
  75.  
  76.  
  77. par(mfrow=c(2,1))
  78. plot(dat[,4], type="b", xaxt="n",
  79. ylim=c(min(dat[,4],est),max(dat[,4],est)),
  80. ylab=colnames(dat)[4], xlab="Birth Month",
  81. main="# of CMM cases")
  82. axis(side=1,at=1:12,labels=dat[,1])
  83. lines(est, type="b", col="Blue")
  84.  
  85.  
  86. plot(est-dat[,4], type="b", col="Blue",
  87. ylab="Model-data", xaxt="n", xlab="Birth Month",
  88. main="# of CMM cases")
  89. axis(side=1,at=1:12,labels=dat[,1])
  90. abline(h=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement