Last data update: 2014.03.03

R: medpar
medparR Documentation

medpar

Description

The US national Medicare inpatient hospital database is referred to as the Medpar data, which is prepared yearly from hospital filing records. Medpar files for each state are also prepared. The full Medpar data consists of 115 variables. The national Medpar has some 14 million records, with one record for each hospilitiztion. The data in the medpar file comes from 1991 Medicare files for the state of Arizona. The data are limited to only one diagnostic group (DRG 112). Patient data have been randomly selected from the original data.

Usage

data(medpar)

Format

A data frame with 1495 observations on the following 10 variables.

los

length of hospital stay

hmo

Patient belongs to a Health Maintenance Organization, binary

white

Patient identifies themselves as Caucasian, binary

died

Patient died, binary

age

Patient age range, categorical

age80

Patient age 80 and over, binary

type

Type of admission, categorical

type1

Elective admission, binary

type2

Urgent admission,binary

type3

Elective admission, binary

provnum

Provider ID

Details

medpar is saved as a data frame. Count models use los as response variable. 0 counts are structurally excluded. The data is also used to predict death as well as to understand the predictors which bear on the death of a patient while in the hospital following surgery.

Source

1991 National Medpar data, National Health Economics & Research Co.

References

Hilbe, Joseph M (2015), Practical Guide to Logistic Regression, Chapman & Hall/CRC.

Hilbe, Joseph M (2014), Modeling Count Data, Cambridge University Press.

Hilbe, Joseph M (2007, 2011), Negative Binomial Regression, Cambridge University Press.

Hilbe, Joseph M (2009), Logistic Regression Models, Chapman & Hall/CRC.

first used in Hardin, JW and JM Hilbe (2001, 2007), Generalized Linear Models and Extensions, Stata Press.

Examples

# library(MASS)  if not automatically loaded

# medpar in both LOGIT and COUNT packages
library(LOGIT)
data(medpar)
glmb <- glm( died ~ los + hmo + white + factor(type), family=binomial, data=medpar)
summary(glmb)
toOR(glmb)

library(LOGIT)
data(medpar)
summary(glmpb <- glm( died ~ los + hmo + white + factor(type),
                family=binomial(link=probit), data=medpar))

library(LOGIT)     # or library(COUNT)
data(medpar)
medpar$los<-as.numeric(medpar$los)
glmpb <- glm(los ~ hmo + white + factor(type), family=poisson, data=medpar)
summary(glmpb)
exp(coef(glmpb))
toRR(glmpb)

#library(COUNT)    # nbinomial in both COUNT and msme packages
#data(medpar)
#nb2 <- nbinomial(los ~ hmo + white + factor(type), data=medpar)
#summary(nb2)
#exp(coef(nb2))

#library(LOGIT)    # or library(COUNT)
#data(medpar)
#glmnb <- glm.nb(los ~ hmo + white + factor(type), data=medpar)
#summary(glmnb)
#exp(coef(glmnb))
#toRR(glmnb)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LOGIT)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LOGIT/medpar.rd_%03d_medium.png", width=480, height=480)
> ### Name: medpar
> ### Title: medpar
> ### Aliases: medpar
> ### Keywords: datasets
> 
> ### ** Examples
> 
> # library(MASS)  if not automatically loaded
> 
> # medpar in both LOGIT and COUNT packages
> library(LOGIT)
> data(medpar)
> glmb <- glm( died ~ los + hmo + white + factor(type), family=binomial, data=medpar)
> summary(glmb)

Call:
glm(formula = died ~ los + hmo + white + factor(type), family = binomial, 
    data = medpar)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.3869  -0.9307  -0.8356   1.3751   2.5346  

Coefficients:
               Estimate Std. Error z value Pr(>|z|)    
(Intercept)   -0.720149   0.219073  -3.287  0.00101 ** 
los           -0.037193   0.007799  -4.769 1.85e-06 ***
hmo            0.027204   0.151242   0.180  0.85725    
white          0.303663   0.209120   1.452  0.14647    
factor(type)2  0.417873   0.144318   2.896  0.00379 ** 
factor(type)3  0.933819   0.229412   4.070 4.69e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1922.9  on 1494  degrees of freedom
Residual deviance: 1881.2  on 1489  degrees of freedom
AIC: 1893.2

