Midterm

Ramya Murtha & Jeff DeWitt

3/5/2020

R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Question 1: Age (numeric)

t.test(bank$age ~ bank$y , conf.level = 0.9999)
Welch Two Sample t-test

data: bank\(age by bank\)y t = -4.7795, df = 5258.5, p-value = 1.805e-06 alternative hypothesis: true difference in means is not equal to 0 99.99 percent confidence interval: -1.8181931 -0.1857294 sample estimates: mean in group no mean in group yes 39.91119 40.91315

Question 2: Type Of Job

CrossTable(bank$job , bank$y , chisq = T )

Cell Contents |————————-| | N | | Chi-square contribution | | N / Row Total | | N / Col Total | | N / Table Total | |————————-|

Total Observations in Table: 41188

          | bank$y 
 bank$job |        no |       yes | Row Total | 

————–|———–|———–|———–| admin. | 9070 | 1352 | 10422 | | 3.423 | 26.961 | | | 0.870 | 0.130 | 0.253 | | 0.248 | 0.291 | | | 0.220 | 0.033 | | ————–|———–|———–|———–| blue-collar | 8616 | 638 | 9254 | | 19.926 | 156.951 | | | 0.931 | 0.069 | 0.225 | | 0.236 | 0.138 | | | 0.209 | 0.015 | | ————–|———–|———–|———–| entrepreneur | 1332 | 124 | 1456 | | 1.240 | 9.767 | | | 0.915 | 0.085 | 0.035 | | 0.036 | 0.027 | | | 0.032 | 0.003 | | ————–|———–|———–|———–| housemaid | 954 | 106 | 1060 | | 0.191 | 1.507 | | | 0.900 | 0.100 | 0.026 | | 0.026 | 0.023 | | | 0.023 | 0.003 | | ————–|———–|———–|———–| management | 2596 | 328 | 2924 | | 0.001 | 0.006 | | | 0.888 | 0.112 | 0.071 | | 0.071 | 0.071 | | | 0.063 | 0.008 | | ————–|———–|———–|———–| retired | 1286 | 434 | 1720 | | 37.814 | 297.849 | | | 0.748 | 0.252 | 0.042 | | 0.035 | 0.094 | | | 0.031 | 0.011 | | ————–|———–|———–|———–| self-employed | 1272 | 149 | 1421 | | 0.097 | 0.767 | | | 0.895 | 0.105 | 0.035 | | 0.035 | 0.032 | | | 0.031 | 0.004 | | ————–|———–|———–|———–| services | 3646 | 323 | 3969 | | 4.375 | 34.458 | | | 0.919 | 0.081 | 0.096 | | 0.100 | 0.070 | | | 0.089 | 0.008 | | ————–|———–|———–|———–| student | 600 | 275 | 875 | | 40.090 | 315.775 | | | 0.686 | 0.314 | 0.021 | | 0.016 | 0.059 | | | 0.015 | 0.007 | | ————–|———–|———–|———–| technician | 6013 | 730 | 6743 | | 0.147 | 1.156 | | | 0.892 | 0.108 | 0.164 | | 0.165 | 0.157 | | | 0.146 | 0.018 | | ————–|———–|———–|———–| unemployed | 870 | 144 | 1014 | | 0.985 | 7.758 | | | 0.858 | 0.142 | 0.025 | | 0.024 | 0.031 | | | 0.021 | 0.003 | | ————–|———–|———–|———–| unknown | 293 | 37 | 330 | | 0.000 | 0.001 | | | 0.888 | 0.112 | 0.008 | | 0.008 | 0.008 | | | 0.007 | 0.001 | | ————–|———–|———–|———–| Column Total | 36548 | 4640 | 41188 | | 0.887 | 0.113 | | ————–|———–|———–|———–|

Statistics for All Table Factors

Pearson’s Chi-squared test

Chi^2 = 961.2424 d.f. = 11 p = 4.189763e-199

Question 3: Marital Status

CrossTable(bank$marital , bank$y , chisq = T )

Cell Contents |————————-| | N | | Chi-square contribution | | N / Row Total | | N / Col Total | | N / Table Total | |————————-|

Total Observations in Table: 41188

         | bank$y 
bank$marital no yes Row Total
divorced 4136 476 4612
0.464 3.652
0.897 0.103 0.112
0.113 0.103
0.100 0.012
————- ———– ———– ———–
married 22396 2532 24928
3.450 27.174
0.898 0.102 0.605
0.613 0.546
0.544 0.061
————- ———– ———– ———–
single 9948 1620 11568
9.778 77.021
0.860 0.140 0.281
0.272 0.349
0.242 0.039
————- ———– ———– ———–
unknown 68 12 80
0.126 0.990
0.850 0.150 0.002
0.002 0.003
0.002 0.000
————- ———– ———– ———–
Column Total 36548 4640 41188
0.887 0.113
————- ———– ———– ———–

