Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Exam 3 (submit by Dec 1, 11:59 pm EST on Classes as a single PDF file) Instruction: This is the third of the 4 exams in BMB 620. Complete the following questions in RMarkdown and submitted the...

1 answer below »

Exam 3 (submit by Dec 1, 11:59 pm EST on Classes as a single PDF file)
Instruction: This is the third of the 4 exams in BMB 620. Complete the following questions in RMarkdown and submitted the generated PDF on Classes by the deadline. Make sure to show both the input and output.
1. Download the "leukemia_remission.txt" data from Classes. The data contain information on 27 leukemia patients. The response variable is whether leukemia remission has occu
ed (REMISS: 1=remiss; 0=no remiss). The predictors are cellularity of the ma
ow clot section (CELL), smear differential percentage of blasts (SMEAR), percentage of absolute ma
ow leukemia cell infiltrate (INFIL), percentage labeling index of the bone ma
ow leukemia cells (LI), absolute number of blasts in the peripheral blood (BLAST), and the highest temperature prior to start of treatment (TEMP).
a. Draw a scatterplot showing the relationship between the response and one of the predictors. Interpret the plot.
. Fit a logistic regression with REMISS as the response. Interpret the result.
c. Convert the model coefficients to probability of remiss. Interpret the result.
d. Use predict() to find the predicted probability of remiss using a new data set.
e. Build another logistic regression with different predictors. Compare the models in b and e.
f. Check the assumptions of your model in b.
2. Download the "CivilInjury_0.csv" data from Classes. The data contain the number of injuries during a fire in a day.
a. Extract the year and month from the `Injury Date` variable.
. Count the number of injuries within each month of each year.
c. Fit a Poisson regression with the number of injuries within a month of each year as the response. Interpret the result.
d. Check the assumptions of your model in c.
3. We want to randomly sample male and female college undergraduate students and ask them if they consume alcohol at least once a week. Our null hypothesis is no difference in the proportion. Our alternative hypothesis is that there is a difference. This is a two-sided alternative; one gender has higher proportion but we don't know which.
a. We would like to detect a difference as small as 5%. How many students do we need to sample in each group if we want 80% power and a significance level of 0.05?
. It turns out we were able to survey 543 males and 675 females. Find the power of our test if we're interested in being able to detect a “small” effect size with 0.05 significance.
c. Let's say we previously surveyed 763 female undergraduates and found that p% said they consumed alcohol once a week. We would like to survey some males and see if a significantly different proportion respond yes. How many do I need to sample to detect a small effect size (0.2) in either direction with 80% power and a significance level of 0.05?
4. Download the "USHospitals.txt" data from Classes. The data list outcome data on US hospitals, as reported by Medicare. In addition to the Provider variable (hospital id), there are 16 variables measured. The information of the 16 variables is below:
a. Use pairs() function to make pair-wise scatterplots between all 16 variables.
. Prepare the data for a principal component analysis (PCA).
c. Determine the number of components needed in your PCA.
d. Perform a PCA on the data. Extract the results and interpret the components.
e. Rotate the principal components and interpret the result.
5. Download the "hemangioma.txt" data from Classes. The data contain information on infants who were surgically treated for hemangioma. Hemangioma is the most common of all childhood cancer diagnoses. It appears as a lump of blood vessels on the skin. If left untreated it usually resolves within a few years. Some parents opt for surgical removal. Age (in days) and expression of genetic markers are given in the data.
a. Determine the number of factors in your exploratory factor analysis (EFA).
. Perform a EFA on the data.
c. Rotate the factors and interpret the result.

Age    RB    p16    DLK    Nanog    C-Myc    EZH2    IGF-2
81     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX
95    6.54    1.9    70988.3    381.83    1    7.09    5340.17
95    3.61    3.82     XXXXXXXXXX    237.28    0    5.57    6310.24
165     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX    0     XXXXXXXXXX     XXXXXXXXXX
286     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX
299     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX
380     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX
418    7.06    3.38     XXXXXXXXXX    264.62    1.17    3.07    8038.53
420    6.39    3.37     XXXXXXXXXX    658.75    1.88    3.87     XXXXXXXXXX
547    6.36    4.05     XXXXXXXXXX    336.11    0.78    4.76    6505.15
590     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX
635    6.7    2.67     XXXXXXXXXX    3072.5    0    4.35     XXXXXXXXXX
752     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX
760    7.33    0.92     XXXXXXXXXX    697.57    1.77    3.32     XXXXXXXXXX
1171     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX
1277    1.34    0.05    94.47    14.96    0.36    3.83    29.93
1520    4.02    2.79     XXXXXXXXXX    453.72    0.62    2.33    1162.69
2138    0.5    0    2330.59    33.11    0.03    0.17    66.49
3626     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX     XXXXXXXXXX

