Exam # 2: Quantitative Geography Fall 2016

NAME: Regina Mendicino ———————-

date()
## [1] "Thu Dec 15 16:47:11 2016"

Due Time: 5pm, December 15, 2016. NOTE: You have 2 (two) hours to complete this exam.

Each question is worth 25 points.

1 (25) Generate two population vectors (call them x1 and x2) each of length 1000 containing random values from a normal distribution. Let the first set of values have a mean of 5 and a standard deviation of 3 and the second set of values have a mean of 8 and a standard deviation of 2. Take a sample of size 15 from each population vector (call them s1 and s2). Create side-by-side box plots of the sample values. Test whether you can detect a significant difference in population means using these two samples.

x1 = rnorm(1000, mean = 5, sd = 3); x1
##    [1]  8.96828908  5.23568158  5.14554810 -0.77203856  4.72747330
##    [6]  2.62613547  3.88178183  9.16034554  8.86459201 -0.62492326
##   [11]  6.91629924  7.24981201  1.56382827  3.20628915  4.87776698
##   [16]  6.03338288  1.92933063 10.02822237  6.45399782  8.14111073
##   [21]  3.07099161  4.88731062  6.30911118  3.67403821  6.60040118
##   [26]  3.90365387  7.20242381 10.16585195  4.39631467  5.65399590
##   [31]  2.38074505  6.19349576  5.92920306  2.34545090  3.46231925
##   [36]  4.55546081  5.84082490  5.07840748  3.99760277  5.15942138
##   [41]  9.68094295  8.28624911 -0.94737709  9.73011257  4.56083656
##   [46]  8.19895131  5.71733718 -1.65985281  6.94135619  1.70445677
##   [51]  5.12767373  1.35863439 -0.60766665  3.78519765  3.72960552
##   [56]  5.22990397  8.34841870 10.14547373  9.20510576  4.34708073
##   [61]  1.20760022  5.14580021  7.13794580  2.53481708  9.05741105
##   [66] -0.75781873  2.53774904 -5.59404279  3.45066094  8.19114307
##   [71]  5.32241254  3.27111678  0.60601933  3.54455864  2.66194421
##   [76]  4.52218410  8.33161377  6.06505821  5.25934675  7.73048210
##   [81]  8.51132549  5.32010200  1.88554657  7.31055656  0.55312556
##   [86]  6.78795050  1.97841592  3.56351035  6.79937091  7.35992722
##   [91]  6.09411796  7.01618031  4.79351493  1.67830647  1.98613573
##   [96]  1.20448519  7.00588153  1.23971094  9.00621648  3.40615574
##  [101]  8.92046158  0.22223559 11.38633633  4.40148963  4.33840227
##  [106]  1.32484561  9.13492920  8.97807387  4.34931636  3.92893099
##  [111]  9.54690327  5.82024059  4.07095117  5.92982107  1.81533004
##  [116]  1.91486808  9.23924058  3.09705020  7.83726516  0.07347837
##  [121]  2.82646689  6.90527828  7.21320567 -1.78348878  7.80862359
##  [126]  8.81568363  6.74636938 -1.88454247  1.03192910  1.95125642
##  [131]  7.41678947  6.26632944  6.32050676 10.63028173  4.06244919
##  [136]  7.66755181  7.78260379  4.55087090  3.81914263  4.63450192
##  [141]  9.11229348  6.12193918  0.02270837  3.90145998  5.32892364
##  [146] -0.14151628  4.49382389  3.83860329  3.52425020  6.22050372
##  [151]  4.78156820  4.02432610 10.31689499  4.59800293  4.78018619
##  [156]  4.27664169  7.55102273  3.52712886  2.61817979  5.13981342
##  [161]  3.64286129  1.89817675  2.93142587  1.38567170  5.04962212
##  [166] 12.48123151  4.56226972  6.17398538  2.13862709  9.16623893
##  [171]  1.48618158  8.38315580  5.19218383  7.38160570  2.20293091
##  [176]  4.52215529  5.18831206 -0.92276905  3.17439968  7.53723104
##  [181]  9.11471723  7.33907981  6.99248166  1.61415113  6.53315877
##  [186]  8.21858609 -0.85388826  1.05038366 -2.94107522  5.27131478
##  [191]  0.71996504  1.85146341  5.96423944  0.55277884  7.67037734
##  [196]  6.67426799  1.51520812  5.72255316  0.30117539 10.56296543
##  [201]  2.25229620 -0.93252284  0.64777630  4.56336138  7.24777169
##  [206]  2.72884458  3.62897478  5.15004395  2.49287809  9.26866788
##  [211]  6.96977007  6.59421006  2.09336341  7.45868953  5.86256173
##  [216]  3.84311872  6.13029051  5.96748679 -3.02383214 10.24401232
##  [221]  7.22318612  8.66772145  8.80518983  4.74118121  7.91722950
##  [226]  4.46807624  4.52409866  5.60195070  3.75172311  4.67342845
##  [231]  6.60223231  6.14865891  3.18679165  6.46127076  0.95639589
##  [236]  1.28804713 10.51792001  6.74426628 10.89133883 10.49180788
##  [241]  8.88094855  7.94656833  7.72765631 11.58000044  6.55589336
##  [246] -0.70418431 -0.83213434 11.51558524  5.21717695  6.80283666
##  [251]  5.94275435  4.88197792 10.85377240  4.76455377  6.06063455
##  [256]  8.78176951  1.87831697  4.19932988  3.54570327  4.37123683
##  [261]  1.71367044  7.83325423  1.87928756  3.93329261  0.32311794
##  [266] 11.76023501  6.55057143  4.30817922  6.37231663  9.75697048
##  [271]  5.34000516  2.54654214  3.62741019  8.46065952  5.40704430
##  [276]  0.69246804  9.15523349  8.25803592  5.35253454  3.10250834
##  [281]  3.01929788  8.66016045  6.38804944  4.74421014  3.91348983
##  [286]  4.72606253  4.34542467  4.22062319  5.55853006  6.79696138
##  [291]  4.12471541  7.38904413  3.73508339  2.75146791  6.52505428
##  [296]  4.26027989 10.55302959  5.04823161  2.06884516  4.23187327
##  [301] 10.34985414  4.19259905  7.63462539  1.93797186  5.08704921
##  [306]  1.11214280  3.14519073  4.29636100  4.10195206  6.00629279
##  [311] -0.09283327  8.05542498  6.33485899  3.92954402  9.65107373
##  [316]  1.16081002  7.54746734  5.47636768  3.26273324  2.35760588
##  [321]  0.11819401  9.88456649  9.55023127  6.36201562  5.16562081
##  [326] -0.17182982  5.83111596  0.23257890  3.76821580  6.77772468
##  [331]  5.03634780  2.51337917  3.28440432  7.94881406  6.29972867
##  [336]  9.21995202  1.46316396  3.72873851 -0.28392787  6.18005013
##  [341]  5.21114178  2.62009436  8.06028025  3.51315915  6.85880543
##  [346]  8.77081688  1.66849976  0.22211127  4.72991754  3.68112988
##  [351]  4.91665554  5.89084845  4.07946201  7.00650714  3.40198720
##  [356]  3.47604741  8.00497748  3.74241944 -0.62797672  4.11010814
##  [361]  2.04721613  3.91722018  0.56124570  7.68665825  7.93857564
##  [366]  3.84311149  3.79211619  0.07105276  8.61363853  7.49628167
##  [371]  2.18565160  8.82899009  6.45045246  3.61378551  6.99321238
##  [376]  1.60737562  3.15725248  7.23153952  4.59240419 -2.95483439
##  [381]  4.53470954  5.52110178  3.01529010  6.90484589  5.03666530
##  [386]  5.91773846  3.91029395  6.62517222  9.63546982  4.95453116
##  [391]  5.83015856  9.77504141  4.91023587  5.39471513  1.12508664
##  [396]  1.42835205  1.33252670  0.62072318  2.99905854  0.85648311
##  [401] 10.42749778  2.87183035 -0.24757029  3.71980154  2.05805555
##  [406]  8.58335405  7.40779311  9.26500675  8.98110609  3.25499001
##  [411]  4.38377937  4.96914873  2.80866698  5.06398049  9.09672383
##  [416]  6.30664010  4.68731302  2.16569715  1.42098883  4.37030208
##  [421]  5.08663393  6.72965499  6.64521316  6.42561421  7.54888378
##  [426]  4.41708170  4.11683317  2.78719247  6.22246897 -1.45222911
##  [431]  4.26113607  8.30659390  2.11682082  3.31775502  1.83436918
##  [436]  6.80263346  7.93527876  1.05921817  1.04816778  6.66674642
##  [441]  2.71940504  1.23660553  6.44873737  5.72910297  2.81387608
##  [446]  5.28006062  7.40685156  8.68095360  5.33457633  4.83432995
##  [451]  2.15851327  6.49191978  9.60844947  1.76027239  1.60536624
##  [456]  5.21125205  6.85509519  3.70724702  5.37400204  8.98330320
##  [461]  2.02488318  8.47677984  5.46479915  6.28835963  4.62916266
##  [466]  8.23998182  3.36649495  6.32575014  3.59600305  9.15679016
##  [471]  6.62549534  0.67153324  6.54742439  4.93227296  6.63640308
##  [476]  3.68456941  7.18144034  1.81741035  4.56264362  7.64937017
##  [481]  2.32593810  1.11873643  4.05812976  1.79142390  6.95380192
##  [486]  2.02542243  8.29288412  8.26859075  2.54313039  3.63407241
##  [491]  0.16949470  7.73024618  4.15553765  9.17022395  4.68233758
##  [496]  0.67467478  4.90108978  6.10977645 -1.57670615  8.38238140
##  [501]  3.23733385  5.23690938  7.36507737  5.45617003 -0.79021903
##  [506]  1.13901107  3.10219374  0.14400161 -0.51070212  7.81713749
##  [511]  6.04152909  2.86919213  5.88893460  5.64809433  4.05845039
##  [516]  7.91085546  2.49472304  6.21123679  5.34163260  5.73706598
##  [521]  7.64741251  6.83377410 11.02668733  0.36605168  3.77738197
##  [526] -0.95752448  6.91581350  5.99049976  0.04382669  5.72677272
##  [531]  3.71493433 -1.23998027  4.85314671  6.72102279 -0.50672293
##  [536]  8.72442635  3.95831916  8.31200219  0.97128165  9.96914730
##  [541]  3.13595002 -0.54021939  7.89819535  4.36485850 10.50368347
##  [546]  5.92921536  5.11801686  8.01349933  7.00419593  4.74994430
##  [551]  5.83720892  5.82935457  6.49848775  4.25190569  5.20543761
##  [556]  4.62582602  4.45667847  3.78777971 -0.61622356  7.22561733
##  [561] -1.52505738  0.91214741  7.99300291  6.54950611  5.30979519
##  [566]  0.39546612  0.15053386  9.20633348  5.37244031  5.44953962
##  [571]  3.99028820  7.91243484  4.24014333  6.46179165  4.12423033
##  [576]  5.81648445  6.27941454  5.91821429  9.54438368  6.91927179
##  [581]  7.38232843  4.54172642  7.51287496  3.53958852  5.78523693
##  [586]  1.92648090  4.32679456 10.21999523  4.47560023  4.81237993
##  [591]  5.72699790  2.35361144  5.91334519  2.48676666  6.33735157
##  [596]  3.22520706  5.77621383 10.01736550  5.16022338  3.53919248
##  [601]  6.21199650 -0.73084611  8.28848636 -1.47431446  8.17256555
##  [606]  3.97158991  3.14251977  1.08255669 -0.56073825  3.84966075
##  [611]  7.19483942  2.93657570 14.03232495 10.96123589  4.21508698
##  [616]  0.88698160  4.99379923  4.02512204  2.85561757  6.63651452
##  [621]  2.71505835  5.31591647  4.99066330  5.87558376  4.87979465
##  [626]  3.53744277  6.46162674  2.39442737 -0.24234842  3.60742807
##  [631]  3.55096281  7.10994523 -3.64180773 -1.19785702  2.45583053
##  [636]  6.10542789 -0.45097701  1.76789490  3.42656347  7.44987602
##  [641]  7.51953128  5.61692892  5.21027711 -0.68217662 -3.19911545
##  [646]  8.38773184 -1.48057684  3.77500360  3.70212928  5.45068426
##  [651]  5.02971961  4.45004251  4.57501211  1.92876214  7.90966869
##  [656]  6.54256467  9.43293328 -4.53842738  7.90590826  2.98229178
##  [661]  7.30541279  1.88603655  1.58493353  0.36340055  4.82265540
##  [666]  7.09190693  5.04426470  1.21630706  4.76672085  1.86446115
##  [671]  5.99644762 11.92995739  2.70845416  5.35344700  7.34168531
##  [676]  6.31442256  4.87784540  4.04417824  5.31166445  9.54542122
##  [681]  6.66851345  8.45624154  5.57104808 -1.41032958  9.61343333
##  [686]  2.04119974  0.53762499  3.97720011  3.75962898  3.98849495
##  [691]  3.89724100  5.95995627  5.09875811  9.75885075  4.37479202
##  [696] -3.19622811 11.19527469  7.27038438  2.05814889  5.18440897
##  [701]  3.61880671  2.95967595  5.68454149  9.76754527  6.50354253
##  [706]  8.39583814  7.16593738  7.50511994 11.44945427  0.15275184
##  [711]  8.45657208  8.75046478  4.91203301  3.26991592  5.44540022
##  [716]  1.06015710 -1.71124654  4.03709294  1.14044389  1.16766528
##  [721]  5.43767321 -0.03409232  3.88119576  6.36729746  8.17198204
##  [726]  8.26044694  1.33028972  8.12393860  1.89330275  7.12623608
##  [731]  2.67063778  6.93965523  4.44935582  6.59624280 10.09854436
##  [736]  7.15271334  6.14614606  4.85847193 11.35609048  2.88441662
##  [741]  6.07349166  6.49478664  2.30381296  6.90267723  4.09438707
##  [746]  4.75515041  5.34829839 10.56317371  5.19749549  1.55866945
##  [751]  6.89293442  3.07719768  5.10899560  1.74602787  6.43711897
##  [756]  0.96527104  9.48587723  3.24870296  4.25140639  7.55670240
##  [761]  4.29224091  2.02463972  2.85634149  7.57622217 10.28381944
##  [766]  3.79920012  6.67881466  8.14164660  5.93394003 10.09264108
##  [771] 10.46280599  1.23934262  2.76367188  1.61573745  4.21806708
##  [776]  7.56025722  3.76309581  2.07644438  4.63607312  3.62684485
##  [781]  4.27056613 12.36768409  4.57809072  4.14959301  8.10743446
##  [786]  5.14032391  2.31677863  6.48742870  2.78490016  4.47805574
##  [791]  6.06956493  2.68380847  6.27513318  5.56256273  5.30296332
##  [796]  5.59371119 11.45921059  3.79061234 10.61698502  6.07048247
##  [801]  7.00803572  6.25897037  5.00754606  3.65439534  6.20791212
##  [806]  7.08568896  4.64436030  7.20492185  2.49686095  3.55651816
##  [811]  5.69808784  5.80782018  1.84939934  4.93123121  4.45448738
##  [816] 10.46507525  5.97999833  2.66019991  6.32161581  7.17404176
##  [821]  5.95922572  6.31761486  5.19473868  3.80383206  8.72915230
##  [826]  6.00081167  4.06179775  7.86685248  3.59423687  3.71546383
##  [831]  9.86673974  5.98647425  6.14730993  5.55448108 -3.60226961
##  [836] -0.48739877  5.32892799  2.37239016  4.07796536  3.58067577
##  [841]  7.39601233 10.97045495  8.26580361  5.11746622  6.50559737
##  [846]  2.69887272  1.58058220  2.39324098 -4.45743818  6.67000115
##  [851]  2.34160676  7.05390522 -0.47272114  4.70500406  3.78447220
##  [856]  0.80439804  3.10424750  2.86833160  4.82396241  4.85326706
##  [861]  7.07658260  6.55398707  0.99110429  2.10794589 10.22350788
##  [866]  7.46218450  0.21634917  5.59923611  1.54185522  2.97795512
##  [871]  7.25594085 -1.27841803  5.21185304  6.49313307  3.14733952
##  [876]  5.00584451  8.54117210  2.53291526  2.99584285  4.41160240
##  [881]  2.40626701 -0.51935879  6.40923385  4.09605082  7.48851802
##  [886]  5.45412860  5.36417820  6.41636212  7.90972113  5.08706207
##  [891]  5.90046303  2.44036428  1.55916901  5.76363565  0.86394593
##  [896]  8.62926883  4.77639616 -1.69187633 11.53111370  8.70342726
##  [901]  5.37594104  2.13662697  2.77765908  5.08243864  5.13160748
##  [906]  6.77760479  3.18100686  8.09012342  2.23159303  4.01621327
##  [911]  5.20434277  1.79103296  4.33513193  8.08677975  9.56158327
##  [916]  5.81906950  1.64621933  9.01516388  3.31650280  2.47407381
##  [921]  5.00984275  6.59572766  9.43618155  8.69999985  9.08275543
##  [926]  1.34049028 -0.26296561  2.19575488  1.71361294  6.13768619
##  [931]  4.54558119  7.35701560  7.82382815  7.38200882  4.31423917
##  [936]  0.50003093  0.48422180  7.72221203  5.54189992  6.00515067
##  [941]  3.21111817  3.88306653  8.95640365  7.83972414  6.57608277
##  [946]  9.04004194  0.14139062  2.92841555  2.03603961  8.66359158
##  [951]  4.04341997  3.65789989 -1.49574291 10.30289229  4.71392410
##  [956]  2.00834228  1.01433774  5.80222150 -0.26480319  6.89066109
##  [961]  3.81137147  8.19640277  8.40133828  7.15854056  5.72540429
##  [966]  4.49234942  5.51565805  2.85690681  4.87504284 -0.56686027
##  [971]  7.53496569  8.12967126  9.86028423  6.94583272  0.66284306
##  [976]  1.12287975  5.59851968  4.48430502  0.48321910  7.86890293
##  [981]  6.19481217  2.77138981  8.76363676  5.88775526  6.27892521
##  [986]  2.52644991  5.65772918  1.70462989  2.85980337  6.04514750
##  [991] -2.99806964  6.84173783  2.75167675  3.68794784 10.50314264
##  [996]  5.97243947  3.30038949  0.85471234 -0.01637781 -0.64956067
x2 = rnorm(1000, mean = 8, sd = 2); x2
##    [1]  5.4770047  9.1207323  7.2283992  6.9363624 10.5698374  7.9067702
##    [7]  8.2692109  5.2994712  9.2096683 10.1496721  8.8214422 10.6159757
##   [13]  5.0449219  4.2908512  7.8634165  5.3732451  6.3948022  5.9604953
##   [19] 13.4650644  4.8996109  8.5877709  7.9564353  6.4160683  6.6112186
##   [25]  8.4158542  8.4030888  7.0649248  7.5761402  6.6698517  8.1752722
##   [31]  6.7141334  7.7868519 11.2416412  8.7695269  7.7055147 12.4366195
##   [37]  7.4567236  9.9668385  8.3494351  8.4168049  6.3397426  7.0632189
##   [43]  7.9902005 10.1413567  8.8578311  8.1871740  2.0396828  8.1320697
##   [49]  8.3656499  6.0627750  6.4833392 12.4224385  6.0411942  8.1356229
##   [55]  6.1224063  4.4960693  8.3834297 10.0649661  5.7275973  4.8461948
##   [61]  9.9611106 10.7955611  9.7960414 11.8380383  9.2423462 10.6037238
##   [67]  4.4248184 11.5978289  6.8715235  8.3905695  8.5466294  9.8722353
##   [73]  7.6584688  7.6666552  7.0629604  8.3668731  4.7841438  6.2698585
##   [79]  9.1342810  9.3850443  6.8885544  7.1194572  8.1530827 10.9623440
##   [85]  8.5125854  9.4577903  6.4018521  8.3267387  7.1270861  5.3217916
##   [91]  8.1351898  5.9320790  9.4405323 12.6583453  9.0935707  7.6519588
##   [97]  7.4744215  8.0675708  4.6366272  9.5253730  6.7912498  5.8977680
##  [103]  9.0632139  6.8802870  6.1028696  7.5418176  6.6432183  7.6032378
##  [109]  3.9342724  4.7664540  6.5728239  9.6942747  5.2714534  7.0778220
##  [115] 12.3203727  6.6507955  6.1550420  9.4901071  9.8887787 11.5819359
##  [121]  7.2884828  5.3430137  6.4759827  6.4164950  5.5085513 10.4247617
##  [127]  8.8509624 10.4389661  9.4289818  8.7965858 11.7927745  6.1798288
##  [133]  6.3594406  6.0418378 10.7467559  5.2262773 10.6023876  8.5298578
##  [139]  9.9118592  9.3269556 11.8245205  4.1759119  8.9901091  8.6808284
##  [145]  9.0155949  7.3790672  6.1286064  9.9874745  8.5790203  9.5790543
##  [151]  3.7331870  6.6926600  4.5103937  6.5647486  6.3821068  5.5012500
##  [157]  7.1878384  9.7353568 10.9798793  7.0049153  8.2747247  5.8887301
##  [163] 10.2471456  9.1564765  4.2668627  5.0942572  0.8931329  6.8408100
##  [169]  8.6607645  8.4409311  9.5805190  7.6117497  5.1288428  8.3500151
##  [175]  5.9222830  8.3220366  9.5339624  8.6110833 10.7088477  9.9392462
##  [181]  8.2548668  9.9886905  9.4605518  7.3023922 10.6328462  4.5884656
##  [187]  4.0240088 10.9314813  7.7617805  6.5909129  8.5499173  7.0026819
##  [193]  7.9223652  8.0994708  6.8409845  9.1543329  6.7011303  4.7433266
##  [199]  9.0151881 10.3240465 10.8714092  6.2203874  9.7918908  7.4593451
##  [205]  5.4903953  7.0291769  8.3936066  9.4830696  9.4420847  8.0386022
##  [211]  6.0626135 10.8152233  7.6833953 10.0868532  8.8788746  7.2906352
##  [217]  7.7433351 10.1369696  6.1631201 10.1643190  6.8158878 10.4369886
##  [223] 10.8014303 11.2181281  7.9014265  9.0036470  7.2630232 10.7967605
##  [229]  8.3591134  4.3344861  7.8663871  4.7595274  6.4379296  9.6114712
##  [235]  8.5987821  9.8101834  7.4697384  5.7525877 10.6552252  8.6796966
##  [241]  8.4205379  8.7415468  8.1075489  6.9791445  9.2843575  9.0639017
##  [247]  7.2222393  8.5381334  7.5869946  9.7239728  9.7582388  4.4555583
##  [253]  9.4583965  7.5192362 10.4488337  9.0260108  9.8936035  7.4251037
##  [259]  7.4131228  7.9725321  9.6364358  8.3822396  8.4992933  4.5706764
##  [265]  7.7858228  9.5819122  7.4047015  9.1443873  8.1564085  8.3374236
##  [271]  4.7324962  4.9741395  6.7762632 10.0188725  9.4081370  8.3992186
##  [277]  8.7071495  7.5028223  7.6221953  8.5292182  7.5331361  7.7732823
##  [283]  9.8612132  7.6263791 10.4279529 12.2701387  6.6248479  8.8373118
##  [289]  8.7024901  6.6387710  9.8039751  9.1369571  7.5097317  8.2384549
##  [295]  4.4938351  8.6767218  8.7463501 10.8687327  7.3456495  7.3762126
##  [301]  9.1608644  5.8219312 11.6412848  7.1531088 10.2228399  4.9029570
##  [307] 10.5319766  8.1981828  9.2692011  8.7972912  8.0307772  7.2274982
##  [313]  8.7431673  8.2620169  5.5290979  6.7126717 10.9805578  8.7430752
##  [319]  8.8707305  9.6890296 13.4615615 10.4478658 13.9476906  9.1669828
##  [325]  7.2818028 11.5061394  9.3810015  8.5020084  8.6052198 10.5773993
##  [331]  8.5228459  7.9112757 11.2889513 10.6149023  7.7019682 11.2540932
##  [337]  8.1437880  8.6083307  5.1726721  4.0387880  9.7096932  7.1914565
##  [343]  5.8383656  4.5832713  7.3163467  9.2710165  7.7159971  5.9980242
##  [349]  8.2196367  8.2152414  2.9917371  4.3729537  5.7183948  7.9040938
##  [355] 11.2238050  8.1757302  3.4853652  8.5304526  8.6015880  5.1910504
##  [361] 11.0265402  8.1278845  6.7349158  6.7995389  7.5178594 10.6745215
##  [367]  6.9709937  9.3911783  9.3439813  9.0350572 11.0923191  9.8442971
##  [373]  7.3346859  6.5415299 10.5703742  6.6208856  5.6958474  9.7259735
##  [379]  7.3484651 11.5914608  9.4838866  7.6246002  7.1484257  5.2090669
##  [385]  9.6029292  9.5474656  9.8266972  7.6531790 11.4172492  9.8129896
##  [391] 13.2382869  7.7304870  3.7169412  9.0686929  7.9976371 11.1837892
##  [397]  7.7402963  4.0786728  9.4456447 12.6503123 10.4432515  7.5292891
##  [403]  2.8680680  9.4231304  6.2322040  6.6383230  6.4496630  5.3473179
##  [409]  7.1426103  4.9636745  8.3932706  9.4931899  7.8647538  6.1947533
##  [415]  8.8156425  5.3012786  3.5692162  6.3231692  5.0184009 12.2808055
##  [421]  7.5025942 10.0903711 10.1809234  9.4416457  8.0138358  6.8912518
##  [427]  4.9993793  6.2478560  8.3529573 10.7683858  6.3595037  4.7543304
##  [433]  9.5580502  6.0222476  7.8060340  7.2681807  8.7284247  5.7946255
##  [439]  8.9612359  8.2130691 10.5533881  7.7691597  5.7120414  8.2159730
##  [445]  7.8608381  4.4046486 13.7849864  7.8346564  6.3979825  8.3617623
##  [451]  7.2914274 10.7946914  7.6911286 10.2966123  6.2103788  6.5117921
##  [457]  7.5893730 10.9723060  6.2510448  9.9757526  6.5769034  8.7859909
##  [463]  8.1438324  9.9589727  6.1384985  9.1672693  9.5546706  7.2447977
##  [469]  5.6383689  9.4470167  6.3508080 10.1537410 10.0817665  5.8711405
##  [475]  8.3955812  5.7728109 11.2429746  7.2583591  8.6422933  6.9394078
##  [481]  8.7406652  7.6725061  8.3443968  9.5497005  7.2850087  6.7085301
##  [487]  7.0086914  8.7719428 10.3833093  6.1619482  7.5841418  6.5670177
##  [493]  6.0502489  7.0503856 12.8266135  9.9314752  7.3530273  8.5955429
##  [499]  8.3870924  7.2558332  7.5901283  7.7945454  8.6830357 10.3013633
##  [505]  8.7060178  6.4544403 11.6440417  9.8050364  6.8856664  9.5859997
##  [511] 10.0161929  8.8318690  5.9414848  8.3475645  7.6655003  9.3691911
##  [517]  3.8273634  5.1238076  5.3737641  7.9576977  5.7992827  9.9409523
##  [523]  8.4536575  8.6596351  7.7194550  6.9519236 10.1486088  9.0427391
##  [529] 10.1062502  9.0748334  4.8495396  9.3091353  9.3826465 10.4576523
##  [535]  8.5888329  8.6878929  8.1374236  7.6911211 12.5722747  8.9914979
##  [541]  6.4391014  6.1127857  6.8940499  8.1850888  8.1079698  7.3751959
##  [547]  5.6701518  6.5484198  6.2718948  6.9780178  7.7549007  3.5457384
##  [553]  8.1024302  5.7902640  6.7062957  9.5586673  7.3652310  5.7975281
##  [559] 10.6568462  7.0127568 10.1070705  8.8607871  8.5849749  6.4976101
##  [565] 11.9332215  3.8077854 10.4169996  8.0382588  8.3935571  6.4052601
##  [571]  9.7724728 10.9293440  8.5592793  7.7695365  6.8116592  9.9497535
##  [577]  8.0363935  8.3818210  8.1756332 10.2209546  7.9918782  6.5629952
##  [583]  6.7525384  7.3171136  4.8597320  9.4740122  8.2567068  5.0414512
##  [589]  7.0605364 11.3499371  9.2545702  5.0604033 10.2291899  8.7776237
##  [595]  8.2267788  6.6907625  8.3854087  9.4685793  5.2288282  7.4639817
##  [601]  9.4556960  6.5387198  9.2972751  4.7793328  7.4008301  7.9748554
##  [607] 11.0314298  8.5853861  6.5126555  6.2372223  8.4119932  8.6152602
##  [613] 11.1920821  6.6381043  4.8065293  4.2758430  9.4453703  6.7262932
##  [619]  9.1466580  7.6431110  8.0210766  7.0065042  7.8030482  7.3157022
##  [625]  8.3004690  7.3984055 11.9070351  8.1236704  9.5044781  8.4205672
##  [631]  5.7035055  6.9656554  9.4788881 10.5485591  7.9031533  5.5863352
##  [637]  9.4978423 11.0497534  5.7765577  6.6082773  6.6454566  7.0080101
##  [643]  8.2748006  8.1833782  6.7916723  7.0794191  4.2454091 10.9852402
##  [649]  9.0754996  8.3350482  8.5450450 10.9328444  9.2291447  6.2467406
##  [655]  6.6369807  8.3317761  8.3716454  9.7330575  9.9402831  3.3643387
##  [661]  8.1101515  6.8456410  8.7971892  7.3173712  8.2259525 11.8571920
##  [667] 12.9082362  8.3285601  8.0210722  9.8895254  7.2228094  8.5022831
##  [673]  8.1622294  7.9427324  8.6892847  6.1790729  4.1973035  8.6344482
##  [679] 10.9030164  4.4753694  5.3553429  8.5534855  3.0890539  6.5092856
##  [685]  9.6574728  7.4753887  9.5742047  7.6859264  8.0854340  5.3640654
##  [691]  7.4151174 10.2782860 10.7146018  9.7372674 10.9978834 10.1849677
##  [697]  8.0413308  7.4785099 12.0017265  6.5661985  6.2789390  7.8994002
##  [703]  6.9558284  5.2221607 10.5743228  7.2694582  8.2402157  7.7023248
##  [709]  5.5907227  7.4142334  6.5028065  3.5747309  8.3387974  6.8152728
##  [715] 10.3843779  9.9258161  4.7982756  9.3553855  8.2565535  4.5573947
##  [721]  6.7163011  7.6906680  6.9311709  8.8344940 12.0678732 10.5180535
##  [727]  6.9415731  6.7565754  6.3491833  7.2687031 10.4058780  6.8032455
##  [733]  8.6047983  5.4921743  6.7152741  6.7997146 10.2958073 11.4765375
##  [739]  6.9188057 11.5055828  7.9166217 10.1272643  8.9168510  6.2784430
##  [745]  7.0676840  9.4671271  7.0981625  9.9357825  4.1670098 10.2767104
##  [751]  4.2642302  7.0334181 10.6612730  9.4134749  7.8612877  6.8596574
##  [757]  7.6980201  9.3759700 11.5397524  3.1317594  5.6479786  8.4483683
##  [763]  4.3546724 10.3959205  9.5075590  8.1082815  9.0132220 11.3726413
##  [769]  4.3193397  5.6393715  7.2057645  6.5845936  8.5540321  8.8255092
##  [775]  7.6787724 10.5943010  9.9158906 10.5493557  9.4262277  9.4355232
##  [781]  7.3780033 11.0889827  3.9951680  6.4234954  5.8912170  7.3522352
##  [787]  7.7427202  5.9403420  8.4031182  8.5243529  7.7414931  6.7802583
##  [793] 12.0951226  8.6464304  5.7475060  6.4639381  9.7791504  6.3608037
##  [799]  7.2293978  9.1753979  9.3524850 11.7515269  5.4193126  6.9817921
##  [805] 12.8339405  7.2553640 10.5644125 10.4904531 10.6946770  6.9374000
##  [811]  9.5625611 11.3242492  7.7776642 10.2119589 10.1572988  5.3368246
##  [817]  9.3848684  7.5380502  8.2687496  6.2341456  7.5983572 11.0647175
##  [823]  3.9645703  9.2622243  7.8630042  9.1767007  8.0697125  8.9920020
##  [829]  9.5194013  7.6460948  6.5848823  7.3693931 12.2717349  8.5443971
##  [835]  5.4606201  7.5625277  7.1181686 11.8164188  6.2680263  6.5183359
##  [841]  5.2309195  8.2021660  8.7610878  9.8462102  9.3422290  5.7747784
##  [847]  8.0165104  6.4929538  5.7515877  8.0609640  7.2755891 10.1701933
##  [853] 10.9786914  9.7190955 10.4411663  6.0527815  7.7442870  8.9048998
##  [859]  7.4117119  3.7806402  8.9657124  7.5211101  5.2038940  7.0420769
##  [865]  7.1658000  7.1469985 12.0128121  7.6351830  4.8441060  7.4705877
##  [871]  6.4759779  9.2065065 10.4422566  7.7416856  5.4011768  8.0734598
##  [877] 12.7201701  7.9424450  7.7826445  6.5833342  8.5801272  7.1907295
##  [883]  8.8149128  7.5916298  4.7317523  9.0164143 10.2495795 10.1454617
##  [889]  9.5795564 11.7421108  7.0722964 11.5436137  9.3061628  5.3417402
##  [895]  6.0368302  6.7617319 11.0616517  8.4690085 10.4026968  9.3808587
##  [901]  7.4741366  8.4307012  7.6660317  9.5553745 13.5296493  7.8070179
##  [907]  7.2328040  6.5089315  7.2428620  4.5598246  7.1022646  5.8384731
##  [913]  7.6418663  5.4000629  6.2821406  5.3851262  7.5884019  8.4702068
##  [919]  9.5370171  5.5597444  7.2937877  6.7751029  8.8929424  8.8673343
##  [925]  7.4156119 14.0536854  9.6292564  5.9755030  5.5550414  5.9394392
##  [931]  6.7645484  6.6018730  5.9528150  6.7246646 10.3585662  8.9446650
##  [937]  8.5390475  6.3163316  4.1849452  5.8499897  9.4755964 10.7402523
##  [943]  6.2843145  6.3400021  9.4316958  4.7990713  8.5019726  8.1430793
##  [949] 11.0482463  4.2272183  7.0983023  5.3400154 10.1413229  5.0094973
##  [955]  6.8365758  5.7201202  5.5925590  8.8971141  5.0192837  9.0265477
##  [961]  7.2372077  9.5713709  5.8405186 10.6699765  7.6814160  3.8089668
##  [967]  8.6765763 10.1021810  8.7847698 10.4017257  6.9358889  6.3500118
##  [973]  7.6641673  8.6049587  6.2349662  9.7408318  5.9075203  9.2263513
##  [979]  6.9252777 10.1959907 10.3519316  5.7399600  9.2596327  8.5818596
##  [985]  7.5664993  9.5209648 11.7764228  7.8415647  5.2687385  9.1075476
##  [991]  9.4553516  9.5696574  6.5555598  7.4349161  9.4151126  8.2113493
##  [997]  5.8398905 10.6383597  8.8457733  9.7317959
s1 = sample(x1, 15); s1
##  [1]  0.1505339  6.1948122 -3.0238321  7.5128750  4.5633614  6.1302905
##  [7]  6.4617917  6.4931331  9.2063335  3.8038321  7.0080357  2.1079459
## [13]  5.4763677 10.4918079  9.0062165
s2 = sample(x2, 15); s2
##  [1]  6.9558284  0.8931329  6.2103788  6.9415731  9.3911783  6.4234954
##  [7]  8.4205672  6.8158878  7.2222393  8.3932706  8.5304526  9.4420847
## [13]  7.4251037  6.7995389 10.3843779
dfs = data.frame(s1, s2); dfs
##            s1         s2
## 1   0.1505339  6.9558284
## 2   6.1948122  0.8931329
## 3  -3.0238321  6.2103788
## 4   7.5128750  6.9415731
## 5   4.5633614  9.3911783
## 6   6.1302905  6.4234954
## 7   6.4617917  8.4205672
## 8   6.4931331  6.8158878
## 9   9.2063335  7.2222393
## 10  3.8038321  8.3932706
## 11  7.0080357  8.5304526
## 12  2.1079459  9.4420847
## 13  5.4763677  7.4251037
## 14 10.4918079  6.7995389
## 15  9.0062165 10.3843779
library(reshape); library(ggplot2)
dfsmelt = melt(dfs, id.vars = 1); dfsmelt
##            s1 variable      value
## 1   0.1505339       s2  6.9558284
## 2   6.1948122       s2  0.8931329
## 3  -3.0238321       s2  6.2103788
## 4   7.5128750       s2  6.9415731
## 5   4.5633614       s2  9.3911783
## 6   6.1302905       s2  6.4234954
## 7   6.4617917       s2  8.4205672
## 8   6.4931331       s2  6.8158878
## 9   9.2063335       s2  7.2222393
## 10  3.8038321       s2  8.3932706
## 11  7.0080357       s2  8.5304526
## 12  2.1079459       s2  9.4420847
## 13  5.4763677       s2  7.4251037
## 14 10.4918079       s2  6.7995389
## 15  9.0062165       s2 10.3843779
ggplot(dfsmelt, aes(x = variable, y = value)) +
  geom_boxplot() 