Statistics for All Table Factors

Pearson’s Chi-squared test

Chi^2 = 122.6552 d.f. = 3 p = 2.068015e-26

Question 4: Education

CrossTable(bank$education , bank$y , chisq = T )

Cell Contents |————————-| | N | | Chi-square contribution | | N / Row Total | | N / Col Total | | N / Table Total | |————————-|

Total Observations in Table: 41188

                | bank$y 
 bank$education |        no |       yes | Row Total | 

——————–|———–|———–|———–| basic.4y | 3748 | 428 | 4176 | | 0.486 | 3.829 | | | 0.898 | 0.102 | 0.101 | | 0.103 | 0.092 | | | 0.091 | 0.010 | | ——————–|———–|———–|———–| basic.6y | 2104 | 188 | 2292 | | 2.423 | 19.088 | | | 0.918 | 0.082 | 0.056 | | 0.058 | 0.041 | | | 0.051 | 0.005 | | ——————–|———–|———–|———–| basic.9y | 5572 | 473 | 6045 | | 8.065 | 63.527 | | | 0.922 | 0.078 | 0.147 | | 0.152 | 0.102 | | | 0.135 | 0.011 | | ——————–|———–|———–|———–| high.school | 8484 | 1031 | 9515 | | 0.198 | 1.561 | | | 0.892 | 0.108 | 0.231 | | 0.232 | 0.222 | | | 0.206 | 0.025 | | ——————–|———–|———–|———–| illiterate | 14 | 4 | 18 | | 0.244 | 1.918 | | | 0.778 | 0.222 | 0.000 | | 0.000 | 0.001 | | | 0.000 | 0.000 | | ——————–|———–|———–|———–| professional.course | 4648 | 595 | 5243 | | 0.004 | 0.032 | | | 0.887 | 0.113 | 0.127 | | 0.127 | 0.128 | | | 0.113 | 0.014 | | ——————–|———–|———–|———–| university.degree | 10498 | 1670 | 12168 | | 8.292 | 65.317 | | | 0.863 | 0.137 | 0.295 | | 0.287 | 0.360 | | | 0.255 | 0.041 | | ——————–|———–|———–|———–| unknown | 1480 | 251 | 1731 | | 2.041 | 16.079 | | | 0.855 | 0.145 | 0.042 | | 0.040 | 0.054 | | | 0.036 | 0.006 | | ——————–|———–|———–|———–| Column Total | 36548 | 4640 | 41188 | | 0.887 | 0.113 | | ——————–|———–|———–|———–|

Statistics for All Table Factors

Pearson’s Chi-squared test

Chi^2 = 193.1059 d.f. = 7 p = 3.305189e-38

Warning message: In chisq.test(t, correct = FALSE, …) : Chi-squared approximation may be incorrect > CrossTable(bank\(education , bank\)y , chisq = T )

Cell Contents |————————-| | N | | Chi-square contribution | | N / Row Total | | N / Col Total | | N / Table Total | |————————-|

Total Observations in Table: 41188

                | bank$y 
 bank$education |        no |       yes | Row Total | 

——————–|———–|———–|———–| basic.4y | 3748 | 428 | 4176 | | 0.486 | 3.829 | | | 0.898 | 0.102 | 0.101 | | 0.103 | 0.092 | | | 0.091 | 0.010 | | ——————–|———–|———–|———–| basic.6y | 2104 | 188 | 2292 | | 2.423 | 19.088 | | | 0.918 | 0.082 | 0.056 | | 0.058 | 0.041 | | | 0.051 | 0.005 | | ——————–|———–|———–|———–| basic.9y | 5572 | 473 | 6045 | | 8.065 | 63.527 | | | 0.922 | 0.078 | 0.147 | | 0.152 | 0.102 | | | 0.135 | 0.011 | | ——————–|———–|———–|———–| high.school | 8484 | 1031 | 9515 | | 0.198 | 1.561 | | | 0.892 | 0.108 | 0.231 | | 0.232 | 0.222 | | | 0.206 | 0.025 | | ——————–|———–|———–|———–| illiterate | 14 | 4 | 18 | | 0.244 | 1.918 | | | 0.778 | 0.222 | 0.000 | | 0.000 | 0.001 | | | 0.000 | 0.000 | | ——————–|———–|———–|———–| professional.course | 4648 | 595 | 5243 | | 0.004 | 0.032 | | | 0.887 | 0.113 | 0.127 | | 0.127 | 0.128 | | | 0.113 | 0.014 | | ——————–|———–|———–|———–| university.degree | 10498 | 1670 | 12168 | | 8.292 | 65.317 | | | 0.863 | 0.137 | 0.295 | | 0.287 | 0.360 | | | 0.255 | 0.041 | | ——————–|———–|———–|———–| unknown | 1480 | 251 | 1731 | | 2.041 | 16.079 | | | 0.855 | 0.145 | 0.042 | | 0.040 | 0.054 | | | 0.036 | 0.006 | | ——————–|———–|———–|———–| Column Total | 36548 | 4640 | 41188 | | 0.887 | 0.113 | | ——————–|———–|———–|———–|