Provider    SDeathN    SDeathR    LungN    LungR    ClotN    ClotR    SplitN    SplitR    CutsN    CutsR    HADeathR    HADeathN    HFDeathR    HFDeathN    PDeathR    PDeathN
10001    157    140.58    15149    0.32    4941    1.47    393    0.9    15820    3.28    15    669    11.8    751    12.7    339
10005    29    123.92    4467    0.3    689    4.7    102    0.69    4584    1.5    17.3    35    14.7    213    15.9    339
10006    110    146.33    9962    0.5    2805    3.22    234    1.21    10577    3.09    18.6    307    12.6    563    15    785
10007    10    NA    2176    0.3    173    6.11    35    0.85    2220    1.74    NA    16    14.4    101    16.1    211
10008    NA    NA    673    0.33    28    4.52    NA    NA    707    1.9    NA    5    13.5    51    15.6    60
10011    173    143.09    10726    0.5    3776    4.58    340    1.55    11212    2.42    16.3    238    10.8    317    17.3    482
10012    25    124.21    3238    0.33    753    2.5    69    1.85    3360    2.12    16.2    100    16.4    134    15.8    243
10016    91    145.74    6551    0.21    2239    3.98    255    0.49    6907    2.03    14    213    13.2    257    13.1    318
10018    3    NA    93    0.34    73    4.36    NA    NA    93    1.98    NA    NA    NA    NA    NA    NA
10019    79    122.64    5638    0.27    1535    6.01    214    0.54    5728    2.51    17.2    70    11    277    15.3    331
10021    8    NA    1559    0.27    166    5.95    16    NA    1618    1.98    16.8    31    11.7    61    11.3    136
10022    NA    NA    1116    0.32    68    4.43    17    NA    1137    1.68    NA    8    11.6    56    13.6    101
10023    170    155.29    11283    0.24    4551    2.59    413    0.91    11648    2.02    18.2    307    10.8    404    14.1    184
10024    95    124.56    9776    0.26    2888    2.12    237    0.5    10061    2.19    17.3    225    10.4    457    15.7    320
10025    11    NA    2544    0.26    333    2.31    78    3.75    2717    1.93    14    72    9.9    165    11.4    117
10027    NA    NA    575    0.34    NA    NA    NA    NA    594    1.95    NA    3    NA    23    11.8    67
10029    145    141.06    11112    0.33    4139    2.39    362    1.55    11457    2.58    17.1    275    11.8    632    12.8    257
10032    NA    NA    695    0.32    3    NA    NA    NA    788    1.9    NA    12    11.8    49    13.7    103
10033    594    157.99    24057    0.71    10804    5.36    1617    0.4    26364    2.11    15.7    214    11.5    408    12.5    384
10034    7    NA    1450    0.3    103    4.11    21    NA    1596    1.98    NA    22    12.4    96    11.4    91
10035    54    165.41    6191    0.25    1550    2.81    173    0.58    6302    1.74    15.9    116    13.4    399    11.6    419
10036    19    NA    3265    0.27    540    5.08    75    0.76    3342    1.87    NA    16    11.7    150    11.4    238
10038    34    115.7    4672    0.35    1008    4.62    118    0.67    4882    1.98    16.5    67    12    194    11.8    215
10039    391    133.14    28969    0.24    10905    3.58    979    1.3    29981    1.89    15.4    1044    12.2    1414    12.9    910
10040    193    105.05    8787    0.66    2699    4.71    257    1.04    9063    1.71    16.7    218    11.2    365    15.5    408
10043    NA    NA    528    0.32    NA    NA    NA    NA    543    1.94    NA    2    11.3    30    12.6    52
10044    NA    NA    1065    0.32    35    4.51    16    NA    1107    2.13    NA    8    11.6    57    8.4    163
10045    6    NA    1398    0.31    51    5.73    23    NA    1442    2    16.7    28    12.5    101    12.9    163
10046    108    123.37    8002    0.16    1795    3.85    170    0.56    8381    0.76    16.6    129    11.5    372    13.7    345
10047    NA    NA    1520    0.32    NA    NA    NA    NA    1583    1.81    15.2    31    12.4    64    11.8    98
10049    6    NA    3465    0.37    575    3.97    98    0.79    3548    2.4    16.6    36    14.1    141    12.8    180
10050    NA    NA    1279    0.31    64    4.44    5    NA    1311    1.71    NA    19    12.4    58    16.6    135
10051    NA    NA    612    0.34    NA    NA    NA    NA    616    1.98    NA    1    11.2    34    11.6    34
10052    NA    NA    965    0.33    NA    NA    NA    NA    992    1.88    NA    6    10.7    37    9.8    87
10054    19    NA    3304    0.35    372    5.77    84    0.76    3403    2.18    16    33    11.2    189    12.8    210
10055    97    144.56    9736    0.23    3679    3.1    315    0.46    10048    1.85    13.4    320    12.7    500    11.1    437
10056    227    133.44    16369    0.49    6938    5.43    555    0.34    16407    2    15.3    268    11.1    477    12.8    515
10058    NA    NA    269    0.34    NA    NA    NA    NA    287    2.01    NA    2    NA    21    13.9    52
10059    NA    NA    1876    0.42    11    NA    NA    NA    1935    1.73    NA    22    10    75    9.6    141
10061    18    NA    3883    0.28    273    7.01    33    2.03    3981    1.9    14.6    26    13.2    127    12.5    361
10062    5    NA    1642    0.31    94    4.28    27    0.87    1742    1.49    NA    17    13.8    100    14    194
10065    35    92.86    3068    0.43    659    5    86    1.75    3155    3.72    17.2    72    12.3    157    16.2    187
10066    NA    NA    571    0.32    3    NA    NA    NA    576    1.94    NA    1    10.2    41    10.9    79
10069    NA    NA    1469    0.32    65    4.39    28    0.88    1494    1.61    NA    10    14.9    98    15.8    123
10073    NA    NA    1249    0.32    11    NA    6    NA    1269    1.8    NA    21    14.3    66    12.4    115
10078    155    132.64    9964    0.24    3286    4.89    313    3.22    10694    3.48    16.2    438    10.9    603    13.6    398
10079    15    NA    3284    0.33    381    6.84    74    0.76    3404    2.15    14.7    33    10.8    181    11.6    231
10083    44    115.25    4869    0.44    922    2.86    165    1.34    4993    2.07    15.9    70    14.3    284    10.5    264
10085    86    115.24    6444    0.36    1490    3.2    241    0.49    6736    2.51    15.6    68    12.8    394    12.9    346
10086    13    NA    2423    0.29    362    5.1    53    0.76    2637    1.48    14.1    28    11.5    83    13.3    246
10087    46    176.12    2210    0.63    902    6.26    142    0.6    2403    2.77    NA    10    NA    22    NA    22
10089    27    115.6    4605    0.21    1042    2.48    53    0.77    4525    1.16    16    66    11.1    224    11.2    276
10090    117    138.33    9259    0.44    3465    5.93    297    1.09    9632    2.74    15.7    202    13.5    488    11.4    483
10091    NA    NA    645    0.33    14    NA    4    NA    663    1.88    NA    4    10.5    54    11.5    45
10092    399    117.05    21658    0.38    5586    6.16    667    0.99    23084    1.31    14.7    398    12.6    883    12    790
10095    NA    NA    583    0.33    NA    NA    NA    NA    590    1.97    NA    7    10.2    39    11.2    29
10097    NA    NA    1381    0.31    NA    NA    NA    NA    1414    1.88    NA    16    11    37    11.7    70
10099    8    NA    2186    0.3    129    5.18    60    1.94    2227    3.2    15.9    28    13.8    101    13.3    168
10100    73    146.15    5702    0.33    2481    4.31    179    0.57    6346    3.38    16.8    170    13.6    299    13.9    185
10101    10    NA    2266    0.28    208    5.88    57    0.72    2306    2.15    16.8    35    15.6    119    11.1    105
10102    NA    NA    259    0.34    NA    NA    NA    NA    272    2.01    NA    2    NA    15    11.3    39
10103    259    124.73    11258    0.46    4487    4    496    0.8    12366    2.73    14.7    307    12.2    366    13.6    324
10104    219    138.31    10302    0.33    4083    5.81    437    0.36    10809    3.3    16    297    12.4    330    15.3    278
10108    7    NA    1759    0.3    87    4.06    35    0.8    1822    3.23    14    31    11.6    121    14.4    180
10109    4    NA    1321    0.31    65    4.17    26    0.88    1355    1.59    NA    11    14.6    60    12.6    152
10110    NA    NA    962    0.33    NA    NA    NA    NA    978    1.94    NA    3    12.2    38    12.4    27
10112    NA    NA    2708    0.3    207    3.74    18    NA    2751    1.49    NA    21    9.7    108    8.5    126
10113    269    163.02    21351    0.43    7200    9.17    866    0.53    22242    1.19    18.2    256    11.8    748    14.2    580
10114    63    155.25    4713    0.57    1013    4.06    171    0.58    4974    4.42    14.4    102    11.2    199    11.6    205
10118    67    110.13    5958    0.44    1039    6.39    122    0.68    6165    1.65    15.3    129    11.1    316    14.1    227
10120    3    NA    1578    0.43    41    4.52    21    NA    1624    2.43    NA    23    13.3    85    14.8    172
10125    3    NA    1968    0.31    65    5.76    23    NA    2046    1.97    NA    14    13.5    110    11.6    322
10126    9    NA    1784    0.3    155    3.89    31    0.84    1823    1.48    NA    19    10.3    83    11.9    120
10128    NA    NA    718    0.33    7    NA    NA    NA    730    1.91    NA    2    11.5    28    11.1    52
10129    9    NA    883    0.32    114    4.01    33    0.86    930    2.61    NA    10    11.8    42    14    90
10130    NA    NA    992    0.43    5    NA    NA    NA    1021    1.88    NA    5    10.8    89    11    158
10131    76    135.11    7868    0.28    2621    4.8    218    0.51    7542    2.57    12.9    182    13    308    12.1    328
10138    NA    NA    442    0.34    NA    NA    NA    NA    443    2.02    NA    2    NA    8    NA    7
10139    181    137.17    11614    0.3    4523    8.86    637    0.34    11568    2.08    15.9    254    13.4    405    12.8    513
10144    79    114.66    5110    0.63    1675    6.23    173    0.61    5484    3.01    15.7    128    12.5    344    14.1    197
10146    6    NA    1335    0.41    74    4.37    13    NA    1384    1.64    NA    24    14.2    48    16.9    126
10148    NA    NA    2079    0.32    22    NA    NA    NA    2134    1.72    NA    14    10.1    132    11.7    65
10149    33    117.48    4590    0.28    817    2.06    186    0.55    4698    1.77    13.7    79    9.7    293    10.3    212
10150    11    NA    1586    0.31    170    3.92    42    0.82    1634    3.69    NA    20    11.4    91    12.8    87
10157    28    137.03    1436    0.3    274    8.12    79    0.73    1535    2.07    NA    3    14    65    11.8    137
10158    36    118.89    2569    0.38    536    3.78    93    0.77    2603    3.75    13.8    31    13.7    114    14.1    219
10164    25    139.66    2998    0.45    333    4.59    122    1.62    3104    2.61    14.6    44    13    139    10.3    252
10168    35    106.95    2406    0.3    1990    4.53    13    NA    2194    1.31    NA    6    11.4    27    11.6    40
10169    3    NA    1583    0.31    55    4.3    18    NA    1622    1.92    NA    18    10.4    149    12.8    96
11300    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    3    NA    22    14.6    28
11302    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    2    12.6    26    10.8    42
11304    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    3
13301    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA
20001    142    98.62    7817    0.19    3287    2.87    335    0.45    8132    3.8    13.3    285    15.2    358    11.5    256
20006    27    117.98    2854    0.25    682    3.05    161    2.2    2973    3.57    17.7    67    14    126    12.4    197
20008    6    NA    1060    0.32    214    3.54    26    0.88    1079    1.56    NA    20    11.5    42    10.8    80
20012    32    114.94    2390    0.33    646    2.94    142    0.6    2494    2.87    15.2    79    14.8    103    13.2    97
20017    80    130.63    2832    0.3    1832    5.47    182    0.54    2900    1.84    15.2    78    13.4    74    14.1    68
20018    NA    NA    526    0.33    NA    NA    NA    NA    540    1.95    NA    1    11.2    33    9.5    137
20024    7    NA    1458    0.3    366    4.87    70    0.76    1534    2.01    NA    17    10.8    63    10.9    94
20026    52    128.06    2838    0.47    877    3.66    188    0.56    2894    3.63    15.9    38    13.4    73    14.2    150
20027    NA    NA    531    0.32    65    4.32    23    NA    549    2.67    NA    2    NA    16    15.5    39
21301    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    1    NA    3    NA    9
21302    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    3    NA    7    NA    10
21303    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    8    NA    9    11.4    31
21304    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    1    NA    6    NA    13
21305    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    4    NA    9    NA    18
21306    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    2    NA    21    11.6    40
21307    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    1    NA    2
21308    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    1    NA    15    11.9    26
21309    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    3    NA    7    NA    15
21311    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    10    11.2    28    13.1    77
21313    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    NA    9    NA    24    12.4    60
30001    3    NA    1153    0.29    83    5.41    10    NA    1204    1.98    NA    17    11.5    27    11.1    34
30002    401    87.13    18790    0.45    7937    3.15    1096    0.75    20073    1.85    14.2    179    9.9    302    11.1    182
30006    268    107.7    16237    0.45    7205    6.21    673    2.55    16898    2.37    14.4    368    13.6    449    11.9    443
30007    44    120.18    3487    0.34    1199    3.8    183    0.54    3698    1.02    18.3    136    10.2    160    12.4    210
30010    85    118.36    6523    0.21    1917    4.01    209    1.12    6701    1.49    18.4    180    12.8    183    9.9    207
30011    136    129.68    9412    0.23    3232    3.93    415    0.89    9584    3.53    17.3    201    10.4    319    14.8    408
30012    131    101.05    7340    0.65    2765    3.01    274    1.68    7760    3.13    14.9    298    12.6    222    11.8    382
30013    154    124.86    11207    0.31    2792    3.07    331    0.41    12152    2.35    11.7    526    12.8    508    16.7    935
30014    143    102.04    10296    0.37    3308    4.53    345    0.93    10911    2.73    15.7    96    11.5    229    11    168
30016    36    100.91    4574    0.52    999    5.28    182    1.33    4875    2.12    14.4    83    12.3    131    14    275
30022    44    130.67    2158    0.26    546    12.23    64    0.75    2331    2.34    NA    11    NA    10    NA    20
30023    102    133.17    6364    0.21    3174    2.66    230    0.43    6201    1.85    12.5    164    13.2    186    9.3    251
30024    376    80.89    12767    0.51    5826    5.43    520    0.9    12847    3.7    16.6    145    11.6    161    12.1    151
30030    123    92.49    4824    0.18    2123    4.19    224    1.26    5215    2.84    15.2    141    11    143    15.3    87
30033    37    79.12    2475    0.24    644    4.32    121    0.62    2619    1.46    NA    24    11.5    96    13    78
30036    98    109.51    7031    0.32    1988    2.89    214    1.2    7797    1.91    15.2    221    12.1    313    11.5    354
30037    42    97.66    2786    0.41    1596    2.53    97    0.74    2985    2.31    14.7    40    11.2    63    13.6    51
30038    188    77.56    11110    0.45    3809    3.7    300    0.95    11784    1.86    15    172    9.3    384    11.8    355
30043    38    111.34    4079    0.33    696    5.78    168    1.38    4351    3.76    16.8    145    11.8    207    10.9    238
30055    78    105.45    6508    0.34    1572    3.9    236    0.43    7057    3.37    16.4    179    9.9    289    12.9    448
30061    221    107.79    24223    0.23    7612    3.13    724    0.58    25772    1.24    15.2    465    12.2    636    10.9    577
30062    26    104.08    2233    0.26    811    5.07    128    0.64    2368    1.78    14.4    56    12.2    76    12    142
30064    242    99.94    10991    0.48    4148    3.15    618    0.67    12030    3.37    12.8    217    10.9    234    10.6    287
30065    180    100.63    10272    0.4    3432    3.89    587    1.11    10688    1.39    14.6    189    10.3    315    10.3    331
30067    5    NA    1094    0.37    163    3.94    39    0.8    1124    1.4    15.2    46    12    54    10.3    123
30068    4    NA    1208    0.31    216    3.54    27    0.85    1289    2.18    NA    13    15.5    51    11.5    153
30069    56    107.85    5653    0.19    2212    4.5    227    1.22    6044    2    18.4    242    12.8    286    15.4    249
30071    3    NA    830    0.31    103    4.28    26    0.88    867    1.67    NA    5    NA    21    10    169
30073    20    NA    1344    0.3    330    3.23    33    0.89    1391    1.45    NA    5    11.4    43    10.2    193
30074    NA    NA    93    0.34    NA    NA    NA    NA    94    2.04    NA    NA    NA    NA    NA    10
30077    NA    NA    29    0.34    NA    NA    NA    NA    29    2.05    NA    NA    NA    NA    NA    2
30078    NA    NA    372    0.45    92    5.53    24    NA    386    2.76    NA    NA    NA    4    10.7    37
30083    33    110.48    2158    0.45    552    3.27    72    0.77    2247    2.46    15.3    45    12.4    63    13.6    116
30084    4    NA    867    0.31    90    4.29    24    NA    888    1.63    NA    11    10.7    38    10.7    143
30085    136    79.97    9415    0.35    4179    4.16    361    1.58    9642    3.6    17.7    156    13.1    279    13.7    458
30087    189    104.9    12831    0.28    5706    4.17    645    0.61    13654    2.25    14    269    8.8    472    10.5    519
30088    118    75.45    14843    0.32    2917    4.37    555    1.86    15643    1.42    16.6    46    13.1    436    10.1    626
30089    162    76.56    9569    0.19    2682    4.64    325    1.48    10264    1.76    16.1    175    9    389    8    353
30092    119    83.73    6611    0.28    2219    5.4    209    1.22    7301    1.56    13.4    114    11.2    168    10    192
30093    89    97.75    12976    0.26    3180    3.4    345    0.4    13633    1.9    13.4    394    12.9    493    12.1    578
30094    64    87.43    4047    0.44    1466    4.02    128    1.53    4351    1.87    15    74    11.7    123    12    177
30100    47    96.62    2182    0.62    1042    4.23    20    NA    2580    5.39    13    188    10    185    12.7    87
30101    55    109.62    5802    0.44    1449    4.32    173    0.57    5962    1.24    15.8    180    11.8    313    12.3    211
30103    382    54.89    13619    0.34    6378    3    1025    0.73    14818    0.88    12.7    212    10.2    386    7.9    457
30105    62    95.24    4369    0.61    2425    2.65    26    0.88    5118    1.41    14.4    407    9.8    606    13.9    25
30107    12    NA    871    0.33    853    2.91    6    NA    723    1.75    NA    NA    NA    NA    NA    NA
30108    4    NA    780    0.33    750    2.78    NA    NA    358    1.26    NA    NA    NA    NA    NA    NA
30110    58    88.01    3589    0
Answered Same Day Dec 02, 2021

