Introduction and Questions Posed

We analyzed the providerspokane dataset in order to find relationships in the data that paint a picture of the overall Spokane healthcare scene. This data analyzes numeric variables like Medicare payment amounts, number of services, Medicare submitted amounts, and beneficiary per day services. Our analysis was based around how these numeric variables are different when we take gender of the provider, provider type, HCPCS code, and facility type. We looked at the distribution and means of these variables in relation to another as well as the Medicare submitted amount vs the paid amount as a function of the grouping variables. Our data analysis ultimately revolved around questions like “What are the most common procedures?”, “Do Male providers receive higher medicare payments than female?”, and “Is there a relationship between the number of services at facilities or non-facilities?”

Explicit Questions posed:

  1. Study how the distributions and means of the number of services, distinct beneficiary per day services, average medicare submitted charged amounts, average medicare paid amount vary as a function of Gender, the Provider Type, and Place of Service, and type of service that is being provided.

  2. Study the relationship between average submitted charge amount and average medicare payment amount and analyze how the relationship of these variables varies as a function of the number of services, distinct beneficiary per day services, and Provider Type.

Conclusion and Limitations

The analysis ultimately found certain features of the healthcare industry that stood out. The first is that ambulance services (ground, helicopter, and plane) were the most expensive on average and had some of the highest submitted costs. We also noticed that the amount submitted to Medicare to cover costs was almost always higher than the actual amount that Medicare paid. This suggests that Medicare either negotiated the price down from the original amount or Medicare did not cover the full amount and the rest of the amount was covered out of pocket. Lastly, we found that male providers on average have a higher submitted amount and amount paid than female providers. These findings offer suggestions and insights into the healthcare industry that there may be flaws in equality or areas that create higher than necessary costs.

One of the potential limitations of our data analysis is sample size of certain nominal variables such as HCPCS codes. Some of the codes are very specific and do not occur frequently, which can result in some codes deviating from the true mean for submitted amount and amount paid.

