-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode_Correlations_JAMA_Reply.R
29 lines (21 loc) · 1.32 KB
/
Code_Correlations_JAMA_Reply.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Set decimals options [digits] and no scientific notation
options(digits=2,scipen=999)
#Correlation Analysis for JAMA Reply to Cruz-Cano and Mead
#Import Deaths
deaths <- read.csv("PATH GOES HERE/Puerto_Rico_Deaths_00_16.csv")
#Just in case the file has 2017 observations
deaths<-subset(deaths,Year<2017)
###This is the analysis using the data for the 2000-2016 period
###This is the correlation we reference in our Letter in response to Drs. Cruz-Cano and Mead
cor.test(x=deaths$Pop_Est,y=deaths$Total_Deaths,alternative = "two.sided",method ="pearson",conf.level = 0.95)
###This is the analysis using the data but with Period Deaths
###The correlation is not significant either
cor.test(x=deaths$Pop_Est,y=deaths$Period_Deaths,alternative = "two.sided",method ="pearson",conf.level = 0.95)
#Supplementary Correlation Analysis for the 2010-2016 period
#This section of the analysis excludes the observations before 2010
#Here, deaths is a subset for deaths after 2009 only
deaths<-subset(deaths, Year>2009)
#Correlations using Period Deaths 2010-2016
cor.test(x=deaths$Pop_Est,y=deaths$Period_Deaths,alternative = "two.sided",method ="pearson",conf.level = 0.95)
#Correlations using Total Deaths 2010-2016
cor.test(x=deaths$Pop_Est,y=deaths$Total_Deaths,alternative = "two.sided",method ="pearson",conf.level = 0.95)