Number of Fisher Scoring iterations: 4

> toOR(glmb)
                  or  delta  zscore pvalue exp.loci. exp.upci.
(Intercept)   0.4867 0.1066 -3.2873 0.0010    0.3168    0.7477
los           0.9635 0.0075 -4.7693 0.0000    0.9489    0.9783
hmo           1.0276 0.1554  0.1799 0.8573    0.7640    1.3821
white         1.3548 0.2833  1.4521 0.1465    0.8992    2.0412
factor(type)2 1.5187 0.2192  2.8955 0.0038    1.1446    2.0152
factor(type)3 2.5442 0.5837  4.0705 0.0000    1.6228    3.9887
> 
> library(LOGIT)
> data(medpar)
> summary(glmpb <- glm( died ~ los + hmo + white + factor(type),
+                 family=binomial(link=probit), data=medpar))

Call:
glm(formula = died ~ los + hmo + white + factor(type), family = binomial(link = probit), 
    data = medpar)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.3725  -0.9284  -0.8359   1.3867   2.5427  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)   -0.45667    0.13086  -3.490 0.000483 ***
los           -0.02065    0.00448  -4.610 4.03e-06 ***
hmo            0.01756    0.09236   0.190 0.849203    
white          0.17801    0.12499   1.424 0.154385    
factor(type)2  0.25459    0.08873   2.869 0.004113 ** 
factor(type)3  0.57887    0.14144   4.093 4.26e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 1922.9  on 1494  degrees of freedom
Residual deviance: 1882.6  on 1489  degrees of freedom
AIC: 1894.6

Number of Fisher Scoring iterations: 4

> 
> library(LOGIT)     # or library(COUNT)
> data(medpar)
> medpar$los<-as.numeric(medpar$los)
> glmpb <- glm(los ~ hmo + white + factor(type), family=poisson, data=medpar)
> summary(glmpb)

Call:
glm(formula = los ~ hmo + white + factor(type), family = poisson, 
    data = medpar)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-5.3063  -1.8259  -0.6319   1.0081  15.3827  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)    2.33293    0.02721  85.744  < 2e-16 ***
hmo           -0.07155    0.02394  -2.988  0.00281 ** 
white         -0.15387    0.02741  -5.613 1.99e-08 ***
factor(type)2  0.22165    0.02105  10.529  < 2e-16 ***
factor(type)3  0.70948    0.02614  27.146  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 8901.1  on 1494  degrees of freedom
Residual deviance: 8142.7  on 1490  degrees of freedom
AIC: 13868

Number of Fisher Scoring iterations: 5

> exp(coef(glmpb))
  (Intercept)           hmo         white factor(type)2 factor(type)3 
   10.3081316     0.9309504     0.8573826     1.2481366     2.0329271 
> toRR(glmpb)
                   rr  delta  zscore pvalue exp.loci. exp.upci.
(Intercept)   10.3081 0.2805 85.7439 0.0000    9.7728   10.8728
hmo            0.9310 0.0223 -2.9882 0.0028    0.8883    0.9757
white          0.8574 0.0235 -5.6131 0.0000    0.8125    0.9047
factor(type)2  1.2481 0.0263 10.5288 0.0000    1.1977    1.3007
factor(type)3  2.0329 0.0531 27.1457 0.0000    1.9314    2.1398
> 
> #library(COUNT)    # nbinomial in both COUNT and msme packages
> #data(medpar)
> #nb2 <- nbinomial(los ~ hmo + white + factor(type), data=medpar)
> #summary(nb2)
> #exp(coef(nb2))
> 
> #library(LOGIT)    # or library(COUNT)
> #data(medpar)
> #glmnb <- glm.nb(los ~ hmo + white + factor(type), data=medpar)
> #summary(glmnb)
> #exp(coef(glmnb))
> #toRR(glmnb)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>