load("/Users/kimberlytang/Desktop/DataViz/project1/providerspokane.RDA")
load("providerspokane.RDA")
names(providerspokane)
##  [1] "National.Provider.Identifier"                            
##  [2] "Last.Name.Organization.Name.of.the.Provider"             
##  [3] "First.Name.of.the.Provider"                              
##  [4] "Middle.Initial.of.the.Provider"                          
##  [5] "Credentials.of.the.Provider"                             
##  [6] "Gender.of.the.Provider"                                  
##  [7] "Entity.Type.of.the.Provider"                             
##  [8] "Street.Address.1.of.the.Provider"                        
##  [9] "Street.Address.2.of.the.Provider"                        
## [10] "City.of.the.Provider"                                    
## [11] "Zip.Code.of.the.Provider"                                
## [12] "State.Code.of.the.Provider"                              
## [13] "Country.Code.of.the.Provider"                            
## [14] "Provider.Type"                                           
## [15] "Medicare.Participation.Indicator"                        
## [16] "Place.of.Service"                                        
## [17] "HCPCS.Code"                                              
## [18] "HCPCS.Description"                                       
## [19] "HCPCS.Drug.Indicator"                                    
## [20] "Number.of.Services"                                      
## [21] "Number.of.Medicare.Beneficiaries"                        
## [22] "Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services"
## [23] "Average.Medicare.Allowed.Amount"                         
## [24] "Average.Submitted.Charge.Amount"                         
## [25] "Average.Medicare.Payment.Amount"                         
## [26] "Average.Medicare.Standardized.Amount"
library(tidyverse)
## ── Attaching packages ────────────────
## ✓ ggplot2 3.2.1     ✓ purrr   0.3.3
## ✓ tibble  2.1.3     ✓ dplyr   0.8.3
## ✓ tidyr   1.0.0     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.4.0
## ── Conflicts ─────────────────────────
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(ggplot2)
library(rattle)
## Rattle: A free graphical interface for data science with R.
## Version 5.3.0 Copyright (c) 2006-2018 Togaware Pty Ltd.
## Type 'rattle()' to shake, rattle, and roll your data.
library(magrittr)
## 
## Attaching package: 'magrittr'
## The following object is masked from 'package:purrr':
## 
##     set_names
## The following object is masked from 'package:tidyr':
## 
##     extract
summary(providerspokane)
##  National.Provider.Identifier
##  Min.   :1.003e+09           
##  1st Qu.:1.276e+09           
##  Median :1.509e+09           
##  Mean   :1.516e+09           
##  3rd Qu.:1.771e+09           
##  Max.   :1.993e+09           
##                              
##                         Last.Name.Organization.Name.of.the.Provider
##  PATHOLOGY ASSOCIATES MEDICAL LABORATORIES LLC:  491               
##  MUELLER                                      :  109               
##  KING                                         :  105               
##  JOHNSON                                      :  103               
##  JONES                                        :   99               
##  LEE                                          :   99               
##  (Other)                                      :17972               
##  First.Name.of.the.Provider Middle.Initial.of.the.Provider
##         :  964                     :3583                  
##  MICHAEL:  630              M      :1571                  
##  JOHN   :  469              J      :1569                  
##  DAVID  :  434              A      :1506                  
##  ROBERT :  410              L      :1299                  
##  WILLIAM:  324              D      :1273                  
##  (Other):15747              (Other):8177                  
##  Credentials.of.the.Provider Gender.of.the.Provider Entity.Type.of.the.Provider
##  MD     :7497                 :  964                I:18014                    
##  M.D.   :4871                F: 5558                O:  964                    
##         :1322                M:12456                                           
##  PA-C   : 904                                                                  
##  ARNP   : 873                                                                  
##  D.O.   : 313                                                                  
##  (Other):3198                                                                  
##  Street.Address.1.of.the.Provider Street.Address.2.of.the.Provider
##  801 S STEVENS ST: 1663                    :10058                 
##  122 W 7TH AVE   : 1194           SUITE 200:  538                 
##  400 E 5TH AVE   : 1176           SUITE 310:  421                 
##  910 W 5TH AVE   : 1038           SUITE 100:  345                 
##  101 W 8TH AVE   :  820           SUITE 700:  311                 
##  105 W 8TH AVE   :  802           SUITE 400:  306                 
##  (Other)         :12285           (Other)  : 6999                 
##  City.of.the.Provider Zip.Code.of.the.Provider State.Code.of.the.Provider
##  SPOKANE:18978        992042654: 1663          WA:18975                  
##                       992021334: 1176          WI:    2                  
##                       992042349: 1125          WY:    1                  
##                       992042966: 1062                                    
##                       992042307:  702                                    
##                       992042302:  607                                    
##                       (Other)  :12643                                    
##  Country.Code.of.the.Provider              Provider.Type  
##  US:18978                     Diagnostic Radiology: 2414  
##                               Internal Medicine   : 1809  
##                               Family Practice     : 1541  
##                               Physician Assistant : 1240  
##                               Nurse Practitioner  : 1214  
##                               Hematology/Oncology :  745  
##                               (Other)             :10015  
##  Medicare.Participation.Indicator Place.of.Service   HCPCS.Code   
##  N:    2                          F: 6157          99213  :  820  
##  Y:18976                          O:12821          99214  :  742  
##                                                    99204  :  316  
##                                                    99203  :  312  
##                                                    99232  :  286  
##                                                    99212  :  261  
##                                                    (Other):16241  
##                                                                   HCPCS.Description
##  Established patient office or other outpatient visit, typically 15 minutes:  820  
##  Established patient office or other outpatient, visit typically 25 minutes:  742  
##  New patient office or other outpatient visit, typically 45 minutes        :  316  
##  New patient office or other outpatient visit, typically 30 minutes        :  312  
##  Subsequent hospital inpatient care, typically 25 minutes per day          :  286  
##  Established patient office or other outpatient visit, typically 10 minutes:  261  
##  (Other)                                                                   :16241  
##  HCPCS.Drug.Indicator Number.of.Services Number.of.Medicare.Beneficiaries
##  N:17844              Min.   :    11.0   Min.   :   11.0                 
##  Y: 1134              1st Qu.:    20.0   1st Qu.:   17.0                 
##                       Median :    42.0   Median :   31.0                 
##                       Mean   :   291.2   Mean   :  101.8                 
##                       3rd Qu.:   115.0   3rd Qu.:   71.0                 
##                       Max.   :155972.0   Max.   :70013.0                 
##                                                                          
##  Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services
##  Min.   :    11.0                                        
##  1st Qu.:    19.0                                        
##  Median :    39.0                                        
##  Mean   :   154.1                                        
##  3rd Qu.:   101.0                                        
##  Max.   :155971.0                                        
##                                                          
##  Average.Medicare.Allowed.Amount Average.Submitted.Charge.Amount
##  Min.   :    0.019               Min.   :    0.23               
##  1st Qu.:   19.003               1st Qu.:   48.00               
##  Median :   56.170               Median :  132.00               
##  Mean   :  104.731               Mean   :  295.21               
##  3rd Qu.:  107.572               3rd Qu.:  276.00               
##  Max.   :29872.890               Max.   :45998.00               
##                                                                 
##  Average.Medicare.Payment.Amount Average.Medicare.Standardized.Amount
##  Min.   :    0.011               Min.   :    0.011                   
##  1st Qu.:   15.498               1st Qu.:   15.990                   
##  Median :   40.720               Median :   43.613                   
##  Mean   :   80.178               Mean   :   83.320                   
##  3rd Qu.:   81.984               3rd Qu.:   85.360                   
##  Max.   :23420.340               Max.   :21855.610                   
## 
str(providerspokane$Place.of.Service)
##  Factor w/ 2 levels "F","O": 1 1 2 2 2 2 2 2 1 2 ...
levels(providerspokane$Place.of.Service)=c("Facility","Non-Facility")

