library (help = "datasets" )
?USJudgeRatings
starting httpd help server ... done
View (USJudgeRatings)
clean_df <- USJudgeRatings
library (visdat)
vis_dat (USJudgeRatings)
Please cite as:
Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
stargazer (USJudgeRatings, type = "text" ,
covariate.labels = c ("Contempt" ,"Integrity" ,"Diligence" , "Case Flow Management" ,"Decisiveness" ,"Preparation" ,"Familiarity" ,"Sound Oral Rulings" ,"Sound Written Rulings" , "Physical Ability" ,"Judicial Appointments" , "Worthy of Retention" ))
====================================================
Statistic N Mean St. Dev. Min Max
----------------------------------------------------
Contempt 43 7.437 0.941 5.700 10.600
Integrity 43 8.021 0.770 5.900 9.200
Diligence 43 7.516 1.144 4.300 9.000
Case Flow Management 43 7.693 0.901 5.100 9.000
Decisiveness 43 7.479 0.860 5.400 8.700
Preparation 43 7.565 0.803 5.700 8.800
Familiarity 43 7.467 0.953 4.800 9.100
Sound Oral Rulings 43 7.488 0.949 5.100 9.100
Sound Written Rulings 43 7.293 1.010 4.700 8.900
Physical Ability 43 7.384 0.961 4.900 9.000
Judicial Appointments 43 7.935 0.940 4.700 9.100
Worthy of Retention 43 7.602 1.101 4.800 9.200
----------------------------------------------------
#Cleaning Data
clean_df <- USJudgeRatings
clean_df$ CONT <- as.numeric (clean_df$ CONT)
clean_df$ INTG <- NULL # irrelevant
clean_df$ CFMG <- NULL
str (USJudgeRatings)
'data.frame': 43 obs. of 12 variables:
$ CONT: num 5.7 6.8 7.2 6.8 7.3 6.2 10.6 7 7.3 8.2 ...
$ INTG: num 7.9 8.9 8.1 8.8 6.4 8.8 9 5.9 8.9 7.9 ...
$ DMNR: num 7.7 8.8 7.8 8.5 4.3 8.7 8.9 4.9 8.9 6.7 ...
$ DILG: num 7.3 8.5 7.8 8.8 6.5 8.5 8.7 5.1 8.7 8.1 ...
$ CFMG: num 7.1 7.8 7.5 8.3 6 7.9 8.5 5.4 8.6 7.9 ...
$ DECI: num 7.4 8.1 7.6 8.5 6.2 8 8.5 5.9 8.5 8 ...
$ PREP: num 7.1 8 7.5 8.7 5.7 8.1 8.5 4.8 8.4 7.9 ...
$ FAMI: num 7.1 8 7.5 8.7 5.7 8 8.5 5.1 8.4 8.1 ...
$ ORAL: num 7.1 7.8 7.3 8.4 5.1 8 8.6 4.7 8.4 7.7 ...
$ WRIT: num 7 7.9 7.4 8.5 5.3 8 8.4 4.9 8.5 7.8 ...
$ PHYS: num 8.3 8.5 7.9 8.8 5.5 8.6 9.1 6.8 8.8 8.5 ...
$ RTEN: num 7.8 8.7 7.8 8.7 4.8 8.6 9 5 8.8 7.9 ...
fullreg <-
lm (formula = CONT ~ . ,
data = clean_df)
library (MASS)
stepAIC (object = fullreg,
direction = "backward" )
Start: AIC=-4.35
CONT ~ DMNR + DILG + DECI + PREP + FAMI + ORAL + WRIT + PHYS +
RTEN
Df Sum of Sq RSS AIC
- RTEN 1 0.21040 24.622 -5.9760
- DILG 1 0.82876 25.240 -4.9094
- WRIT 1 0.84491 25.256 -4.8819
- PHYS 1 1.04970 25.461 -4.5346
- DECI 1 1.06803 25.479 -4.5037
- FAMI 1 1.13326 25.544 -4.3938
<none> 24.411 -4.3450
- PREP 1 1.20765 25.619 -4.2687
- ORAL 1 2.12354 26.535 -2.7583
- DMNR 1 2.64254 27.054 -1.9253
Step: AIC=-5.98
CONT ~ DMNR + DILG + DECI + PREP + FAMI + ORAL + WRIT + PHYS
Df Sum of Sq RSS AIC
- DILG 1 0.67502 25.297 -6.8130
- PHYS 1 0.84087 25.462 -6.5320
- WRIT 1 0.87145 25.493 -6.4804
- PREP 1 1.09104 25.712 -6.1116
- FAMI 1 1.12490 25.746 -6.0550
- DECI 1 1.12851 25.750 -6.0490
<none> 24.622 -5.9760
- DMNR 1 2.91906 27.541 -3.1583
- ORAL 1 2.96452 27.586 -3.0874
Step: AIC=-6.81
CONT ~ DMNR + DECI + PREP + FAMI + ORAL + WRIT + PHYS
Df Sum of Sq RSS AIC
- PREP 1 0.4600 25.756 -8.0381
- PHYS 1 0.6005 25.897 -7.8041
- DECI 1 0.6459 25.942 -7.7289
- FAMI 1 0.8189 26.115 -7.4431
- WRIT 1 0.9652 26.262 -7.2028
<none> 25.297 -6.8130
- DMNR 1 3.1713 28.468 -3.7344
- ORAL 1 3.2495 28.546 -3.6165
Step: AIC=-8.04
CONT ~ DMNR + DECI + FAMI + ORAL + WRIT + PHYS
Df Sum of Sq RSS AIC
- FAMI 1 0.4084 26.165 -9.3616
- PHYS 1 1.0882 26.845 -8.2586
<none> 25.756 -8.0381
- WRIT 1 1.3754 27.132 -7.8011
- DECI 1 1.7222 27.479 -7.2549
- DMNR 1 2.9352 28.692 -5.3975
- ORAL 1 4.4656 30.222 -3.1629
Step: AIC=-9.36
CONT ~ DMNR + DECI + ORAL + WRIT + PHYS
Df Sum of Sq RSS AIC
- PHYS 1 1.0027 27.168 -9.7446
<none> 26.165 -9.3616
- DECI 1 2.0388 28.204 -8.1351
- DMNR 1 3.1762 29.341 -6.4351
- ORAL 1 4.1169 30.282 -5.0780
- WRIT 1 5.2394 31.404 -3.5129
Step: AIC=-9.74
CONT ~ DMNR + DECI + ORAL + WRIT
Df Sum of Sq RSS AIC
<none> 27.168 -9.7446
- DECI 1 1.5072 28.675 -9.4228
- DMNR 1 2.7768 29.944 -7.5600
- ORAL 1 3.2992 30.467 -6.8163
- WRIT 1 4.4821 31.650 -5.1784
Call:
lm(formula = CONT ~ DMNR + DECI + ORAL + WRIT, data = clean_df)
Coefficients:
(Intercept) DMNR DECI ORAL WRIT
7.3180 -0.5912 0.8183 2.8270 -3.0128
reg1 <-
lm (formula = CONT ~ DMNR + DECI + ORAL + WRIT, data = clean_df)