ggplot(dfsmelt, aes(x = variable, y = value)) +
  geom_boxplot() +
  geom_hline(aes(yintercept = mean(s1)))

2 (25) On a field experiment you measure soil moisture tension in units of pascals and rainfall amount in cm. Back in the lab you regress soil moisture ONTO rainfall using the lm() function in R. You find the slope of the linear relationship is -2.5. What are the units on this slope parameter? On average, as predicted by your regression model, by how much does the soil moisture tension change with a 10 cm rainfall event? NOTE: Answers DO NOT require R code.

#The units of the slope perameter are cm/pascals. 
#A 10 cm rainfall event would result in a -25 pascal change in soil moisture tension.

3 (25) The file https://docs.google.com/spreadsheets/d/e/2PACX-1vR6PLvP-w0XhrDALnDLNAy1wRub7OBbV9ylTMKsV-bhRKVzNDP1CLgSCYGz5tLe4vJctl7uVmjjnFkQ/pub?output=csv contains data on plant species diversity from R.T. McMaster (2005). “Factors Influencing Vascular Plant Diversity on 22 Islands off the Coast of Eastern North America,” Journal of Biogeography, Vol. 32, pp. 475-492.

  1. Read the data into R and select the variables ntv.rich (Native plant species richness index), area (area of the island in hectares), latitude, elev (elevation in meters above sea level), and human.dens (human population density per hectare). Create a new variable lntv.rich as the logarithm of the species richness index.