1. Mean Provider Type functions

Distribution of gender across type of service

ggplot(providerspokane, aes(Provider.Type, fill =Gender.of.the.Provider )) + geom_bar()+coord_flip()

This is just a count of gender in all the types of services.

Distribution of gender across average medicare submitted charged amounts

providerspokane%>%group_by(Gender.of.the.Provider)%>%summarise(Mean_submitted_charge_amount=mean(Average.Submitted.Charge.Amount))%>%filter(Gender.of.the.Provider!="")%>%ggplot(.,aes(Gender.of.the.Provider,Mean_submitted_charge_amount))+geom_bar(stat="identity")

This graph shows that the male providers submit higher charge amounts than the female providers do, on average.

Distribution of gender across distinct beneficiary per day services

providerspokane%>%group_by(Gender.of.the.Provider)%>%summarise(Mean_Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services=mean(Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services))%>%filter(Gender.of.the.Provider!="")%>%ggplot(.,aes(Gender.of.the.Provider,Mean_Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services))+geom_bar(stat="identity")

This graph shows that per day the number of beneficiary services provided is virtually equal in male and female providers.

Distribution of gender across average medicare paid amount

providerspokane%>%group_by(Gender.of.the.Provider)%>%summarise(Mean_Average.Medicare.Payment.Amount=mean(Average.Medicare.Payment.Amount))%>%filter(Gender.of.the.Provider!="")%>%ggplot(.,aes(Gender.of.the.Provider,Mean_Average.Medicare.Payment.Amount))+geom_bar(stat="identity")

This graph depicts the mean of the average medicare payment amount, across gender. Males, on average, pay more than females for the payments.

Average medicare payment at facilities and non-facilities

Place_AMPA = providerspokane%>%
  group_by(Place.of.Service)%>%
  summarise(mean_medicare_paid = mean(Average.Medicare.Payment.Amount))

ggplot(Place_AMPA, mapping = aes(Place.of.Service, mean_medicare_paid, fill = Place.of.Service)) +geom_bar(stat = "identity")

This shows that overall, the amount of medicare paid is greater at facilities than the amount of medicare paid at non facilities.

Average submitted charge amount for facilities and non-facilities

Place_ASCA = providerspokane%>%
  group_by(Place.of.Service)%>%
  summarise(mean_submitted_charge_amount = mean(Average.Submitted.Charge.Amount))