Statistics for All Table Factors

Pearson’s Chi-squared test

Chi^2 = 193.1059 d.f. = 7 p = 3.305189e-38

Warning message: In chisq.test(t, correct = FALSE, …) : Chi-squared approximation may be incorrect > CrossTable(bank\(education , bank\)y , chisq = T )

Cell Contents |————————-| | N | | Chi-square contribution | | N / Row Total | | N / Col Total | | N / Table Total | |————————-|

Total Observations in Table: 41188

                | bank$y 
 bank$education |        no |       yes | Row Total | 

——————–|———–|———–|———–| basic.4y | 3748 | 428 | 4176 | | 0.486 | 3.829 | | | 0.898 | 0.102 | 0.101 | | 0.103 | 0.092 | | | 0.091 | 0.010 | | ——————–|———–|———–|———–| basic.6y | 2104 | 188 | 2292 | | 2.423 | 19.088 | | | 0.918 | 0.082 | 0.056 | | 0.058 | 0.041 | | | 0.051 | 0.005 | | ——————–|———–|———–|———–| basic.9y | 5572 | 473 | 6045 | | 8.065 | 63.527 | | | 0.922 | 0.078 | 0.147 | | 0.152 | 0.102 | | | 0.135 | 0.011 | | ——————–|———–|———–|———–| high.school | 8484 | 1031 | 9515 | | 0.198 | 1.561 | | | 0.892 | 0.108 | 0.231 | | 0.232 | 0.222 | | | 0.206 | 0.025 | | ——————–|———–|———–|———–| illiterate | 14 | 4 | 18 | | 0.244 | 1.918 | | | 0.778 | 0.222 | 0.000 | | 0.000 | 0.001 | | | 0.000 | 0.000 | | ——————–|———–|———–|———–| professional.course | 4648 | 595 | 5243 | | 0.004 | 0.032 | | | 0.887 | 0.113 | 0.127 | | 0.127 | 0.128 | | | 0.113 | 0.014 | | ——————–|———–|———–|———–| university.degree | 10498 | 1670 | 12168 | | 8.292 | 65.317 | | | 0.863 | 0.137 | 0.295 | | 0.287 | 0.360 | | | 0.255 | 0.041 | | ——————–|———–|———–|———–| unknown | 1480 | 251 | 1731 | | 2.041 | 16.079 | | | 0.855 | 0.145 | 0.042 | | 0.040 | 0.054 | | | 0.036 | 0.006 | | ——————–|———–|———–|———–| Column Total | 36548 | 4640 | 41188 | | 0.887 | 0.113 | | ——————–|———–|———–|———–|

Statistics for All Table Factors

Pearson’s Chi-squared test

Chi^2 = 193.1059 d.f. = 7 p = 3.305189e-38

Warning message: In chisq.test(t, correct = FALSE, …) : Chi-squared approximation may be incorrect > t.test(bank\(age ~ bank\)y , conf.level = 0.9999)

Welch Two Sample t-test

data: bank\(age by bank\)y t = -4.7795, df = 5258.5, p-value = 1.805e-06 alternative hypothesis: true difference in means is not equal to 0 99.99 percent confidence interval: -1.8181931 -0.1857294 sample estimates: mean in group no mean in group yes 39.91119 40.91315

Question 5: Has Credit in Default

Question 6: Has Housing Loan

Question 7: Has Personal Loan

Question 8: Contact Communication Type

Question 9: Last Contact Month of Year

Question 10: Last Contact Day of the Week

Question 11: Last Contact Duration in Seconds

Question 12: Number of Contacts This Campaign and For This Client

Question 13: Number of Days Passed Since Last Contact

Question 14: # of contacts Performed Before This Campaign and For This Client

Question 15: Outcome Of the Previous Marketing Campaign

Question 16: emp.var.rate: employment variation rate - quarterly indicator

Question 17: cons.price.idx: consumer price index - monthly indicator (numeric)

Question 18: cons.conf.idx: consumer confidence index - monthly indicator (numeric)

Question 19: euribor3m: euribor 3 month rate - daily indicator (numeric)

Question 20: nr.employed: number of employees - quarterly indicator (numeric)

Question 21: y - has the client subscribed a term deposit? (binary: ‘yes’,‘no’)

+++++++++++++++++++++++++++++++++++++

Slide with R Output

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Slide with Plot