PlantDiversity = read.csv("C:/Users/Regina/Downloads/PlantDiversity.csv"); PlantDiversity
##                 Island tot.rich ntv.rich nonntv.rich pct.nonntv  area
## 1     Appledore Island      182       79         103         57    40
## 2          Bear Island       64       43          21         33     3
## 3         Block Island      661      396         265         40  2707
## 4     Cuttyhunk Island      311      173         138         44    61
## 5       Fishers Island      920      516         404         44  1190
## 6     Gardiners Island      390      249         141         36  1350
## 7   Grand Manan Island      633      374         259         41 13600
## 8            Gull Rock       34       15          19         56     4
## 9         Horse Island      107       75          32         30     4
## 10        Isle au Haut      641      370         271         42  1900
## 11         Kent Island      232      120         112         48   128
## 12 Machias Seal Island       72       24          48         67    10
## 13 Marthaâ<U+0080><U+0099>s Vineyard      979      605         374         38 13600
## 14      Matinicus Rock       62       21          41         66     8
## 15 Mount Desert Island     1060      620         440         42 26668
## 16     Muskeget Island      156       88          68         44   140
## 17    Nantucket Island     1166      625         541         46 10900
## 18      Naushon Island      564      362         202         36  2300
## 19     Penikese Island      347      181         166         48    34
## 20   Tuckernuck Island      353      224         129         37   350
## 21    Whaleboat Island      163       99          64         39    47
## 22  Wooden Ball Island      155       69          86         55    46
##    latitude elev dist.mnland dist.island soil.types years.isol
## 1     42.99   18        10.0        10.0          6       7000
## 2     41.25   13         0.3         0.3          1       3800
## 3     41.18   64        20.6        20.6         59     10,000
## 4     41.42   46        10.8         0.4         11       4700
## 5     41.27   40         2.7         2.7         35       7200
## 6     41.08   37         6.7         6.7         37       5000
## 7     44.75  122        17.5        17.5          .     14,000
## 8     44.96   10        13.2         1.0          .     11,800
## 9     41.24   10         1.9         0.3          1       8800
## 10    44.05  165        22.9         8.1         21       7500
## 11    44.58   20        30.1         7.0          .     12,000
## 12    44.50    6        17.7        17.7          .     11,720
## 13    41.39   95        13.4        13.4         47       4700
## 14    43.79   15        30.6         4.7          1     10,500
## 15    44.33  466         0.3         0.3         74       5000
## 16    41.33   10        35.7         7.5          4       4700
## 17    41.27   33        42.5        21.0         27       4700
## 18    41.47   53         8.6         8.6         18       4700
## 19    41.45   21         8.5         1.6          6       4700
## 20    41.30   15        34.0         3.0         16       4700
## 21    43.76   23         1.3         1.3          4       7500
## 22    43.86   19        27.4         4.3          2     10,500
##    years.deglac human.pop human.dens
## 1         12640         0       0.00
## 2         15000         0       0.00
## 3         15000      1010       0.37
## 4         14900        86       1.41
## 5         15000       289       0.24
## 6         14950         0       0.00
## 7         14000      2757       0.20
## 8         11800         0       0.00
## 9         15000         0       0.00
## 10        13250        79       0.04
## 11        12000         0       0.00
## 12        11720         0       0.00
## 13        15000     10760       0.79
## 14        12700         0       0.00
## 15        13350     10424       0.39
## 16        15000         0       0.00
## 17        15000      9520       0.87
## 18        14900         0       0.00
## 19        14900         0       0.00
## 20        15000         0       0.00
## 21        12540         0       0.00
## 22        12620         0       0.00
Plants = subset(PlantDiversity, select=c("ntv.rich", "area", "latitude", "elev", "human.dens")); Plants
##    ntv.rich  area latitude elev human.dens
## 1        79    40    42.99   18       0.00
## 2        43     3    41.25   13       0.00
## 3       396  2707    41.18   64       0.37
## 4       173    61    41.42   46       1.41
## 5       516  1190    41.27   40       0.24
## 6       249  1350    41.08   37       0.00
## 7       374 13600    44.75  122       0.20
## 8        15     4    44.96   10       0.00
## 9        75     4    41.24   10       0.00
## 10      370  1900    44.05  165       0.04
## 11      120   128    44.58   20       0.00
## 12       24    10    44.50    6       0.00
## 13      605 13600    41.39   95       0.79
## 14       21     8    43.79   15       0.00
## 15      620 26668    44.33  466       0.39
## 16       88   140    41.33   10       0.00
## 17      625 10900    41.27   33       0.87
## 18      362  2300    41.47   53       0.00
## 19      181    34    41.45   21       0.00
## 20      224   350    41.30   15       0.00
## 21       99    47    43.76   23       0.00
## 22       69    46    43.86   19       0.00
lntv.rich = log(Plants$ntv.rich); lntv.rich
##  [1] 4.369448 3.761200 5.981414 5.153292 6.246107 5.517453 5.924256
##  [8] 2.708050 4.317488 5.913503 4.787492 3.178054 6.405228 3.044522
## [15] 6.429719 4.477337 6.437752 5.891644 5.198497 5.411646 4.595120
## [22] 4.234107
  1. Fit a multiple linear regression to the logarithm of native species richness using area, latitude, elevation and human density as the explanatory variables. Then use the step function to find a final model.