ggplot(Place_ASCA, mapping = aes(Place.of.Service, mean_submitted_charge_amount, fill = Place.of.Service)) +geom_bar(stat = "identity")

This graph demonstrates that the average charge for services is also greater at facilities than it is at non facilities.

Average number of services at facilities and non facilities

Place_ANOS = providerspokane%>%
  group_by(Place.of.Service)%>%
  summarise(average_number_of_services = mean(Number.of.Services))

ggplot(Place_ANOS, mapping = aes(Place.of.Service,average_number_of_services, fill = Place.of.Service )) +geom_bar(stat = "identity")

This graph shows that the number of services provided to patients is over 100% greater at non facilities than facilities.

Average number of beneficiary services per day at facilities and non-facilities

Place_ANBS = providerspokane%>%
  group_by(Place.of.Service)%>%
  summarise(average_number_of_beneficiary_services = mean(Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services))

ggplot(Place_ANBS, mapping = aes(Place.of.Service,average_number_of_beneficiary_services, fill = Place.of.Service )) +geom_bar(stat = "identity")

This graph demonstrates that the amount of beneficiary services covered by Medicare is much greater at non facilities than at facilities.

Function of Average Number of Services and Provider Type

library(rattle)
library(magrittr)
Provider_MNoS=providerspokane%>%
  group_by(Provider.Type)%>%
  summarise(mean_number_of_services=mean(Number.of.Services))
MNoS_sort <- arrange(Provider_MNoS, desc(mean_number_of_services))

ggplot(data = MNoS_sort, mapping = aes(reorder(Provider.Type, mean_number_of_services), mean_number_of_services)) + geom_bar(stat = 'identity') + ggtitle('Average of Number of Services by Provider Type') + labs(y = 'Average of Number of Services', x = 'Provider Type') + theme(axis.text.y = element_text(size = 8)) + coord_flip()

This demonstrates that ambulance service suppliers have the highest average number of services by far compared to any other provider type.

Function of Average Number of Distinct Beneficiary per Day Services and Provider Type

Provider_MNoDMBPDS=providerspokane%>%
  group_by(Provider.Type)%>%
  summarise(mean_distinct_beneficiaries=mean(Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services))
MNoDMBPDS_sort <- arrange(Provider_MNoDMBPDS, desc(mean_distinct_beneficiaries))

ggplot(data = MNoDMBPDS_sort, mapping = aes(reorder(Provider.Type, mean_distinct_beneficiaries), mean_distinct_beneficiaries)) + geom_bar(stat = 'identity') + ggtitle('Average of Number of Distinct Beneficiary per Day Services by Provider Type') + labs(y = 'Average of Number of Distinct Beneficiary per Day Services', x = 'Provider Type') + theme(axis.text.y = element_text(size = 8)) + coord_flip()

Ambulance service suppliers and clinical labs have the highest distinct medicare beneficiary per day services by far.

Function of Average Medicare Submitted Charge Amount and Provider Type

Provider_ASCA=providerspokane%>%
  group_by(Provider.Type)%>%
  summarise(mean_submitted_charge_amount=mean(Average.Submitted.Charge.Amount))
MSCA_sort <- arrange(Provider_ASCA, desc(mean_submitted_charge_amount))

ggplot(data = MSCA_sort, mapping = aes(reorder(Provider.Type, mean_submitted_charge_amount), mean_submitted_charge_amount)) + geom_bar(stat = 'identity') + ggtitle('Average of the Submitted Charge Amount by Provider Type') + labs(y = 'Average of the Submitted Charge Amount ($)', x = 'Provider Type') + theme(axis.text.y = element_text(size = 8)) + coord_flip()

This graph shows that ambulance services are by far the most expensive and the charge submitted for this type far exceeds any other.

Function of Average Medicare Paid and Provider Type

Provider_MMP=providerspokane%>%
  group_by(Provider.Type)%>%
  summarise(mean_medicare_paid=mean(Average.Medicare.Payment.Amount))
MMP_sort <- arrange(Provider_MMP, desc(mean_medicare_paid))

