Research and Data Analysis #2

profilejamex.a.bowher2s
Week1Rcode.txt

#HMGT400 Week 1 exercise # Importing the data set into R Studio hmgtdata<-read.csv ("C:/Users/HP/Desktop/R work/HMGT400HOSPITAL1F.csv", header=T,sep = ",") hmgtdata #Names of variables names(hmgtdata) # subset data for 2011 and for 2012 hmgtdata11 <- subset(hmgtdata, hmgtdata$year=="2011") hmgtdata12 <- subset(hmgtdata, hmgtdata$year=="2012") hmgtdata11 hmgtdata12 #1a Hospital beds -2011 ## N mytable <- table(hmgtdata11$hospital_beds) summary(mytable) ##Mean mean(hmgtdata11$hospital_beds) ##StDev sd(hmgtdata11$hospital_beds) ## Results: n=1505, mean=376.6086 and stdev=560.8998 #1b Hospital beds -2012 ## N mytable <- table(hmgtdata12$hospital_beds) summary(mytable) ##Mean mean(hmgtdata12$hospital_beds) ##StDev sd(hmgtdata12$hospital_beds) ## Results: n=1525, mean=376.8 and stdev=579.8366 ### Running a T test to find the p-value #factor variable for year aggregate(hospital_beds ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$hospital_beds, hmgtdata$year1, paired = F) ## p-value < 2.2e-16 #2a Number of paid Employees - 2011 ## N mytable <- table(hmgtdata11$total_hospital_employees_on_payr) summary(mytable) ##Mean mean(hmgtdata11$total_hospital_employees_on_payr,na.rm=TRUE) ##StDev sd(hmgtdata11$total_hospital_employees_on_payr,na.rm=TRUE) ## Results: n=1498, mean=1237.276 and stdev=1615.797 #2b Number of paid Employees -2012 ## N mytable <- table(hmgtdata12$total_hospital_employees_on_payr) summary(mytable) ##Mean mean(hmgtdata12$total_hospital_employees_on_payr,na.rm=TRUE) ##StDev sd(hmgtdata12$total_hospital_employees_on_payr,na.rm=TRUE) ## Results: n=1515, mean=1491.121 and stdev=1961.637 ### Running a T test to find the p-value #factor variable for year aggregate(total_hospital_employees_on_payr ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$total_hospital_employees_on_payr, hmgtdata$year1, paired = F) ## p-value < 2.2e-16 #3a Number of non-paid Employees - 2011 ## N mytable <- table(hmgtdata11$total_hospital_non_paid_workers) summary(mytable) ##Mean mean(hmgtdata11$total_hospital_non_paid_workers,na.rm=TRUE) ##StDev sd(hmgtdata11$total_hospital_non_paid_workers,na.rm=TRUE) ## Results: n=30, mean=39.973 and stdev=72.58805 #3b Number of non-paid Employee -2012 ## N mytable <- table(hmgtdata12$total_hospital_non_paid_workers) summary(mytable) ##Mean mean(hmgtdata12$total_hospital_non_paid_workers,na.rm=TRUE) ##StDev sd(hmgtdata12$total_hospital_non_paid_workers,na.rm=TRUE) ## Results: n=30, mean=44.76976 and stdev=81.29861 ### Running a T test to find the p-value #factor variable for year aggregate(total_hospital_non_paid_workers ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$total_hospital_non_paid_workers, hmgtdata$year1, paired = F) ## p-value = 6.653e-05 #4a Total hospital cost - 2011 ## N mytable <- table(hmgtdata11$total_hosp_cost) summary(mytable) ##Mean mean(hmgtdata11$total_hosp_cost,na.rm=TRUE) ##StDev sd(hmgtdata11$total_hosp_cost,na.rm=TRUE) ## Results: n=1505, mean=216873322 and stdev=304570722 #4b Total hospital cost -2012 ## N mytable <- table(hmgtdata12$total_hosp_cost) summary(mytable) ##Mean mean(hmgtdata12$total_hosp_cost,na.rm=TRUE) ##StDev sd(hmgtdata12$total_hosp_cost,na.rm=TRUE) ## Results: n=1525, mean=214748023 and stdev=294143536 ### Running a T test to find the p-value #factor variable for year aggregate(total_hosp_cost ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$total_hosp_cost, hmgtdata$year1, paired = F) ## p-value = < 2.2e-16 #5a Total hospital revenues - 2011 ## N mytable <- table(hmgtdata11$total_hosp_revenue) summary(mytable) ##Mean mean(hmgtdata11$total_hosp_revenue,na.rm=TRUE) ##StDev sd(hmgtdata11$total_hosp_revenue,na.rm=TRUE) ## Results: n=1505, mean=228706319 and stdev=323339811 #5b Total hospital revenues -2012 ## N mytable <- table(hmgtdata12$total_hosp_revenue) summary(mytable) ##Mean mean(hmgtdata12$total_hosp_revenue,na.rm=TRUE) ##StDev sd(hmgtdata12$total_hosp_revenue,na.rm=TRUE) ## Results: n=1525, mean=229978391 and stdev=321273114 ### Running a T test to find the p-value #factor variable for year aggregate(total_hosp_revenue ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$total_hosp_revenue, hmgtdata$year1, paired = F) ## p-value = < 2.2e-16 #6a Available Medicare days - 2011 ## N mytable <- table(hmgtdata11$total_hospital_medicare_days) summary(mytable) ##Mean mean(hmgtdata11$total_hospital_medicare_days,na.rm=TRUE) ##StDev sd(hmgtdata11$total_hospital_medicare_days,na.rm=TRUE) ## Results: n=1499, mean=16739.16 and stdev=19214.29 #6b Available Medicare days -2012 ## N mytable <- table(hmgtdata12$total_hospital_medicare_days) summary(mytable) ##Mean mean(hmgtdata12$total_hospital_medicare_days,na.rm=TRUE) ##StDev sd(hmgtdata12$total_hospital_medicare_days,na.rm=TRUE) ## Results: n=1516, mean=17110.14 and stdev=19765.74 ### Running a T test to find the p-value #factor variable for year aggregate(total_hospital_medicare_days ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$total_hospital_medicare_days, hmgtdata$year1, paired = F) ## p-value = < 2.2e-16 #7a Available Medicaid days - 2011 ## N mytable <- table(hmgtdata11$total_hospital_medicaid_days) summary(mytable) ##Mean mean(hmgtdata11$total_hospital_medicaid_days,na.rm=TRUE) ##StDev sd(hmgtdata11$total_hospital_medicaid_days,na.rm=TRUE) ## Results: n=1484, mean=5301.199 and stdev=9207.699 #7b Available Medicaid days -2012 ## N mytable <- table(hmgtdata12$total_hospital_medicaid_days) summary(mytable) ##Mean mean(hmgtdata12$total_hospital_medicaid_days,na.rm=TRUE) ##StDev sd(hmgtdata12$total_hospital_medicaid_days,na.rm=TRUE) ## Results: n=1501, mean=5366.333 and stdev=9340.373 ### Running a T test to find the p-value #factor variable for year aggregate(total_hospital_medicaid_days ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$total_hospital_medicaid_days, hmgtdata$year1, paired = F) ## p-value = < 2.2e-16 #8a Total Hospital Discharge - 2011 ## N mytable <- table(hmgtdata11$total_hospital_discharges) summary(mytable) ##Mean mean(hmgtdata11$total_hospital_discharges,na.rm=TRUE) ##StDev sd(hmgtdata11$total_hospital_discharges,na.rm=TRUE) ## Results: n=1500, mean=9492.326 and stdev=10898.6 #8b Total Hospital Discharge -2012 ## N mytable <- table(hmgtdata12$total_hospital_discharges) summary(mytable) ##Mean mean(hmgtdata12$total_hospital_discharges,na.rm=TRUE) ##StDev sd(hmgtdata12$total_hospital_discharges,na.rm=TRUE) ## Results: n=1517, mean=9544.051 and stdev=10994.17 ### Running a T test to find the p-value #factor variable for year aggregate(total_hospital_discharges ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$total_hospital_discharges, hmgtdata$year1, paired = F) ## p-value = < 2.2e-16 #9a Medicare discharge - 2011 ## N mytable <- table(hmgtdata11$total_hospital_medicare_discharg) summary(mytable) ##Mean mean(hmgtdata11$total_hospital_medicare_discharg,na.rm=TRUE) ##StDev sd(hmgtdata11$total_hospital_medicare_discharg,na.rm=TRUE) ## Results: n=1499, mean=3230.624 and stdev=3388.957 #9b Medicare discharge -2012 ## N mytable <- table(hmgtdata12$total_hospital_medicare_discharg) summary(mytable) ##Mean mean(hmgtdata12$total_hospital_medicare_discharg,na.rm=TRUE) ##StDev sd(hmgtdata12$total_hospital_medicare_discharg,na.rm=TRUE) ## Results: n=1516, mean=3598.248 and stdev=3785.675 ### Running a T test to find the p-value #factor variable for year aggregate(total_hospital_medicare_discharg ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$total_hospital_medicare_discharg, hmgtdata$year1, paired = F) ## p-value = < 2.2e-16 #10a Medicaid discharge - 2011 ## N mytable <- table(hmgtdata11$total_hospital_medicaid_discharg) summary(mytable) ##Mean mean(hmgtdata11$total_hospital_medicaid_discharg,na.rm=TRUE) ##StDev sd(hmgtdata11$total_hospital_medicaid_discharg,na.rm=TRUE) ## Results: n=1481, mean=1130.727 and stdev=1757.158 #10b Medicaid discharge -2012 ## N mytable <- table(hmgtdata12$total_hospital_medicaid_discharg) summary(mytable) ##Mean mean(hmgtdata12$total_hospital_medicaid_discharg,na.rm=TRUE) ##StDev sd(hmgtdata12$total_hospital_medicaid_discharg,na.rm=TRUE) ## Results: n=1498, mean=1119.547 and stdev=1740.423 ### Running a T test to find the p-value #factor variable for year aggregate(total_hospital_medicaid_discharg ~ year, hmgtdata, mean) year1 <- as.factor(hmgtdata$year) t.test(hmgtdata$total_hospital_medicaid_discharg, hmgtdata$year1, paired = F) ## p-value = < 2.2e-16 ###END