Solution

Subhanbasha answered on Dec 02 2021
108 Votes
Exam3
Catherine
December 2021
knitr::opts_chunk$set(echo = TRUE,warning = FALSE,messages=FALSE)
Question 1.a
li
ary(tinytex)
# Reading file
leuk <- read.table('leukemiaremission.txt',header = TRUE)

plot(REMISS~CELL,data=leuk,
main="Scatter Plot")
From the above scatter plot we can observe that CELL is incresed then it tends to
leukemia remission has occu
ed.
Question 1.
# Logistic model
logi <- glm(REMISS~.,data=leuk)

# Summary of the model
summary(logi)
##
## Call:
## glm(formula = REMISS ~ ., data = leuk)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.73148 -0.28640 0.01317 0.28326 0.61075
##
## Coefficients:
## Estimate Std. E
or t value Pr(>|t|)
## (Intercept) 5.001776 6.717355 0.745 0.4652
## CELL -0.222161 1.779991 -0.125 0.9019
## SMEAR -1.528849 3.387515 -0.451 0.6566
## INFIL 1.584228 3.850919 0.411 0.6852
## LI 0.535005 0.266740 2.006 0.0586 .
## BLAST -0.009178 0.335354 -0.027 0.9784
## TEMP -4.949192 6.692905 -0.739 0.4682
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1953698)
##
## Null deviance: 6.0000 on 26 degrees of freedom
## Residual deviance: 3.9074 on 20 degrees of freedom
## AIC: 40.433
##
## Number of Fisher Scoring iterations: 2
By observing the logistic regression model summary the p value of each independent
variable is greater than 0.05 so we can infer that non of the variables are significant in
the model.
Question 1.c
logit2prob <- function(logit){
odds <- exp(logit)
prob <- odds / (1 + odds)
return(prob)
}
logit2prob(coef(logi))
## (Intercept) CELL SMEAR INFIL LI BLAST
## 0.993318947 0.444687136 0.178162226 0.829802429 0.630649643 0.497705515
## TEMP
## 0.007039233
The variable INFIL has high probability than other variables that means it has hih
valuable in the model
Question 1.d
New_data<-data.frame(CELL=0.7,SMEAR=0.6,INFIL=0.8,LI=0.5,BLAST=0.6,TEMP=0.7)
predict(logi,newdata = New_data)
## 1
## 1.993898
Question 1.e
logi1 <- glm(REMISS~INFIL+LI+BLAST+CELL,data=leuk)
# Summary of the model
summary(logi1)
##
## Call:
## glm(formula = REMISS ~ INFIL + LI + BLAST + CELL, data = leuk)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.83660 -0.23042 -0.06619 0.23535 0.65026
##
## Coefficients:
## Estimate Std. E
or t value Pr(>|t|)
## (Intercept) -0.60229 0.45452 -1.325 0.1987
## INFIL 0.05614 0.56418 0.100 0.9216
## LI 0.54888 0.22975 2.389 0.0259 *
## BLAST -0.05043 0.26502 -0.190 0.8508
## CELL 0.43947 0.56918 0.772 0.4483
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1849362)
##
## Null deviance: 6.0000 on 26 degrees of freedom
## Residual deviance: 4.0686 on 22 degrees of freedom
## AIC: 37.524
##
## Number of Fisher Scoring iterations: 2
Comparing with the intial model the LI variable is significant in this model. Tha AIC
value is 37.524.
Question 1.f
plot(logi)
Question 2.a
li
ary(lu
idate)
##
## Attaching package: 'lu
idate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
civi <- read.csv('civilinjury0.csv')
unique(year(civi$Injury.Date))
## [1] 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016
unique(month(civi$Injury.Date))
## [1] 1 2 4 5 7 8 9 10 11 12 3 6
Question 2.
civi$year <- year(civi$Injury.Date)
civi$mon <- month(civi$Injury.Date)
agg <- aggregate(civi["Total.Injuries"], by=civi[c("year","mon")],FUN=sum)
agg
## year mon Total.Injuries
## 1 2005 1 11
## 2 2006 1 2
## 3 2007 1 2
## 4 2008 1 4
## 5 2009 1 6
## 6 2010 1 1
## 7 2011 1 4
## 8 2012 1 9
## 9 2013 1 2
## 10 2014 1 1
## 11 2015 1 5
## 12 2005 2 3
## 13 2006 2 3
## 14 2007 2 7
## 15 2009 2 2
## 16 2010 2 1
## 17 2011 2 3
## 18 2012 2 3
## 19 2013 2 5
## 20 2014 2 2
## 21 2015 2 2
## 22 2006 3 4
## 23 2007 3 1
## 24 2008 3 2
## 25 2009 3 1
## 26 2010 3 1
## 27 2011 3 1
## 28 2012 3 4
## 29 2013 3 1
## 30 2014 3 2
## 31 2015 3 1
## 32 2016 3 1
## 33 2005 4 3
## 34 2006 4 7
## 35 2007 4 1
## 36 2008 4 3
## 37 2010 4 7
## 38 2011 4 3
## 39 2013 4 1
## 40 2015 4 1
## 41 2005 5 2
## 42 2006 5 3
## 43 2007 5 3
## 44 2008 5 2
## 45 2009 5 5
## 46 2010 5 7
## 47 2011 5 1
## 48 2012 5 1
## 49 2013 ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here