EXERCISE 3 AND 4

profilejamex.a.bowher2s
Week3.docx

# Week 3 & 4 # Step 1: Install package dplyr & read it, if you install it for the week 2 , you do not need to install again install.packages('dplyr') library(dplyr)

# Step 2: Read your data # Pl change the location of file hosp <- read.csv("C:/Users/hzare/Dropbox/HMGT400HOSPITAL.csv", header=T, sep = ',')

#Step 3: See the variables' names names (hosp)

#step 4 : generate benefit variable hosp$benefit <- (hosp$total_hosp_revenue-hosp$total_hosp_cost)

#step 5 : Define herf_cat as a categorical variable herfindahl <- group_by(hosp, herf_cat)

# Step 6: See the means  # Note: 0=High Competevie #       1=Moderate Competevie #       2=low Competevie

summarize (herfindahl, bed=mean(hospital_beds, na.rm=T),            payer=mean(total_hospital_employees_on_payr, na.rm=T),            nopayer=mean(total_hospital_non_paid_workers, na.rm=T),            resident=mean(interns_and_residents, na.rm=T),            member=mean(system_member, na.rm=T),                        cost=mean(total_hosp_cost, na.rm=T),            revenue=mean(log_hosp_revenue, na.rm=T),            benefit=mean(benefit, na.rm=T),                        medicare=mean(total_hospital_medicare_days, na.rm=T),            mediciad=mean(total_hospital_medicaid_days, na.rm=T),                        totdis=mean(total_hospital_discharges, na.rm=T),            mediciaredis=mean(total_hospital_medicare_discharg, na.rm=T),            mediciaddis=mean(total_hospital_medicaid_discharg, na.rm=T),                        herf_index=mean(herf_index, na.rm=T))

# Step 7: See the SD  summarize (herfindahl, bed=sd(hospital_beds, na.rm=T),            payer=sd(total_hospital_employees_on_payr, na.rm=T),            nopayer=sd(total_hospital_non_paid_workers, na.rm=T),            resident=sd(interns_and_residents, na.rm=T),            member=sd(system_member, na.rm=T),                        cost=sd(total_hosp_cost, na.rm=T),            revenue=sd(log_hosp_revenue, na.rm=T),            benefit=sd(benefit, na.rm=T),                        medicare=sd(total_hospital_medicare_days, na.rm=T),            mediciad=sd(total_hospital_medicaid_days, na.rm=T),                        totdis=sd(total_hospital_discharges, na.rm=T),            mediciaredis=sd(total_hospital_medicare_discharg, na.rm=T),            mediciaddis=sd(total_hospital_medicaid_discharg, na.rm=T),                        herf_index=sd(herf_index, na.rm=T))

# To find the N use following commands # Step 8: Generate 2 dataset for a ttest. high_compt <- subset(hosp, hosp$herf_cat==0) moderate_compt <- subset(hosp, hosp$herf_cat==1) low_compt <- subset(hosp, hosp$herf_cat==2)

#8-1  number of beds in high competetive market mytable <- table(high_compt$hospital_beds) summary(mytable)

#8-2  number of beds in moderate competetive market mytable <- table(moderate_compt$hospital_beds) summary(mytable)

#8-3  number of beds in low competetive market mytable <- table(low_compt$hospital_beds) summary(mytable)

#Note 2:  For other variables just replace the name of variables with hospital_beds

#9 The exercise asks you to report Anova, you can report chi-squire as well #9A This is the test for chi-sq bed = table(hosp$hospital_beds, hosp$herf_cat) chisq.test(bed)

# Ignore warning message after running chi-sq

#9B This is the test for Anova bed =lm(hosp$hospital_beds ~ hosp$herf_cat) anova(bed)

# Thank you

#

Week

3

&

4

#

Step

1:

Install

package

dplyr

&

read

it,

if

you

install

it

for

the

week

2

,

you

do

not

need

to

install

again

install.packages('dplyr')

library(dplyr)

#

Step

2:

Read

your

data

#

Pl

change

the

location

of

file

hosp

<

-

read.csv("C:/Users/hzare/Dropbox/

HMGT400HOSPITAL.csv",

header=T,

sep

=

',')

#Step

3:

See

the

variables'

names

names

(hosp)

#step

4

:

generate

benefit

variable

hosp$benefit

<

-

(hosp$total_hosp_revenue

-

hosp$total_hosp_cost)

#step

5

:

Define

herf_cat

as

a

categorical

variable

herfindahl

<

-

group_by(hosp,

herf_cat)

#

Step

6:

See

the

means

#