ggplot(data = MMP_sort, mapping = aes(reorder(Provider.Type, mean_medicare_paid), mean_medicare_paid)) + geom_bar(stat = 'identity') + ggtitle('Average of Amount Medicare Paid by Provider Type') + labs(y = 'Average of the Amount Medicare Paid ($)', x = 'Provider Type') + theme(axis.text.y = element_text(size = 8)) + coord_flip()

This graph demonstrates that the ambulance surgical center has the highest medicare paid. As this is one of the most expensive provider types, it means that it is also covered strongly by medicare.

2. Distribution Provider Type Functions

Distribution Function of Number of Services by Provider Type

ggplot(providerspokane,aes(Number.of.Services,fill=Provider.Type))+geom_density()+facet_wrap(.~Provider.Type, scales = "free") + theme(legend.position = 'none') + ggtitle('Distribution of Number of Services by Provider Type') + labs(y = 'Density', x = 'Number of Services')
## Warning: Groups with fewer than two data points have been dropped.

This data shows the individual number of services density graphs for every provider type with enough data points. This allows us to see where the bulk of procedures in each provider type range in the Number of Services.

Distribution Function of Number of Distinct Beneficiary per Day Services by Provider Type

ggplot(providerspokane,aes(Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services,fill=Provider.Type))+geom_density()+facet_wrap(.~Provider.Type, scales = "free") + theme(legend.position = 'none') + ggtitle('Distribution of Number of Distinct Beneficiary per Day Services by Provider Type') + labs(y = 'Density', x = 'Number of Distinct Medicare Beneficiary per Day Services')
## Warning: Groups with fewer than two data points have been dropped.

This data shows individual Number of Distinct Beneficiary per Day Services density graphs for every provider type with enough data points. This allows us to see where the bulk of procedures in each provider type range in Number of Distinct Beneficiary per Day Services.

Distribution Function of Average Medicare Submitted Charge Amount by Provider Type

ggplot(providerspokane,aes(Average.Submitted.Charge.Amount,fill=Provider.Type))+geom_density()+facet_wrap(.~Provider.Type, scales = "free") + theme(legend.position = 'none') + ggtitle('Distribution of Average Medicare Submitted Charge Amount by Provider Type') + labs(y = 'Density', x = 'Average Medicare Submitted Charge ($)')
## Warning: Groups with fewer than two data points have been dropped.

This data shows individual medicare submitted charge density graphs for every provider type with enough data points. This allows us to see where the bulk of procedures in each provider type range in average medicare submitted charge amount. For example, nearly all of Internal medicine’s procedures are low cost as indicated by the high pointed cluster on the left of the graph.

Distribution Function of Average Medicare Paid by Provider Type

ggplot(providerspokane,aes(Average.Medicare.Payment.Amount,fill=Provider.Type))+geom_density()+facet_wrap(.~Provider.Type, scales = "free") + theme(legend.position = 'none') + ggtitle('Distribution of Average Medicare Payment by Provider Type') + labs(y = 'Density', x = 'Average Medicare Payment ($)')
## Warning: Groups with fewer than two data points have been dropped.

This data shows individual medicare payment density graphs for every provider type with enough data points. This allows us to see where the bulk of procedures in each provider type range in average medicare payment.

Distribution Function of Average Medicare Paid by Average Submitted Charge Amount

ggplot(data = providerspokane[providerspokane$Average.Medicare.Payment.Amount<20000,], aes(x = Average.Medicare.Payment.Amount, y = Average.Submitted.Charge.Amount, color=Number.of.Services)) +
  geom_point(size = 1,alpha=.1)+geom_smooth(method="lm")

This graph demonstrates that on average more medicare is paid to services where the provider is male and less medicare is paid when the provider is female.

Distribution Function of Average Medicare Paid by Average Submitted Charge Amount

ggplot(data = providerspokane[providerspokane$Average.Medicare.Payment.Amount<20000,], aes(x = Average.Medicare.Payment.Amount, y = Average.Submitted.Charge.Amount)) +
  geom_point(size = 1) + facet_wrap(.~Provider.Type, scales="free")

Scatterplot with average submitted charge amount, average medicare payment amount as a function of the beneficiary number of services