plantfit = lm(lntv.rich ~ Plants$area + Plants$latitude + Plants$elev + Plants$human.dens); plantfit
## 
## Call:
## lm(formula = lntv.rich ~ Plants$area + Plants$latitude + Plants$elev + 
##     Plants$human.dens)
## 
## Coefficients:
##       (Intercept)        Plants$area    Plants$latitude  
##         2.058e+01          6.286e-05         -3.768e-01  
##       Plants$elev  Plants$human.dens  
##         3.421e-03          3.116e-01
plantstep = step(plantfit); plantstep
## Start:  AIC=-5.03
## lntv.rich ~ Plants$area + Plants$latitude + Plants$elev + Plants$human.dens
## 
##                     Df Sum of Sq    RSS     AIC
## - Plants$human.dens  1    0.1999 11.310 -6.6385
## - Plants$elev        1    0.6094 11.719 -5.8559
## - Plants$area        1    0.8882 11.998 -5.3388
## <none>                           11.110 -5.0308
## - Plants$latitude    1    5.3343 16.444  1.5964
## 
## Step:  AIC=-6.64
## lntv.rich ~ Plants$area + Plants$latitude + Plants$elev
## 
##                   Df Sum of Sq    RSS     AIC
## - Plants$elev      1    0.5202 11.830 -7.6492
## <none>                         11.310 -6.6385
## - Plants$area      1    1.4338 12.743 -6.0126
## - Plants$latitude  1    6.9480 18.258  1.8980
## 
## Step:  AIC=-7.65
## lntv.rich ~ Plants$area + Plants$latitude
## 
##                   Df Sum of Sq    RSS     AIC
## <none>                         11.830 -7.6492
## - Plants$latitude  1    6.4281 18.258 -0.1018
## - Plants$area      1   11.7053 23.535  5.4839
## 
## Call:
## lm(formula = lntv.rich ~ Plants$area + Plants$latitude)
## 
## Coefficients:
##     (Intercept)      Plants$area  Plants$latitude  
##      20.5049917        0.0001119       -0.3729416
  1. Fit the final model and check the residuals for normality.