Note:

0=High

Competevie

#

1=Moderate

Competevie

#

2=low

Competevie

summarize

(herfindahl,

bed=mean(hospital_beds,

na.rm=T),

payer=mean(total_hospital_employees_on_payr,

na.rm=T),

nopayer=mean(total_hospital_non_paid_workers,

na.rm=T),

resident=mean(interns_and_residents,

na.rm=T),

member=mean(system_member,

na.rm=T),

cost=mean(total_hosp_cost,

na.rm=T),

revenue=mean

(log_hosp_revenue,

na.rm=T),

benefit=mean(benefit,

na.rm=T),

medicare=mean(total_hospital_medicare_days,

na.rm=T),

mediciad=mean(total_hospital_medicaid_days,

na.rm=T),

totdis=mean(total_h

ospital_discharges,

na.rm=T),

mediciaredis=mean(total_hospital_medicare_discharg,

na.rm=T),

mediciaddis=mean(total_hospital_medicaid_discharg,

na.rm=T),

herf_index=mean(herf_index,

na.rm=T))

#

Step

7:

See

the

SD

summarize

(herfindahl,

bed=sd(hospital_beds,

na.rm=T),

payer=sd(total_hospital_employees_on_payr,

na.rm=T),

nopayer=sd(total_hospital_non_paid_workers,

na.rm=T),

resident=sd(interns_and_residents,

na.rm=T),

mem

ber=sd(system_member,

na.rm=T),

cost=sd(total_hosp_cost,

na.rm=T),

revenue=sd(log_hosp_revenue,

na.rm=T),

benefit=sd(benefit,

na.rm=T),

medicare=sd(total_hospital_medicare_days,

na.rm=T),

mediciad=sd(total_hospital_medicaid_days,

na.rm=T),

totdis=sd(total_hospital_discharges,

na.rm=T),

mediciaredis=sd(total_hospital_medicare_discharg,

na.rm=T),

mediciaddis=sd(total_hospital_medicaid_di

scharg,

na.rm=T),

# Week 3 & 4

# Step 1: Install package dplyr & read it, if you install it for the week 2 ,

you do not need to install again

install.packages('dplyr')

library(dplyr)

# Step 2: Read your data

# Pl change the location of file

hosp <- read.csv("C:/Users/hzare/Dropbox/HMGT400HOSPITAL.csv", header=T, sep

= ',')

#Step 3: See the variables' names

names (hosp)

#step 4 : generate benefit variable

hosp$benefit <- (hosp$total_hosp_revenue-hosp$total_hosp_cost)

#step 5 : Define herf_cat as a categorical variable

herfindahl <- group_by(hosp, herf_cat)

# Step 6: See the means

# Note: 0=High Competevie

# 1=Moderate Competevie

# 2=low Competevie

summarize (herfindahl, bed=mean(hospital_beds, na.rm=T),

payer=mean(total_hospital_employees_on_payr, na.rm=T),

nopayer=mean(total_hospital_non_paid_workers, na.rm=T),

resident=mean(interns_and_residents, na.rm=T),

member=mean(system_member, na.rm=T),

cost=mean(total_hosp_cost, na.rm=T),

revenue=mean(log_hosp_revenue, na.rm=T),

benefit=mean(benefit, na.rm=T),

medicare=mean(total_hospital_medicare_days, na.rm=T),

mediciad=mean(total_hospital_medicaid_days, na.rm=T),

totdis=mean(total_hospital_discharges, na.rm=T),

mediciaredis=mean(total_hospital_medicare_discharg, na.rm=T),

mediciaddis=mean(total_hospital_medicaid_discharg, na.rm=T),

herf_index=mean(herf_index, na.rm=T))

# Step 7: See the SD

summarize (herfindahl, bed=sd(hospital_beds, na.rm=T),

payer=sd(total_hospital_employees_on_payr, na.rm=T),

nopayer=sd(total_hospital_non_paid_workers, na.rm=T),

resident=sd(interns_and_residents, na.rm=T),

member=sd(system_member, na.rm=T),

cost=sd(total_hosp_cost, na.rm=T),

revenue=sd(log_hosp_revenue, na.rm=T),

benefit=sd(benefit, na.rm=T),

medicare=sd(total_hospital_medicare_days, na.rm=T),

mediciad=sd(total_hospital_medicaid_days, na.rm=T),

totdis=sd(total_hospital_discharges, na.rm=T),

mediciaredis=sd(total_hospital_medicare_discharg, na.rm=T),

mediciaddis=sd(total_hospital_medicaid_discharg, na.rm=T),