ggplot(providerspokane, aes(x=Average.Submitted.Charge.Amount, y=Average.Medicare.Payment.Amount, color=Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services)) +
  geom_point(size = 1,alpha=.1) + geom_smooth(method = "loess", color ='red') + labs(y = "Average Medicare Payment", x = "Average Submitted Charge Amount", color = "Distinct Beneficiary per Day Services")

This graph demonstrates that the higher the cost of the service, the higher the medicare payment is, showing there is a positive relationship between charge amount and medicare payment amount.

3. Frequency of HCPCS Code Functions

Function of Average Number of Services and HCPCS Code

HCPCS_MNoS=providerspokane%>%
  group_by(HCPCS.Description)%>%
  summarise(mean_number_of_services=mean(Number.of.Services))
HCPCS_MNoS_sort <- arrange(HCPCS_MNoS, desc(mean_number_of_services))
HCPCS_MNoS_sort_25 <- as_data_frame(head(HCPCS_MNoS_sort,25))
## Warning: `as_data_frame()` is deprecated, use `as_tibble()` (but mind the new semantics).
## This warning is displayed once per session.
ggplot(data = HCPCS_MNoS_sort_25, mapping = aes(reorder(HCPCS.Description, mean_number_of_services), mean_number_of_services)) + geom_bar(stat = 'identity') + ggtitle('Average of Number of Services by HCPCS Code') + labs(y = 'Average of Number of Services', x = 'HCPCS Code') + theme(axis.text.y = element_text(size = 8)) + coord_flip() + scale_x_discrete(labels=c("Travel allowance one way in connection with medically necessary laboratory specimen collection drawn from home bound or nursing home bound patient; prorated trip charge." = "Travel allowance (Necessary lab specimen from home bound patient, prorated trip charge)", "Injection, abatacept, 10 mg (code may be used for medicare when drug administered under the direct supervision of a physician, not for use when drug is self administered)" = "Injection, abatacept, 10 mg (Non-self administered)"))

This data is significant since it shows that the highest average services are the amount of miles travelled by 3 types of ambulances (ground, plane, and helicopter). These occur on a higher average than any medical procedures.

Function of Average Number of Distinct Beneficiary per Day Services and HCPCS Code

HCPCS_MNoDBPDS=providerspokane%>%
  group_by(HCPCS.Description)%>%
  summarise(mean_number_of_Beneficiary=mean(Number.of.Distinct.Medicare.Beneficiary.Per.Day.Services))
HCPCS_MNoDBPDS_sort <- arrange(HCPCS_MNoDBPDS, desc(mean_number_of_Beneficiary))
HCPCS_MNoDBPDS_sort_25 <- as_data_frame(head(HCPCS_MNoDBPDS_sort,25))

ggplot(data = HCPCS_MNoDBPDS_sort_25, mapping = aes(reorder(HCPCS.Description, mean_number_of_Beneficiary), mean_number_of_Beneficiary)) + geom_bar(stat = 'identity') + ggtitle('Distinct Beneficiary per Day Services by HCPCS Code') + labs(y = 'Average Number of Distinct Beneficiary per Day Services', x = 'HCPCS Code') + theme(axis.text.y = element_text(size = 8)) + coord_flip() + scale_x_discrete(labels=c("Travel allowance one way in connection with medically necessary laboratory specimen collection drawn from home bound or nursing home bound patient; prorated trip charge." = "Travel allowance (Necessary lab specimen from home bound patient, prorated trip charge)", "Ambulance service, basic life support, non-emergency transport, (bls)" = "Basic life support, non emergency ambulance", "Ambulance service, advanced life support, emergency transport, level 1 (als1-emergency)" = "Advanced life support, emergency ambulance", "Ambulance service, basic life support, emergency transport (bls-emergency)" = "Basic life support, emergency ambulance")) +  theme(plot.title = element_text(hjust=0))

This data is significant as it shows that on average urine bacterial counts and lab travel are among the most commonly done services per distinct beneficiary.

Function of Average Medicare Submitted Charge Amount and HCPCS Code