residuals(plantstep)
##           1           2           3           4           5           6 
## -0.10725950 -1.36028570  0.53127084  0.08871621  0.99926588  0.18185064 
##           7           8           9          10          11          12 
##  0.58669185 -1.02993412 -0.80783901  1.62399762  0.89391520 -0.73215498 
##          13          14          15          16          17          18 
## -0.18541931 -1.13025113 -0.52666370 -0.62964266  0.10445497  0.59519330 
##          19          20          21          22 
##  0.14813094  0.26998135  0.40479431  0.08118701

4 (25) The file scotlip.zip contains Male lip cancer incidence in Scotland districts between 1975 and 1980 from Waller and Gotway (2004). The response variable (CANCER) is the number of incident male cases of lip cancer in each of the 56 districts over the six-year period. The expected rates (CEXP) were estimated by Clayton and Kaldor (1987) using an age-distribution model. The percentage of the male work force employed in agriculture, fishing, or forestry divided by 10 is the variable AFF.

References: Clayton D. and Kaldor J. (1987). Empirical Bayes estimates of age-standardized relative risks for use in disease mapping. Biometrics 43, 671–681.

Waller, L.A. and Gotway, C.A. (2004). Applied Spatial Statistics for Public Health Data. New York: John Wiley and Sons.

  1. Download the data and get it into R using the readOGR() function from the rgdal package OR the readShapeSpatial() function from the maptools package. The dsn and layer names are scotlip.

  2. Fit a regression model to the cancer counts using the expected rate and percentage of work force in agriculture, fishing, or forestry as the explanatory variables. Use the summary() function to print the table of coefficients and the R-squared value.

  3. Plot a map of the regression model residuals. Use a range from -30 to 30 by 10 and six colors from the PuOr color ramp from the RColorBrewer package.

  4. Compute the Moran’s I statistic on the model residuals using the appropriate function from the spdep package.