HCPCS_MMSCA=providerspokane%>%
  group_by(HCPCS.Description)%>%
  summarise(mean_number_of_submitted=mean(Average.Submitted.Charge.Amount))
HCPCS_MMSCA_sort <- arrange(HCPCS_MMSCA, desc(mean_number_of_submitted))
HCPCS_MMSCA_sort_25 <- as_data_frame(head(HCPCS_MMSCA_sort,25))

ggplot(data = HCPCS_MMSCA_sort_25, mapping = aes(reorder(HCPCS.Description, mean_number_of_submitted), mean_number_of_submitted)) + geom_bar(stat = 'identity') + ggtitle('Mean Medicare Submitted Charge Amount by HCPCS Code') + labs(y = 'Average Medicare Submitted Charge Amount ($)', x = 'HCPCS Code') + theme(axis.text.y = element_text(size = 8)) + coord_flip() + scale_x_discrete(labels = c("Anesthesia for procedure on heart and great blood vessels on heart-lung machine, age 1 year or older, or re-operation more than 1 month after original procedure" = "Anesthesia (Procedure on heart and great blood vessels on heart-lung machine (age 1+))", "Open treatment of broken of lower forearm or growth plate separation with insertion of hardware 3 or more fragments" = "Insertion of 3+ hardware fragments to treat broken lower forearm or growthplate separation", "Injection of bone cement into body of middle spine bone accessed through the skin using imaging guidance" = "Image guided injection of bone cement in middle spine through skin", "Injection of bone cement into body of lower spine bone accessed through the skin using imaging guidance" = "Image guided injection of bone cement in lower spine through skin", "Abdominal removal of uterus (250 grams or less) with removal of tubes and/or ovaries using an endoscope" = "Abdominal removal of uterus (<250 g) with tube and/or ovary endoscopic removal", "Ambulance service, conventional air services, transport, one way (rotary wing)" = "One way air ambulance (helicopter)", "Ambulance service, conventional air services, transport, one way (fixed wing)" = "One way air ambulance (fixed wing plane)")) + theme(plot.title = element_text(hjust=0))

This graph is significant because it shows the few outliers at the top of the graph that had a large average payment submitted to Medicare. Air ambulance services and specialized surgeries like cochlear implants are among the most expensive.

Function of Average Medicare Paid and HCPCS Code

HCPCS_MMP=providerspokane%>%
  group_by(HCPCS.Description)%>%
  summarise(mean_medicare_paid=mean(Average.Medicare.Payment.Amount))
HCPCS_MMP_sort <- arrange(HCPCS_MMP, desc(mean_medicare_paid))
HCPCS_MMP_sort_25 <- as_data_frame(head(HCPCS_MMP_sort,25))

ggplot(data = HCPCS_MMP_sort_25, mapping = aes(reorder(HCPCS.Description, mean_medicare_paid), mean_medicare_paid)) + geom_bar(stat = 'identity') + ggtitle('Average of Amount Medicare Paid by HCPCS Code') + labs(y = 'Average of the Amount Medicare Paid ($)', x = 'HCPCS Code') + theme(axis.text.y = element_text(size = 8)) + coord_flip() + scale_x_discrete(labels= c("Ambulance service, conventional air services, transport, one way (rotary wing)" = "One way air ambulance (helicopter)", "Ambulance service, conventional air services, transport, one way (fixed wing)" = "One way air ambulance (fixed wing plane)", "Open treatment of broken of lower forearm or growth plate separation with insertion of hardware 3 or more fragments" = "Insertion of 3+ hardware pieces to treat broken lower forearm/growthplate separation", "Injection of bone cement into body of middle spine bone accessed through the skin using imaging guidance" = "Image guided injection of bone cement in middle spine through skin", "Injection of bone cement into body of lower spine bone accessed through the skin using imaging guidance" = "Image guided injection of bone cement in lower spine through skin"))

This graph is significant because it shows a few outliers at the top of the graph that require a large average payment amount. Those are air ambulance services and specialized surgeries like cochlear implants and forearm reconstruction. It should be noted that the paid amount for the top outcomes is almost half of the amount that was submitted.