#########################################################################################
## The script below documents the statistical analysis for the 823 project
## Completed at Fleming College-Lindsay Ontario, A collaborative project with
## The Ministry of Environment and Climate Change as Client, and Andrew Millar as Project head.
# Written by Alexand Jick Neba - GIS Cartographic Specialist.
##
## R is an Open source powerful statical environment. Downlaod here http://mirror.fcaglp.unlp.edu.ar/CRAN/
## http://cran.r-project.org/manuals.html
###########################################################################################
getwd() # Get working directory
## [1] "E:/BayofQuinte2"
setwd("E:\\BayofQuinte2") # Set working directory
list.files() # Which are the files in the working directory
## [1] "AAFC_Crop_Mapping_2011_v1_Metadata_EN.xml"
## [2] "AAFC_Crop_Mapping_2011_v1_Metadata_FR.xml"
## [3] "AESB-EOS_2011_CI_ON_30m_v1.tif"
## [4] "AESB-EOS_2011_CI_ON_30m_v1.tif.aux.xml"
## [5] "AESB-EOS_2011_CI_ON_30m_v1.tif.ovr"
## [6] "Collab_R.md"
## [7] "Collab_R.R"
## [8] "Collab_R.Rmd"
## [9] "ExposedLandUrban.pdf"
## [10] "figure"
## [11] "FinalStat1.csv"
## [12] "FinalStat2.csv"
## [13] "FinalStat3.csv"
## [14] "FinalStats.csv"
## [15] "FinalStats.xlsx"
## [16] "FinalStats4.xlsx"
## [17] "FinalStats5.csv"
## [18] "NormalityUrbanExposedLand.pdf"
## [19] "Project_New.mxd"
## [20] "R_with vegetation Indices.Rhistory"
## [21] "ResidualUrbanExposedLand.pdf"
## [22] "Rplot.pdf"
## [23] "Rplot01.pdf"
## [24] "SalamanderIn R.txt"
## [25] "Vegetation Inventory.docx"
mydata <- read.csv("FinalStat3.csv", header=TRUE, # Read data into R Programming Environment.
sep=",")
mydata # Take a look of the data
## OBJECTID_1.. Shape.. OBJECTID Year gridcode WatershedI Area
## 1 1 Polygon 1 2013 1 1 22.2131
## 2 2 Polygon 2 2013 0 2 3593.6400
## 3 3 Polygon 3 2013 3 3 63.6132
## 4 4 Polygon 4 2013 0 4 2784.3400
## 5 5 Polygon 5 2013 0 5 138.7460
## 6 6 Polygon 6 2013 0 6 1026.0600
## 7 7 Polygon 7 2013 7 7 32.7726
## 8 8 Polygon 8 2013 8 8 1052.0500
## 9 9 Polygon 9 2013 0 9 112.6950
## 10 10 Polygon 10 2012 0 1 22.2131
## 11 11 Polygon 11 2012 0 2 3593.6400
## 12 12 Polygon 12 2012 0 3 63.6132
## 13 13 Polygon 13 2012 0 4 2784.3400
## 14 14 Polygon 14 2012 0 5 138.7460
## 15 15 Polygon 15 2012 0 6 1026.0600
## 16 16 Polygon 16 2012 0 7 32.7726
## 17 17 Polygon 17 2012 0 8 1052.0500
## 18 18 Polygon 18 2012 0 9 112.6950
## 19 19 Polygon 19 Polygon 19 1 22.2131
## 20 20 Polygon 20 Polygon 20 2 3593.6400
## 21 21 Polygon 21 Polygon 21 3 63.6132
## 22 22 Polygon 22 Polygon 22 4 2784.3400
## 23 23 Polygon 23 Polygon 23 5 138.7460
## 24 24 Polygon 24 Polygon 24 6 1026.0600
## 25 25 Polygon 25 Polygon 25 7 32.7726
## 26 26 Polygon 26 Polygon 26 8 1052.0500
## 27 27 Polygon 27 Polygon 27 9 112.6950
## CHOROPHYLL CONDFIELD DO FWPH FWTEMP MCTOT PCRFU
## 1 6.225000 254.7586 9.12213 8.285350 19.78100 1.2166700 1.0564800
## 2 5.980000 255.7133 9.38837 8.119020 20.30420 0.1583330 0.7925930
## 3 5.235000 257.3951 8.71554 8.192520 20.06130 0.0300000 0.7959880
## 4 2.317778 237.7856 10.37260 8.227790 18.13300 0.9128570 0.6420000
## 5 66.570000 256.0574 8.73040 8.305170 19.85320 4.8120000 1.1596300
## 6 5.535000 246.2133 9.23891 8.070300 18.38180 1.7800000 0.5753330
## 7 11.005556 303.2860 9.96349 8.022360 16.33680 2.1545500 1.3370500
## 8 5.544286 256.8065 9.84252 8.365080 18.26880 0.8077780 1.6369400
## 9 9.917500 286.1991 8.20674 8.206740 17.08170 0.5840000 1.4309000
## 10 6.921429 258.7545 11.11249 7.946004 16.37412 4.1709414 0.7874660
## 11 7.028571 276.6121 11.69927 7.918423 16.83617 8.5060000 0.9086706
## 12 5.284615 276.8996 11.68883 7.927533 16.59223 8.5060000 0.8833761
## 13 12.876923 265.9464 12.26378 7.995238 16.54946 11.4543817 1.1190476
## 14 6.430769 250.0345 11.91570 8.017071 15.92044 0.0000000 1.0204762
## 15 7.071429 262.7923 11.51454 7.976560 16.31663 5.8325420 1.2090476
## 16 7.935714 282.0768 10.84007 7.719973 15.45208 9.8922145 1.3146599
## 17 43.600000 264.9231 11.60086 8.131879 17.28083 11.5205035 2.7264835
## 18 10.650000 280.6090 10.78354 7.985160 16.03781 12.2530000 2.0805536
## 19 5.008333 255.0377 12.67648 8.445817 17.26703 0.4649484 0.9385714
## 20 8.929167 264.1389 12.85899 8.335632 17.80013 0.1162936 1.7624339
## 21 10.091667 262.3361 11.32984 8.430801 17.93573 0.2680594 1.5152778
## 22 9.612500 276.1458 12.92521 8.401389 17.87139 0.4866084 1.2194444
## 23 8.462500 249.0417 13.14794 8.421403 17.02688 0.7218186 0.9891667
## 24 15.304545 264.2803 12.07167 8.426515 17.67545 0.7312644 1.4522727
## 25 12.866667 303.2709 10.18907 8.239279 16.67454 0.7037500 1.1322619
## 26 17.268182 262.0000 11.72590 8.530277 18.09656 1.0254015 1.3023377
## 27 13.431818 274.7917 10.68493 8.344741 16.39815 0.9445911 1.0477904
## PHYCO PON PPFT PPPT PPUT SDISC
## 1 2101.680 0.13425000 0.007300000 0.01818300 0.02190000 1.7857100
## 2 1710.530 0.12175000 0.005600000 0.01433300 0.01903300 1.6222200
## 3 1740.700 0.11575000 0.006400000 0.01763300 0.02330000 1.7000000
## 4 1280.570 0.08800000 0.006850000 0.01178000 0.01828200 1.5428600
## 5 2436.540 0.20950000 0.006900000 0.01874000 0.02370000 1.6400000
## 6 1232.410 0.11900000 0.006600000 0.00000000 0.01746700 1.7500000
## 7 2847.440 0.19600000 0.008150000 0.03329000 0.03340900 1.7090900
## 8 3314.880 0.26112500 0.008500000 0.03151000 0.03567300 1.3916700
## 9 3124.510 0.27475000 0.008500000 0.02958000 0.04150900 1.6500000
## 10 1710.526 0.18208333 0.008207143 0.01780000 0.02371429 1.8230769
## 11 1931.997 0.13266667 0.006538462 0.01360909 0.01963077 1.9285714
## 12 1879.574 0.13927273 0.006541667 0.01343000 0.01931667 1.9538462
## 13 2386.976 0.22740000 0.008275000 0.02131000 0.02719167 0.9714286
## 14 2110.712 0.15318182 0.007784615 0.01146000 0.02380000 1.5571429
## 15 2656.679 0.18541667 0.008276923 0.02113636 0.02672308 1.2892857
## 16 2830.466 0.16525000 0.013900000 0.02433636 0.03745385 2.0500000
## 17 5811.222 0.28975000 0.009914286 0.03034167 0.03985000 1.6142857
## 18 4404.485 0.25200000 0.010064286 0.02591667 0.03234286 1.8071429
## 19 1816.530 0.08981818 0.007491667 0.01169167 0.01871667 2.3463636
## 20 3804.942 0.16845455 0.006808333 0.01570833 0.02332500 1.4683333
## 21 3187.034 0.17145455 0.008225000 0.01990000 0.03035833 1.5716667
## 22 2634.910 0.14672727 0.009275000 0.01969167 0.02505833 1.4416667
## 23 2118.613 0.13872727 0.008191667 0.01525000 0.02387500 1.7550000
## 24 3100.235 0.22060000 0.008518182 0.02035455 0.03101818 1.3818182
## 25 2223.507 0.16318182 0.015208333 0.01958333 0.03748333 2.1400000
## 26 2864.650 0.15200000 0.010900000 0.01980909 0.03106364 1.6227273
## 27 2197.176 0.17680000 0.011790909 0.01804545 0.03241818 2.0108333
## Water Exposed.Land Urban Shrubland Wetland Pasture Grain
## 1 0.072930 2.029880 17.592290 17.511260 10.392500 9.586217 0.024310
## 2 4.515051 0.296273 1.920768 11.775750 7.497971 12.718620 1.210513
## 3 0.165532 0.557431 31.043540 15.272770 4.023691 10.359170 4.582537
## 4 2.670904 0.382744 2.090145 16.786900 10.693250 6.767476 0.334550
## 5 1.406956 2.733478 2.037459 19.939990 16.995040 14.888180 4.918833
## 6 3.716262 0.992044 2.154078 27.216480 11.326060 9.785450 0.242968
## 7 0.505300 8.153461 18.053500 16.658430 4.838800 12.841220 6.159721
## 8 4.645465 1.871257 2.506701 33.063790 8.285323 13.486930 0.397110
## 9 1.998132 2.695321 1.169170 32.970770 9.656038 15.287060 2.815113
## 10 0.060775 1.572042 15.744730 19.622170 10.724730 10.153450 0.109395
## 11 4.408438 0.273934 1.629153 11.719380 7.606212 13.437390 0.220088
## 12 0.142895 0.560261 25.760680 13.006252 4.182149 10.008300 0.149969
## 13 2.171827 0.306461 1.800622 17.622600 11.549570 6.715176 0.105634
## 14 1.160463 2.289142 2.016053 18.184695 17.296020 14.784390 0.558501
## 15 3.203399 0.642680 2.051453 27.497347 11.855500 10.366120 0.059645
## 16 0.483331 6.033396 17.619600 25.254035 4.783876 15.024450 0.675565
## 17 4.120462 1.003296 2.469660 34.016695 8.885350 13.138585 0.116515
## 18 1.837610 2.640217 1.157990 29.312319 9.673608 17.780340 0.242779
## 19 0.056723 1.754367 16.105330 6.981003 10.331720 18.349947 4.817419
## 20 4.829556 0.213828 1.609168 7.670526 6.561266 15.627530 1.706790
## 21 0.090547 0.350870 26.090330 7.965324 3.521437 14.648844 5.345115
## 22 2.637643 0.241878 1.791474 13.973264 10.587100 9.206715 0.743897
## 23 1.205221 0.841320 2.025783 13.401438 15.855990 19.476837 5.147163
## 24 3.418386 0.293315 1.986369 23.016125 11.197380 14.197637 1.042479
## 25 0.584940 5.843908 18.479160 9.433188 4.127535 18.597247 9.982428
## 26 4.637081 0.473161 2.282482 27.806148 8.116111 19.272143 1.376454
## 27 1.613998 1.455873 1.147608 24.550187 8.720063 23.711645 3.361365
## Corn.Products Beans other.agriculture Fruits Coniferous Broadleaf
## 1 10.534300 14.569750 0.000000 0.000000 0.093188 10.068360
## 2 5.208727 2.362924 0.004809 0.206214 7.212492 19.535140
## 3 7.552203 6.096373 0.000000 0.069325 0.739940 9.847008
## 4 1.753591 1.082778 0.004654 0.011346 7.789808 18.956080
## 5 5.222408 5.651176 0.247142 0.048650 5.806208 8.099890
## 6 0.720482 0.638645 0.017192 0.000000 9.816062 13.176380
## 7 6.983580 6.423356 0.000000 0.000000 3.861154 4.338992
## 8 1.405282 1.776215 0.000000 0.004106 6.412611 14.073360
## 9 2.014104 3.009975 0.000000 0.000000 6.311444 10.508160
## 10 17.653060 6.470494 0.000000 0.000000 0.182325 9.991383
## 11 5.189492 1.713026 0.000476 0.000852 7.336761 20.190570
## 12 17.628410 7.588988 0.000000 0.000000 0.690422 10.320970
## 13 2.414609 0.665576 0.000452 0.000000 7.547606 18.836160
## 14 13.600579 5.586310 0.000000 0.000000 5.176353 7.609499
## 15 1.188172 0.326734 0.004034 0.006491 9.529325 13.231120
## 16 7.615206 5.410009 0.032954 0.000000 3.732082 4.080850
## 17 1.377992 1.772279 0.006587 0.000000 6.358203 14.579020
## 18 8.245687 1.787297 0.000000 0.000000 6.219604 9.900414
## 19 10.911110 15.007330 0.036465 0.000000 0.024310 9.335014
## 20 4.083989 2.517848 0.048886 6.409648 6.386482 20.294830
## 21 13.225550 8.500118 0.093377 0.000000 0.302767 9.365976
## 22 1.805826 0.913758 0.013220 0.001972 6.031207 18.092070
## 23 8.274381 8.344437 0.019460 0.000000 5.629122 8.199136
## 24 1.098616 0.492250 0.020438 0.000000 8.735953 12.657730
## 25 8.576375 5.679136 0.389960 0.000000 4.168728 3.891362
## 26 3.066436 0.977718 0.008641 0.000000 5.617280 14.541640
## 27 3.103414 7.019814 0.055903 0.000000 4.929044 9.957116
## Mixed.Wood
## 1 5.299566
## 2 25.435210
## 3 7.451752
## 4 30.622300
## 5 7.069160
## 6 19.887200
## 7 6.571651
## 8 11.667510
## 9 6.781828
## 10 5.660163
## 11 26.219640
## 12 7.873362
## 13 30.208760
## 14 6.748070
## 15 19.781680
## 16 5.209537
## 17 11.754170
## 18 6.260333
## 19 4.217773
## 20 28.362980
## 21 8.447771
## 22 33.914990
## 23 6.489901
## 24 21.583580
## 25 5.967487
## 26 11.432430
## 27 5.759602
names(mydata) # What are the Field names
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood"
attach(mydata) # Attach data for proper management(Best practice)
detach(mydata) # Detach data
View(mydata) # View data
Mod1=glm(mydata$PPUT~ mydata$Urban +I(mydata$Urban^2), data=mydata, family=poisson())# Fit a generalized Linear Model
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.021900
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.019033
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.023300
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.018282
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.023700
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.017467
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.033409
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.035673
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.041509
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.023714
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.019631
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.019317
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.027192
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.023800
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.026723
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.037454
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.039850
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.032343
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.018717
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.023325
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.030358
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.025058
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.023875
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.031018
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.037483
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.031064
## Warning in dpois(y, mu, log = TRUE): non-integer x = 0.032418
summary(Mod1) # Model diagnostic
##
## Call:
## glm(formula = mydata$PPUT ~ mydata$Urban + I(mydata$Urban^2),
## family = poisson(), data = mydata)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.06433 -0.03440 -0.00395 0.03047 0.08095
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -3.6206086 1.8946026 -1.911 0.056 .
## mydata$Urban 0.0119755 0.5017353 0.024 0.981
## I(mydata$Urban^2) -0.0005042 0.0188229 -0.027 0.979
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 0.047658 on 26 degrees of freedom
## Residual deviance: 0.046855 on 24 degrees of freedom
## AIC: Inf
##
## Number of Fisher Scoring iterations: 6
plot(Urban, PPUT, ylab="PHYCO",xlab="Agriculture", ylim=c(0,20),main="Relation btw Area of PHYCO & Agriculture") # Plot model parameters
## Error in plot(Urban, PPUT, ylab = "PHYCO", xlab = "Agriculture", ylim = c(0, : object 'Urban' not found
abline(Mod1$coef) # Fit line
## Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet
curve(coef(Mod1)[1]+coef(Mod1)[2]*x+coef(Mod1)[3]*x^2,from=0,to=20,add=TRUE) #Fit curve line
## Error in plot.xy(xy.coords(x, y), type = type, ...): plot.new has not been called yet
coef # Observe model coefficients
## function (object, ...)
## UseMethod("coef")
## <bytecode: 0x0000000006bb7520>
## <environment: namespace:stats>
install.packages("lme4") # R package for glm
## Installing package into 'H:/My Documents/R/win-library/3.2'
## (as 'lib' is unspecified)
## Error in contrib.url(repos, "source"): trying to use CRAN without setting a mirror
library(lme4) # library containing model algorithm
## Loading required package: Matrix
## Loading required package: Rcpp
##############################################################################################################################
install.packages("knitr")
## Installing package into 'H:/My Documents/R/win-library/3.2'
## (as 'lib' is unspecified)
## Error in contrib.url(repos, "source"): trying to use CRAN without setting a mirror
library(knitr)
###########################################################################################
mod2=glm() #Generalized Linear Model detailed explanation here http://www.sagepub.com/upm-data/21121_Chapter_15.pdf
## Error in environment(formula): argument "formula" is missing, with no default
names(mydata) # Viewing data names
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood"
View(mydata) # View data in spreadsheet
summary(mydata) #Summary Statistics
## OBJECTID_1.. Shape.. OBJECTID Year gridcode
## Min. : 1.0 Polygon:27 Min. : 1.0 2012 :9 Min. : 0.00
## 1st Qu.: 7.5 1st Qu.: 7.5 2013 :9 1st Qu.: 0.00
## Median :14.0 Median :14.0 Polygon:9 Median : 0.00
## Mean :14.0 Mean :14.0 Mean : 8.37
## 3rd Qu.:20.5 3rd Qu.:20.5 3rd Qu.:20.50
## Max. :27.0 Max. :27.0 Max. :27.00
## WatershedI Area CHOROPHYLL CONDFIELD
## Min. :1 Min. : 22.21 Min. : 2.318 Min. :237.8
## 1st Qu.:3 1st Qu.: 63.61 1st Qu.: 6.103 1st Qu.:255.9
## Median :5 Median : 138.75 Median : 8.463 Median :262.8
## Mean :5 Mean : 980.68 Mean :12.115 Mean :266.1
## 3rd Qu.:7 3rd Qu.:1052.05 3rd Qu.:11.936 3rd Qu.:276.4
## Max. :9 Max. :3593.64 Max. :66.570 Max. :303.3
## DO FWPH FWTEMP MCTOT
## Min. : 8.207 Min. :7.720 Min. :15.45 Min. : 0.0000
## 1st Qu.: 9.903 1st Qu.:8.006 1st Qu.:16.47 1st Qu.: 0.5353
## Median :11.112 Median :8.207 Median :17.27 Median : 0.9446
## Mean :10.911 Mean :8.185 Mean :17.49 Mean : 3.3354
## 3rd Qu.:11.821 3rd Qu.:8.355 3rd Qu.:18.11 3rd Qu.: 5.3223
## Max. :13.148 Max. :8.530 Max. :20.30 Max. :12.2530
## PCRFU PHYCO PON PPFT
## Min. :0.5753 Min. :1232 Min. :0.0880 Min. :0.005600
## 1st Qu.:0.9236 1st Qu.:1906 1st Qu.:0.1365 1st Qu.:0.006875
## Median :1.1323 Median :2387 Median :0.1653 Median :0.008207
## Mean :1.2162 Mean :2573 Mean :0.1731 Mean :0.008545
## 3rd Qu.:1.3840 3rd Qu.:2982 3rd Qu.:0.2028 3rd Qu.:0.008897
## Max. :2.7265 Max. :5811 Max. :0.2898 Max. :0.015208
## PPPT PPUT SDISC Water
## Min. :0.00000 Min. :0.01747 Min. :0.9714 Min. :0.05672
## 1st Qu.:0.01479 1st Qu.:0.02260 1st Qu.:1.5500 1st Qu.:0.49432
## Median :0.01874 Median :0.02506 Median :1.6500 Median :1.83761
## Mean :0.01905 Mean :0.02732 Mean :1.6861 Mean :2.08740
## 3rd Qu.:0.02122 3rd Qu.:0.03238 3rd Qu.:1.8151 3rd Qu.:3.56732
## Max. :0.03329 Max. :0.04151 Max. :2.3464 Max. :4.82956
## Exposed.Land Urban Shrubland Wetland
## Min. :0.2138 Min. : 1.148 Min. : 6.981 Min. : 3.521
## 1st Qu.:0.3668 1st Qu.: 1.861 1st Qu.:13.204 1st Qu.: 7.030
## Median :0.9920 Median : 2.090 Median :17.623 Median : 9.656
## Mean :1.7223 Mean : 8.161 Mean :19.342 Mean : 9.233
## 3rd Qu.:2.1595 3rd Qu.:16.849 3rd Qu.:26.235 3rd Qu.:10.961
## Max. :8.1535 Max. :31.044 Max. :34.017 Max. :17.296
## Pasture Grain Corn.Products Beans
## Min. : 6.715 Min. :0.02431 Min. : 0.7205 Min. : 0.3267
## 1st Qu.:10.256 1st Qu.:0.23143 1st Qu.: 1.9100 1st Qu.: 1.3979
## Median :13.487 Median :0.74390 Median : 5.2087 Median : 3.0100
## Mean :13.712 Mean :2.09062 Mean : 6.3131 Mean : 4.5328
## 3rd Qu.:15.457 3rd Qu.:3.97195 3rd Qu.: 8.4254 3rd Qu.: 6.4469
## Max. :23.712 Max. :9.98243 Max. :17.6531 Max. :15.0073
## other.agriculture Fruits Coniferous Broadleaf
## Min. :0.000000 Min. :0.000000 Min. :0.02431 Min. : 3.891
## 1st Qu.:0.000000 1st Qu.:0.000000 1st Qu.:3.79662 1st Qu.: 9.350
## Median :0.004809 Median :0.000000 Median :5.80621 Median :10.321
## Mean :0.037209 Mean :0.250319 Mean :5.06076 Mean :11.988
## 3rd Qu.:0.026696 3rd Qu.:0.003039 3rd Qu.:6.81255 3rd Qu.:14.560
## Max. :0.389960 Max. :6.409648 Max. :9.81606 Max. :20.295
## Mixed.Wood
## Min. : 4.218
## 1st Qu.: 6.375
## Median : 7.873
## Mean :13.581
## 3rd Qu.:20.735
## Max. :33.915
ncol(mydata) # View number of fields.
## [1] 34
nrow(mydata) # View number of records.
## [1] 27
######################################################################
##########################################
crPlots(mod2) # Construct a model plot (Optional)
## Error in eval(expr, envir, enclos): could not find function "crPlots"
###Statistical Anlaysis for Generalized Parameters##########################
#############################################################################
#### Part two, Detailed Parameters##########################################
##############################################################################
## Model for further analysis#################################################
mod3=lm(mydata$PPPT~mydata$Urban+mydata$Exposed.Land+mydata$Pasture+mydata$Corn.Products+mydata$Beans+mydata$Grain, data=mydata)
summary(mod3)
##
## Call:
## lm(formula = mydata$PPPT ~ mydata$Urban + mydata$Exposed.Land +
## mydata$Pasture + mydata$Corn.Products + mydata$Beans + mydata$Grain,
## data = mydata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0199225 -0.0031409 0.0006973 0.0036387 0.0095628
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0143006 0.0055785 2.563 0.0185 *
## mydata$Urban 0.0002515 0.0002407 1.045 0.3086
## mydata$Exposed.Land 0.0018639 0.0007540 2.472 0.0225 *
## mydata$Pasture 0.0004054 0.0004351 0.932 0.3626
## mydata$Corn.Products -0.0004870 0.0004154 -1.172 0.2549
## mydata$Beans -0.0003298 0.0005071 -0.650 0.5229
## mydata$Grain -0.0007174 0.0007667 -0.936 0.3606
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006671 on 20 degrees of freedom
## Multiple R-squared: 0.3292, Adjusted R-squared: 0.1279
## F-statistic: 1.636 on 6 and 20 DF, p-value: 0.1892
names(mydata)
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood"
attach(mydata)
re1= lm(PPPT~Urban)
summary(re1)
##
## Call:
## lm(formula = PPPT ~ Urban)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0189809 -0.0041872 -0.0002395 0.0022450 0.0141190
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.896e-02 1.859e-03 10.20 2.16e-10 ***
## Urban 1.195e-05 1.496e-04 0.08 0.937
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.007284 on 25 degrees of freedom
## Multiple R-squared: 0.0002554, Adjusted R-squared: -0.03973
## F-statistic: 0.006387 on 1 and 25 DF, p-value: 0.9369
coplot(PPPT~Urban|Exposed.Land, panel=panel.smooth) # Observe interaction between model parameters of interest
plot(re1) # Ploting regression diagnostics
termplot(re1) # termplot for model diagnostics
Exposed.Land1=mean(Exposed.Land,na.rm=T) # remove zero value if any in dataset
Exposed.Land1# Get a look at variable
## [1] 1.72229
max(Exposed.Land) #Maximum value
## [1] 8.153461
plot(x=log(mydata$Urban),# Log transform variables
y=log(mydata$PPPT),
main="PPPT-Urban relationship on Bay of Quinte", # title
xlab="log(Urban)", ylab= "log(PPPT(mg/L))",
pch=19, col="blue") #graph parameters
########################################################################################
mod4=lm(mydata$PPUT~mydata$Urban+mydata$Exposed.Land+mydata$Pasture+mydata$Corn.Products+mydata$Beans+mydata$Grain, data=mydata) # Fit Model
summary(mod4)####Summary to elliminate parameters without any effect
##
## Call:
## lm(formula = mydata$PPUT ~ mydata$Urban + mydata$Exposed.Land +
## mydata$Pasture + mydata$Corn.Products + mydata$Beans + mydata$Grain,
## data = mydata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0094872 -0.0033415 -0.0003431 0.0022017 0.0105709
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0158523 0.0045477 3.486 0.00233 **
## mydata$Urban 0.0003480 0.0001963 1.773 0.09142 .
## mydata$Exposed.Land 0.0017772 0.0006146 2.891 0.00902 **
## mydata$Pasture 0.0009783 0.0003547 2.758 0.01213 *
## mydata$Corn.Products -0.0005139 0.0003387 -1.517 0.14485
## mydata$Beans -0.0007009 0.0004134 -1.695 0.10553
## mydata$Grain -0.0006826 0.0006250 -1.092 0.28776
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005438 on 20 degrees of freedom
## Multiple R-squared: 0.5524, Adjusted R-squared: 0.4181
## F-statistic: 4.113 on 6 and 20 DF, p-value: 0.007527
re2=lm(PPUT~Urban+Exposed.Land+Pasture, data=mydata)# Models with effect
summary(re2)# Summary
##
## Call:
## lm(formula = PPUT ~ Urban + Exposed.Land + Pasture, data = mydata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0098588 -0.0047640 0.0003084 0.0030029 0.0133818
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0191615 0.0045132 4.246 0.000305 ***
## Urban -0.0001098 0.0001356 -0.810 0.426395
## Exposed.Land 0.0016959 0.0006606 2.567 0.017217 *
## Pasture 0.0004473 0.0003098 1.444 0.162306
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006157 on 23 degrees of freedom
## Multiple R-squared: 0.34, Adjusted R-squared: 0.2539
## F-statistic: 3.95 on 3 and 23 DF, p-value: 0.02077
aov(re2)# Analysis of variance
## Call:
## aov(formula = re2)
##
## Terms:
## Urban Exposed.Land Pasture Residuals
## Sum of Squares 0.0000021729 0.0003680774 0.0000790233 0.0008720203
## Deg. of Freedom 1 1 1 23
##
## Residual standard error: 0.006157428
## Estimated effects may be unbalanced
re3=lm(PPUT~Exposed.Land)
summary(re3)
##
## Call:
## lm(formula = PPUT ~ Exposed.Land)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.008659 -0.005297 -0.001346 0.004430 0.013793
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.024296 0.001621 14.989 5.33e-14 ***
## Exposed.Land 0.001755 0.000621 2.827 0.00911 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006328 on 25 degrees of freedom
## Multiple R-squared: 0.2422, Adjusted R-squared: 0.2119
## F-statistic: 7.992 on 1 and 25 DF, p-value: 0.009114
plot(PPUT,Exposed.Land)
abline(re3)
coplot(PPUT~Exposed.Land|Urban,panel=panel.smooth,data=mydata) # Coplot to observe interaction
summary(re3)
##
## Call:
## lm(formula = PPUT ~ Exposed.Land)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.008659 -0.005297 -0.001346 0.004430 0.013793
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.024296 0.001621 14.989 5.33e-14 ***
## Exposed.Land 0.001755 0.000621 2.827 0.00911 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006328 on 25 degrees of freedom
## Multiple R-squared: 0.2422, Adjusted R-squared: 0.2119
## F-statistic: 7.992 on 1 and 25 DF, p-value: 0.009114
############################################################################################
#Relationship between Pasture and PPFT on the Bay of Quinte (multiple regressions)
mod5=lm(mydata$PPFT~mydata$Urban+mydata$Exposed.Land+mydata$Pasture+mydata$Corn.Products+mydata$Beans+mydata$Grain, data=mydata)
summary(mod5)
##
## Call:
## lm(formula = mydata$PPFT ~ mydata$Urban + mydata$Exposed.Land +
## mydata$Pasture + mydata$Corn.Products + mydata$Beans + mydata$Grain,
## data = mydata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0032265 -0.0010267 -0.0002498 0.0010652 0.0036273
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.767e-03 1.450e-03 2.597 0.01723 *
## mydata$Urban 9.790e-05 6.259e-05 1.564 0.13345
## mydata$Exposed.Land 5.214e-04 1.960e-04 2.660 0.01504 *
## mydata$Pasture 3.541e-04 1.131e-04 3.131 0.00527 **
## mydata$Corn.Products -7.454e-05 1.080e-04 -0.690 0.49802
## mydata$Beans -2.027e-04 1.318e-04 -1.537 0.13985
## mydata$Grain -1.840e-04 1.993e-04 -0.923 0.36699
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.001734 on 20 degrees of freedom
## Multiple R-squared: 0.5424, Adjusted R-squared: 0.4051
## F-statistic: 3.951 on 6 and 20 DF, p-value: 0.009099
aov(mod5)
## Call:
## aov(formula = mod5)
##
## Terms:
## mydata$Urban mydata$Exposed.Land mydata$Pasture
## Sum of Squares 3.521000e-07 3.665206e-05 1.883480e-05
## Deg. of Freedom 1 1 1
## mydata$Corn.Products mydata$Beans mydata$Grain
## Sum of Squares 4.533380e-06 8.365180e-06 2.562410e-06
## Deg. of Freedom 1 1 1
## Residuals
## Sum of Squares 6.015047e-05
## Deg. of Freedom 20
##
## Residual standard error: 0.001734221
## Estimated effects may be unbalanced
re4=lm(PPFT~Pasture)
summary(re4)
##
## Call:
## lm(formula = PPFT ~ Pasture)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0026712 -0.0011385 -0.0001550 0.0006483 0.0053173
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.767e-03 1.352e-03 3.525 0.00166 **
## Pasture 2.755e-04 9.462e-05 2.912 0.00745 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.001981 on 25 degrees of freedom
## Multiple R-squared: 0.2533, Adjusted R-squared: 0.2234
## F-statistic: 8.48 on 1 and 25 DF, p-value: 0.007452
plot(x=Pasture, y=PPFT,
main= "Relationship Pasture-PPFT on Bay of Quinte",
pch=19, col="blue", xlab="Pasture(%)", ylab= "Total Phosphorous (mg/L)") # Plot Model
abline(re4)
fitted <- predict(re4, interval = "confidence") # Determined confidence intervals
lines(Pasture, fitted[, "fit"],lwd=2)# Construct a regression line
lines(Pasture, fitted[, "lwr"], lty = "dotted",col="red")# determine lower confidence band
lines(Pasture, fitted[, "upr"], lty = "dotted",col="red") # determine upper confidence band
legend("topright", bty="n", legend=paste("R2 is",
format(summary(re4)$adj.r.squared, digits=4))) # Fit a legend and the R2
###########################################################################################
################################################################################################
###No Relationship
mod6=lm(PHYCO~Urban*Pasture)
summary(mod6)
##
## Call:
## lm(formula = PHYCO ~ Urban * Pasture)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1254.7 -695.2 -109.1 377.2 3157.4
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2026.60724 861.93821 2.351 0.0277 *
## Urban -20.37394 81.56595 -0.250 0.8050
## Pasture 51.39745 59.55648 0.863 0.3970
## Urban:Pasture 0.06998 6.20633 0.011 0.9911
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 996.2 on 23 degrees of freedom
## Multiple R-squared: 0.09332, Adjusted R-squared: -0.02495
## F-statistic: 0.7891 on 3 and 23 DF, p-value: 0.5124
plot(Urban,PHYCO)
fitted <- predict(mod6, interval = "confidence")
lines(Urban, fitted[, "fit"])
lines(Urban, fitted[, "lwr"], lty = "dotted")
lines(Urban, fitted[, "upr"], lty = "dotted")
#########################################################################################
mod7=lm(mydata$PCRFU~mydata$Urban+mydata$Exposed.Land+mydata$Pasture+mydata$Corn.Products+mydata$Beans+mydata$Grain, data=mydata)
summary(mod7)
##
## Call:
## lm(formula = mydata$PCRFU ~ mydata$Urban + mydata$Exposed.Land +
## mydata$Pasture + mydata$Corn.Products + mydata$Beans + mydata$Grain,
## data = mydata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.67221 -0.27493 -0.05818 0.10867 1.32675
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.68438 0.38158 1.794 0.0880 .
## mydata$Urban 0.01291 0.01647 0.784 0.4422
## mydata$Exposed.Land 0.04438 0.05157 0.861 0.3997
## mydata$Pasture 0.05536 0.02976 1.860 0.0776 .
## mydata$Corn.Products -0.02238 0.02842 -0.788 0.4401
## mydata$Beans -0.02805 0.03469 -0.809 0.4282
## mydata$Grain -0.06726 0.05244 -1.283 0.2143
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4563 on 20 degrees of freedom
## Multiple R-squared: 0.2363, Adjusted R-squared: 0.007236
## F-statistic: 1.032 on 6 and 20 DF, p-value: 0.4341
######################################################################################
mod8=lm(mydata$MCTOT~mydata$Urban+mydata$Exposed.Land+mydata$Pasture+mydata$Corn.Products+mydata$Beans+mydata$Grain, data=mydata)
summary(mod8)
##
## Call:
## lm(formula = mydata$MCTOT ~ mydata$Urban + mydata$Exposed.Land +
## mydata$Pasture + mydata$Corn.Products + mydata$Beans + mydata$Grain,
## data = mydata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.557 -2.561 -1.099 1.630 7.712
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.62384 3.28161 0.800 0.4334
## mydata$Urban 0.07044 0.14162 0.497 0.6243
## mydata$Exposed.Land 0.67655 0.44352 1.525 0.1428
## mydata$Pasture 0.11141 0.25593 0.435 0.6680
## mydata$Corn.Products 0.15215 0.24439 0.623 0.5406
## mydata$Beans -0.35067 0.29832 -1.175 0.2536
## mydata$Grain -0.92188 0.45099 -2.044 0.0543 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.924 on 20 degrees of freedom
## Multiple R-squared: 0.3095, Adjusted R-squared: 0.1024
## F-statistic: 1.494 on 6 and 20 DF, p-value: 0.2307
#######################################################################################
mod9=lm(FWTEMP~Pasture*Beans*Grain)# Multiple regression
summary(mod9)
##
## Call:
## lm(formula = FWTEMP ~ Pasture * Beans * Grain)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.1947 -0.7810 -0.1603 0.8899 2.0853
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.25322 1.73521 8.790 4.02e-08 ***
## Pasture 0.13849 0.14497 0.955 0.3514
## Beans 0.66149 0.39270 1.684 0.1084
## Grain 5.41497 2.40968 2.247 0.0367 *
## Pasture:Beans -0.05274 0.03668 -1.438 0.1667
## Pasture:Grain -0.31170 0.13942 -2.236 0.0376 *
## Beans:Grain -0.78184 0.37565 -2.081 0.0512 .
## Pasture:Beans:Grain 0.04691 0.02251 2.084 0.0509 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.251 on 19 degrees of freedom
## Multiple R-squared: 0.3418, Adjusted R-squared: 0.0993
## F-statistic: 1.409 on 7 and 19 DF, p-value: 0.2585
plot(mod9)
###########################################################################################
####################################################################################
reg0=lm(mydata$FWPH~mydata$Exposed.Land+mydata$Corn.Products+mydata$Beans+mydata$Grain, data=mydata)
summary(reg0)
##
## Call:
## lm(formula = mydata$FWPH ~ mydata$Exposed.Land + mydata$Corn.Products +
## mydata$Beans + mydata$Grain, data = mydata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.231345 -0.075549 -0.005422 0.070071 0.310394
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.232861 0.049054 167.832 < 2e-16 ***
## mydata$Exposed.Land -0.063652 0.015884 -4.007 0.000593 ***
## mydata$Corn.Products -0.022451 0.007606 -2.952 0.007372 **
## mydata$Beans 0.023836 0.010280 2.319 0.030093 *
## mydata$Grain 0.045537 0.013312 3.421 0.002447 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1413 on 22 degrees of freedom
## Multiple R-squared: 0.609, Adjusted R-squared: 0.5379
## F-statistic: 8.567 on 4 and 22 DF, p-value: 0.0002512
aov(reg0)
## Call:
## aov(formula = reg0)
##
## Terms:
## mydata$Exposed.Land mydata$Corn.Products mydata$Beans
## Sum of Squares 0.1142043 0.0397436 0.2969676
## Deg. of Freedom 1 1 1
## mydata$Grain Residuals
## Sum of Squares 0.2337832 0.4395510
## Deg. of Freedom 1 22
##
## Residual standard error: 0.1413492
## Estimated effects may be unbalanced
plot(reg0)
reg1=lm(DO~ Beans*I(Grain1^2)) # Multiple regression Model
## Error in unique(c("AsIs", oldClass(x))): object 'Grain1' not found
fitted <- predict(reg1, interval = "confidence")# Model Prediction
## Error in predict(reg1, interval = "confidence"): object 'reg1' not found
plot(Grain1, DO)
## Error in plot(Grain1, DO): object 'Grain1' not found
lines(Grain1, fitted[, "fit"])
## Error in lines(Grain1, fitted[, "fit"]): object 'Grain1' not found
# now the confidence bands
lines(Corn.Products, fitted[, "lwr"], lty = "dotted")
lines(Corn.Products, fitted[, "upr"], lty = "dotted")
summary(reg1)
## Error in summary(reg1): error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'reg1' not found
plot(Exposed.Land,FWPH)
mydata$Grain1<-log(mydata$Grain) # Creating a new variable in the database
names(mydata)
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood" "Grain1"
attach(mydata)
## The following objects are masked from mydata (pos = 3):
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
Grain1
## [1] -3.71686749 0.19104424 1.52225277 -1.09496893 1.59307131
## [6] -1.41482553 1.81803148 -0.92354196 1.03500240 -2.21279009
## [11] -1.51372781 -1.89732667 -2.24777499 -0.58249887 -2.81934496
## [16] -0.39220590 -2.14973526 -1.41560371 1.57223831 0.53461441
## [21] 1.67618306 -0.29585269 1.63844569 0.04160153 2.30082635
## [26] 0.31951063 1.21234714
##########################################################################################
#########################################################################################
reg2=lm(mydata$CONDFIELD~mydata$Urban+mydata$Exposed.Land+mydata$Pasture+mydata$Corn.Products+mydata$Beans+mydata$Grain, data=mydata)
summary(reg2)
##
## Call:
## lm(formula = mydata$CONDFIELD ~ mydata$Urban + mydata$Exposed.Land +
## mydata$Pasture + mydata$Corn.Products + mydata$Beans + mydata$Grain,
## data = mydata)
##
## Residuals:
## Min 1Q Median 3Q Max
## -16.7264 -9.0706 0.5376 6.6879 19.3074
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 245.68975 9.84383 24.959 < 2e-16 ***
## mydata$Urban 0.63477 0.42481 1.494 0.15073
## mydata$Exposed.Land 4.65312 1.33044 3.497 0.00227 **
## mydata$Pasture 1.14467 0.76773 1.491 0.15157
## mydata$Corn.Products 0.06282 0.73308 0.086 0.93256
## mydata$Beans -2.00630 0.89488 -2.242 0.03646 *
## mydata$Grain 0.09030 1.35284 0.067 0.94744
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.77 on 20 degrees of freedom
## Multiple R-squared: 0.5744, Adjusted R-squared: 0.4467
## F-statistic: 4.498 on 6 and 20 DF, p-value: 0.004858
###################################################################################################
#############################################################################################
############################################################################################
attach(mydata) # attach data
## The following objects are masked from mydata (pos = 3):
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## Grain1, gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
##
## The following objects are masked from mydata (pos = 4):
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
reg5=lm(CONDFIELD~Exposed.Land) #Fit linear model
summary(reg5) # summarize model
##
## Call:
## lm(formula = CONDFIELD ~ Exposed.Land)
##
## Residuals:
## Min 1Q Median 3Q Max
## -21.337 -10.618 2.408 8.498 18.053
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 257.138 3.123 82.342 < 2e-16 ***
## Exposed.Land 5.187 1.196 4.335 0.000209 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 12.19 on 25 degrees of freedom
## Multiple R-squared: 0.4291, Adjusted R-squared: 0.4063
## F-statistic: 18.79 on 1 and 25 DF, p-value: 0.0002087
aov(reg5) # Analysis of variance
## Call:
## aov(formula = reg5)
##
## Terms:
## Exposed.Land Residuals
## Sum of Squares 2793.836 3716.556
## Deg. of Freedom 1 25
##
## Residual standard error: 12.19271
## Estimated effects may be unbalanced
plot(x= Exposed.Land, y= CONDFIELD,
main= "Relationship Exposed Land- Water Conductivity on Bay of Quinte", # Graph Title
pch=19, col="blue",xlab="Exposed Land(%)", ylab= "Electrical Conductivity (mS/cm)") # Plot model parameter
fitted <- predict(reg5, interval = "confidence") # confidence interval
lines(Exposed.Land, fitted[, "fit"]) #
lines(Exposed.Land, fitted[, "lwr"], lty = "dotted",col="red") # Lower confidence band
lines(Exposed.Land, fitted[, "upr"], lty = "dotted",col="red") # Upper confidence band
legend("topright", bty="n", legend=paste("R2 is",
format(summary(reg5)$adj.r.squared, digits=4))) # Legend with R2
########################################################################################
#########################################################################################
#######################################################################################
reg6=lm(SDISC~Pasture)# Fit Model
summary(reg6)# Model summary
##
## Call:
## lm(formula = SDISC ~ Pasture)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.47629 -0.15593 -0.03004 0.21892 0.50223
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.21892 0.17134 7.114 1.86e-07 ***
## Pasture 0.03407 0.01199 2.842 0.0088 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2511 on 25 degrees of freedom
## Multiple R-squared: 0.2442, Adjusted R-squared: 0.2139
## F-statistic: 8.077 on 1 and 25 DF, p-value: 0.008798
aov(reg6)# Analysis of variance
## Call:
## aov(formula = reg6)
##
## Terms:
## Pasture Residuals
## Sum of Squares 0.5090634 1.5757420
## Deg. of Freedom 1 25
##
## Residual standard error: 0.2510571
## Estimated effects may be unbalanced
plot(x=Pasture, y=SDISC,
main= "Relationship Pasture - SDISC on Bay of Quinte",pch=19, col="blue",
xlab="Pasture(%)", ylab="SDISC (m)") # Plot model
fitted <- predict(reg6, interval = "confidence")# confidence interval
lines(Pasture, fitted[, "fit"],lwd=2)
lines(Pasture, fitted[, "lwr"], lty = "dotted",col="red",lwd=2)# lower confidence band
lines(Pasture, fitted[, "upr"], lty = "dotted",col="red",lwd=2) # Upper confidence band
legend("topright", bty="n", legend=paste("R2 is",
format(summary(reg6)$adj.r.squared, digits=4)))# Legend
coplot(SDISC~Pasture|SDISC,panel=panel.smooth) # coplot to observe parameter interaction
##################################################################################################
#####################################################################################
###############################################################################
fit=lm(PPUT~SDISC)
summary(fit)
##
## Call:
## lm(formula = PPUT ~ SDISC)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.009781 -0.004772 -0.002533 0.005310 0.014150
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.029200 0.008596 3.397 0.00228 **
## SDISC -0.001115 0.005030 -0.222 0.82630
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.007263 on 25 degrees of freedom
## Multiple R-squared: 0.001963, Adjusted R-squared: -0.03796
## F-statistic: 0.04918 on 1 and 25 DF, p-value: 0.8263
names(mydata)
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood" "Grain1"
plot(fit) # for model diagnostics
plot(PPUT,SDISC) # Plot parameter
abline(PPUT,SDISC,add=T) # add line on graph
## Warning in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): "add"
## is not a graphical parameter
#####################################################################################
# Using ggplot2 for developing aesthetic graphics
#The learning curve is pretty steep but become fun when understood
######################################################################
install.packages("ggplot2") # install ggplot2 documentation is found online
## Installing package into 'H:/My Documents/R/win-library/3.2'
## (as 'lib' is unspecified)
## Error in contrib.url(repos, "source"): trying to use CRAN without setting a mirror
library(ggplot2) # Open ggplot2 library and graph algorithms
qplot(Pasture, SDISC, data=mydata, geom=c("point", "smooth"), # Plotting ggplot2
method="lm", formula=y~x,
main="Regression of Pasture on SDISC",
xlab="Pasture", ylab="SDISC (m)")
p <- ggplot(mydata, aes(Pasture, SDISC))
p + geom_point(colour = "red", size = 3)
###########################################################################################
#Statistical Analysis Part II - Saturday 13-06-2015
########################################################
getwd()
## [1] "E:/BayofQuinte2"
setwd("E:\\BayofQuinte2")
list.files()
## [1] "AAFC_Crop_Mapping_2011_v1_Metadata_EN.xml"
## [2] "AAFC_Crop_Mapping_2011_v1_Metadata_FR.xml"
## [3] "AESB-EOS_2011_CI_ON_30m_v1.tif"
## [4] "AESB-EOS_2011_CI_ON_30m_v1.tif.aux.xml"
## [5] "AESB-EOS_2011_CI_ON_30m_v1.tif.ovr"
## [6] "Collab_R.md"
## [7] "Collab_R.R"
## [8] "Collab_R.Rmd"
## [9] "ExposedLandUrban.pdf"
## [10] "figure"
## [11] "FinalStat1.csv"
## [12] "FinalStat2.csv"
## [13] "FinalStat3.csv"
## [14] "FinalStats.csv"
## [15] "FinalStats.xlsx"
## [16] "FinalStats4.xlsx"
## [17] "FinalStats5.csv"
## [18] "NormalityUrbanExposedLand.pdf"
## [19] "Project_New.mxd"
## [20] "R_with vegetation Indices.Rhistory"
## [21] "ResidualUrbanExposedLand.pdf"
## [22] "Rplot.pdf"
## [23] "Rplot01.pdf"
## [24] "SalamanderIn R.txt"
## [25] "Vegetation Inventory.docx"
mydata1 <- read.csv("FinalStats5.csv", header=TRUE,
sep=",")
View(mydata1)
edit(mydata1)
## OBJECTID_1.. Shape.. OBJECTID Year gridcode WatershedI Area
## 1 1 Polygon 1 2013 1 1 22.2131
## 2 2 Polygon 2 2013 0 2 3593.6400
## 3 3 Polygon 3 2013 3 3 63.6132
## 4 4 Polygon 4 2013 0 4 2784.3400
## 5 5 Polygon 5 2013 0 5 138.7460
## 6 6 Polygon 6 2013 0 6 1026.0600
## 7 7 Polygon 7 2013 7 7 32.7726
## 8 8 Polygon 8 2013 8 8 1052.0500
## 9 9 Polygon 9 2013 0 9 112.6950
## 10 10 Polygon 10 2012 0 1 22.2131
## 11 11 Polygon 11 2012 0 2 3593.6400
## 12 12 Polygon 12 2012 0 3 63.6132
## 13 13 Polygon 13 2012 0 4 2784.3400
## 14 14 Polygon 14 2012 0 5 138.7460
## 15 15 Polygon 15 2012 0 6 1026.0600
## 16 16 Polygon 16 2012 0 7 32.7726
## 17 17 Polygon 17 2012 0 8 1052.0500
## 18 18 Polygon 18 2012 0 9 112.6950
## 19 19 Polygon 19 2011 19 1 22.2131
## 20 20 Polygon 20 2011 20 2 3593.6400
## 21 21 Polygon 21 2011 21 3 63.6132
## 22 22 Polygon 22 2011 22 4 2784.3400
## 23 23 Polygon 23 2011 23 5 138.7460
## 24 24 Polygon 24 2011 24 6 1026.0600
## 25 25 Polygon 25 2011 25 7 32.7726
## 26 26 Polygon 26 2011 26 8 1052.0500
## 27 27 Polygon 27 2011 27 9 112.6950
## CHOROPHYLL CONDFIELD DO FWPH FWTEMP MCTOT PCRFU
## 1 6.225000 254.7586 9.12213 8.285350 19.78100 1.2166700 1.0564800
## 2 5.980000 255.7133 9.38837 8.119020 20.30420 0.1583330 0.7925930
## 3 5.235000 257.3951 8.71554 8.192520 20.06130 0.0300000 0.7959880
## 4 2.317778 237.7856 10.37260 8.227790 18.13300 0.9128570 0.6420000
## 5 66.570000 256.0574 8.73040 8.305170 19.85320 4.8120000 1.1596300
## 6 5.535000 246.2133 9.23891 8.070300 18.38180 1.7800000 0.5753330
## 7 11.005556 303.2860 9.96349 8.022360 16.33680 2.1545500 1.3370500
## 8 5.544286 256.8065 9.84252 8.365080 18.26880 0.8077780 1.6369400
## 9 9.917500 286.1991 8.20674 8.206740 17.08170 0.5840000 1.4309000
## 10 6.921429 258.7545 11.11249 7.946004 16.37412 4.1709414 0.7874660
## 11 7.028571 276.6121 11.69927 7.918423 16.83617 8.5060000 0.9086706
## 12 5.284615 276.8996 11.68883 7.927533 16.59223 8.5060000 0.8833761
## 13 12.876923 265.9464 12.26378 7.995238 16.54946 11.4543817 1.1190476
## 14 6.430769 250.0345 11.91570 8.017071 15.92044 0.0000000 1.0204762
## 15 7.071429 262.7923 11.51454 7.976560 16.31663 5.8325420 1.2090476
## 16 7.935714 282.0768 10.84007 7.719973 15.45208 9.8922145 1.3146599
## 17 43.600000 264.9231 11.60086 8.131879 17.28083 11.5205035 2.7264835
## 18 10.650000 280.6090 10.78354 7.985160 16.03781 12.2530000 2.0805536
## 19 5.008333 255.0377 12.67648 8.445817 17.26703 0.4649484 0.9385714
## 20 8.929167 264.1389 12.85899 8.335632 17.80013 0.1162936 1.7624339
## 21 10.091667 262.3361 11.32984 8.430801 17.93573 0.2680594 1.5152778
## 22 9.612500 276.1458 12.92521 8.401389 17.87139 0.4866084 1.2194444
## 23 8.462500 249.0417 13.14794 8.421403 17.02688 0.7218186 0.9891667
## 24 15.304545 264.2803 12.07167 8.426515 17.67545 0.7312644 1.4522727
## 25 12.866667 303.2709 10.18907 8.239279 16.67454 0.7037500 1.1322619
## 26 17.268182 262.0000 11.72590 8.530277 18.09656 1.0254015 1.3023377
## 27 13.431818 274.7917 10.68493 8.344741 16.39815 0.9445911 1.0477904
## PHYCO PON PPFT PPPT PPUT SDISC
## 1 2101.680 0.13425000 0.007300000 0.01818300 0.02190000 1.7857100
## 2 1710.530 0.12175000 0.005600000 0.01433300 0.01903300 1.6222200
## 3 1740.700 0.11575000 0.006400000 0.01763300 0.02330000 1.7000000
## 4 1280.570 0.08800000 0.006850000 0.01178000 0.01828200 1.5428600
## 5 2436.540 0.20950000 0.006900000 0.01874000 0.02370000 1.6400000
## 6 1232.410 0.11900000 0.006600000 0.00000000 0.01746700 1.7500000
## 7 2847.440 0.19600000 0.008150000 0.03329000 0.03340900 1.7090900
## 8 3314.880 0.26112500 0.008500000 0.03151000 0.03567300 1.3916700
## 9 3124.510 0.27475000 0.008500000 0.02958000 0.04150900 1.6500000
## 10 1710.526 0.18208333 0.008207143 0.01780000 0.02371429 1.8230769
## 11 1931.997 0.13266667 0.006538462 0.01360909 0.01963077 1.9285714
## 12 1879.574 0.13927273 0.006541667 0.01343000 0.01931667 1.9538462
## 13 2386.976 0.22740000 0.008275000 0.02131000 0.02719167 0.9714286
## 14 2110.712 0.15318182 0.007784615 0.01146000 0.02380000 1.5571429
## 15 2656.679 0.18541667 0.008276923 0.02113636 0.02672308 1.2892857
## 16 2830.466 0.16525000 0.013900000 0.02433636 0.03745385 2.0500000
## 17 5811.222 0.28975000 0.009914286 0.03034167 0.03985000 1.6142857
## 18 4404.485 0.25200000 0.010064286 0.02591667 0.03234286 1.8071429
## 19 1816.530 0.08981818 0.007491667 0.01169167 0.01871667 2.3463636
## 20 3804.942 0.16845455 0.006808333 0.01570833 0.02332500 1.4683333
## 21 3187.034 0.17145455 0.008225000 0.01990000 0.03035833 1.5716667
## 22 2634.910 0.14672727 0.009275000 0.01969167 0.02505833 1.4416667
## 23 2118.613 0.13872727 0.008191667 0.01525000 0.02387500 1.7550000
## 24 3100.235 0.22060000 0.008518182 0.02035455 0.03101818 1.3818182
## 25 2223.507 0.16318182 0.015208333 0.01958333 0.03748333 2.1400000
## 26 2864.650 0.15200000 0.010900000 0.01980909 0.03106364 1.6227273
## 27 2197.176 0.17680000 0.011790909 0.01804545 0.03241818 2.0108333
## Water Exposed.Land Urban Shrubland Wetland Pasture Grain
## 1 0.072930 2.029880 17.592290 17.511260 10.392500 9.586217 0.024310
## 2 4.515051 0.296273 1.920768 11.775750 7.497971 12.718620 1.210513
## 3 0.165532 0.557431 31.043540 15.272770 4.023691 10.359170 4.582537
## 4 2.670904 0.382744 2.090145 16.786900 10.693250 6.767476 0.334550
## 5 1.406956 2.733478 2.037459 19.939990 16.995040 14.888180 4.918833
## 6 3.716262 0.992044 2.154078 27.216480 11.326060 9.785450 0.242968
## 7 0.505300 8.153461 18.053500 16.658430 4.838800 12.841220 6.159721
## 8 4.645465 1.871257 2.506701 33.063790 8.285323 13.486930 0.397110
## 9 1.998132 2.695321 1.169170 32.970770 9.656038 15.287060 2.815113
## 10 0.060775 1.572042 15.744730 19.622170 10.724730 10.153450 0.109395
## 11 4.408438 0.273934 1.629153 11.719380 7.606212 13.437390 0.220088
## 12 0.142895 0.560261 25.760680 13.006252 4.182149 10.008300 0.149969
## 13 2.171827 0.306461 1.800622 17.622600 11.549570 6.715176 0.105634
## 14 1.160463 2.289142 2.016053 18.184695 17.296020 14.784390 0.558501
## 15 3.203399 0.642680 2.051453 27.497347 11.855500 10.366120 0.059645
## 16 0.483331 6.033396 17.619600 25.254035 4.783876 15.024450 0.675565
## 17 4.120462 1.003296 2.469660 34.016695 8.885350 13.138585 0.116515
## 18 1.837610 2.640217 1.157990 29.312319 9.673608 17.780340 0.242779
## 19 0.056723 1.754367 16.105330 6.981003 10.331720 18.349947 4.817419
## 20 4.829556 0.213828 1.609168 7.670526 6.561266 15.627530 1.706790
## 21 0.090547 0.350870 26.090330 7.965324 3.521437 14.648844 5.345115
## 22 2.637643 0.241878 1.791474 13.973264 10.587100 9.206715 0.743897
## 23 1.205221 0.841320 2.025783 13.401438 15.855990 19.476837 5.147163
## 24 3.418386 0.293315 1.986369 23.016125 11.197380 14.197637 1.042479
## 25 0.584940 5.843908 18.479160 9.433188 4.127535 18.597247 9.982428
## 26 4.637081 0.473161 2.282482 27.806148 8.116111 19.272143 1.376454
## 27 1.613998 1.455873 1.147608 24.550187 8.720063 23.711645 3.361365
## Corn.Products Beans other.agriculture Fruits Coniferous Broadleaf
## 1 10.534300 14.569750 0.000000 0.000000 0.093188 10.068360
## 2 5.208727 2.362924 0.004809 0.206214 7.212492 19.535140
## 3 7.552203 6.096373 0.000000 0.069325 0.739940 9.847008
## 4 1.753591 1.082778 0.004654 0.011346 7.789808 18.956080
## 5 5.222408 5.651176 0.247142 0.048650 5.806208 8.099890
## 6 0.720482 0.638645 0.017192 0.000000 9.816062 13.176380
## 7 6.983580 6.423356 0.000000 0.000000 3.861154 4.338992
## 8 1.405282 1.776215 0.000000 0.004106 6.412611 14.073360
## 9 2.014104 3.009975 0.000000 0.000000 6.311444 10.508160
## 10 17.653060 6.470494 0.000000 0.000000 0.182325 9.991383
## 11 5.189492 1.713026 0.000476 0.000852 7.336761 20.190570
## 12 17.628410 7.588988 0.000000 0.000000 0.690422 10.320970
## 13 2.414609 0.665576 0.000452 0.000000 7.547606 18.836160
## 14 13.600579 5.586310 0.000000 0.000000 5.176353 7.609499
## 15 1.188172 0.326734 0.004034 0.006491 9.529325 13.231120
## 16 7.615206 5.410009 0.032954 0.000000 3.732082 4.080850
## 17 1.377992 1.772279 0.006587 0.000000 6.358203 14.579020
## 18 8.245687 1.787297 0.000000 0.000000 6.219604 9.900414
## 19 10.911110 15.007330 0.036465 0.000000 0.024310 9.335014
## 20 4.083989 2.517848 0.048886 6.409648 6.386482 20.294830
## 21 13.225550 8.500118 0.093377 0.000000 0.302767 9.365976
## 22 1.805826 0.913758 0.013220 0.001972 6.031207 18.092070
## 23 8.274381 8.344437 0.019460 0.000000 5.629122 8.199136
## 24 1.098616 0.492250 0.020438 0.000000 8.735953 12.657730
## 25 8.576375 5.679136 0.389960 0.000000 4.168728 3.891362
## 26 3.066436 0.977718 0.008641 0.000000 5.617280 14.541640
## 27 3.103414 7.019814 0.055903 0.000000 4.929044 9.957116
## Mixed.Wood
## 1 5.299566
## 2 25.435210
## 3 7.451752
## 4 30.622300
## 5 7.069160
## 6 19.887200
## 7 6.571651
## 8 11.667510
## 9 6.781828
## 10 5.660163
## 11 26.219640
## 12 7.873362
## 13 30.208760
## 14 6.748070
## 15 19.781680
## 16 5.209537
## 17 11.754170
## 18 6.260333
## 19 4.217773
## 20 28.362980
## 21 8.447771
## 22 33.914990
## 23 6.489901
## 24 21.583580
## 25 5.967487
## 26 11.432430
## 27 5.759602
attach(mydata1)
## The following objects are masked from mydata (pos = 4):
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
##
## The following objects are masked from mydata (pos = 5):
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
##
## The following objects are masked from mydata (pos = 6):
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
mean(Fruits, na.rm=T)
## [1] 0.2503187
names(mydata1)
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood"
############################################################################
##Example to use
reg6=lm(SDISC~Pasture)# Fit Model
summary(reg6)# Model summary
##
## Call:
## lm(formula = SDISC ~ Pasture)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.47629 -0.15593 -0.03004 0.21892 0.50223
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.21892 0.17134 7.114 1.86e-07 ***
## Pasture 0.03407 0.01199 2.842 0.0088 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2511 on 25 degrees of freedom
## Multiple R-squared: 0.2442, Adjusted R-squared: 0.2139
## F-statistic: 8.077 on 1 and 25 DF, p-value: 0.008798
aov(reg6)# Analysis of variance
## Call:
## aov(formula = reg6)
##
## Terms:
## Pasture Residuals
## Sum of Squares 0.5090634 1.5757420
## Deg. of Freedom 1 25
##
## Residual standard error: 0.2510571
## Estimated effects may be unbalanced
plot(x=Pasture, y=SDISC,
main= "Relationship Pasture - SDISC on Bay of Quinte",pch=19, col="blue",
xlab="Pasture(%)", ylab="SDISC (m)") # Plot model
line(SDISC,Pasture)
##
## Call:
## line(SDISC, Pasture)
##
## Coefficients:
## [1] 8.542 3.162
fitted <- predict(reg6, interval = "confidence")# confidence interval
lines(Pasture, fitted[, "fit"],lwd=2)
lines(Pasture, fitted[, "lwr"], lty = "dotted",col="red",lwd=2)# lower confidence band
lines(Pasture, fitted[, "upr"], lty = "dotted",col="red",lwd=2) # Upper confidence band
legend("topright", bty="n", legend=paste("R2 is",
format(summary(reg6)$adj.r.squared, digits=4)))# Legend
coplot(SDISC~Pasture|SDISC,panel=panel.smooth) # coplot to observe parameter interaction
########################################################################################
#Effect of exposed land, corn and beans on fresh water temperature
re1=lm(CHOROPHYLL~Pasture)
summary(re1)
##
## Call:
## lm(formula = CHOROPHYLL ~ Pasture)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.516 -5.041 -3.747 -1.222 53.844
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.9923 9.1026 0.548 0.588
## Pasture 0.5195 0.6369 0.816 0.422
##
## Residual standard error: 13.34 on 25 degrees of freedom
## Multiple R-squared: 0.02592, Adjusted R-squared: -0.01305
## F-statistic: 0.6652 on 1 and 25 DF, p-value: 0.4224
aov(re1)
## Call:
## aov(formula = re1)
##
## Terms:
## Pasture Residuals
## Sum of Squares 118.330 4447.322
## Deg. of Freedom 1 25
##
## Residual standard error: 13.33765
## Estimated effects may be unbalanced
plot(CHOROPHYLL,Urban)
abline(CHOROPHYLL,Urban)
re2=lm(FWTEMP~Exposed.Land+I(Exposed.Land)^2)
summary(re2)
##
## Call:
## lm(formula = FWTEMP ~ Exposed.Land + I(Exposed.Land)^2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.4384 -1.0878 -0.1554 0.3441 2.5995
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 17.9002 0.3213 55.713 <2e-16 ***
## Exposed.Land -0.2365 0.1231 -1.921 0.0662 .
## I(Exposed.Land) NA NA NA NA
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.254 on 25 degrees of freedom
## Multiple R-squared: 0.1287, Adjusted R-squared: 0.0938
## F-statistic: 3.691 on 1 and 25 DF, p-value: 0.06617
plot(x=Exposed.Land, y=FWTEMP,
main= "Relationship Exposed Land - FWTEMP on Bay of Quinte",pch=19, col="blue",
xlab="Exposed Land(%)", ylab="FWTEMP (c)") # Plot model
fitted <- predict(re2, interval = "confidence")# confidence interval
lines(Exposed.Land, fitted[, "fit"],lwd=2)
lines(Exposed.Land, fitted[, "lwr"], lty = "dotted",col="red",lwd=2)# lower confidence band
lines(Exposed.Land, fitted[, "upr"], lty = "dotted",col="red",lwd=2) # Upper confidence band
legend("topright", bty="n", legend=paste("R2 is",
format(summary(re2)$adj.r.squared, digits=4)))# Legend
###################################################################################################
#Fresh water ph
names(mydata1)
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood"
re3=lm(FWPH~Grain)
summary(re3)
##
## Call:
## lm(formula = FWPH ~ Grain)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.42290 -0.14650 0.00056 0.15576 0.36666
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.12289 0.04936 164.558 <2e-16 ***
## Grain 0.02959 0.01508 1.962 0.0609 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1974 on 25 degrees of freedom
## Multiple R-squared: 0.1335, Adjusted R-squared: 0.09883
## F-statistic: 3.851 on 1 and 25 DF, p-value: 0.06093
plot(x=Grain, y=FWPH,
main= "Relationship Grain Production - FWTPH on Bay of Quinte",pch=19, col="blue",
xlab="Grain(%)", ylab="FWPH (mS/cm)") # Plot model
abline(re3)
fitted <- predict(re3, interval = "confidence")# confidence interval
lines(Grain, fitted[, "fit"],lwd=2)
lines(Grain, fitted[, "lwr"], lty = "dotted",col="red",lwd=2)# lower confidence band
lines(Grain, fitted[, "upr"], lty = "dotted",col="red",lwd=2) # Upper confidence band
legend("topright", bty="n", legend=paste("R2 is",
format(summary(re3)$adj.r.squared, digits=4)))# Legend
######################################################################################################
library(car)
names(mydata1)
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood"
r1=lm(PPFT~+Pasture)
summary(r1)
##
## Call:
## lm(formula = PPFT ~ +Pasture)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0026712 -0.0011385 -0.0001550 0.0006483 0.0053173
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.767e-03 1.352e-03 3.525 0.00166 **
## Pasture 2.755e-04 9.462e-05 2.912 0.00745 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.001981 on 25 degrees of freedom
## Multiple R-squared: 0.2533, Adjusted R-squared: 0.2234
## F-statistic: 8.48 on 1 and 25 DF, p-value: 0.007452
crPlots(r1)
########################################################################################################
names(mydata1)
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood"
r2=lm(CHOROPHYLL~other.agriculture)
summary(r2)
##
## Call:
## lm(formula = CHOROPHYLL ~ other.agriculture)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.059 -4.189 -2.804 0.680 40.285
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.603 2.551 3.765 0.000904 ***
## other.agriculture 67.500 27.564 2.449 0.021689 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 12.14 on 25 degrees of freedom
## Multiple R-squared: 0.1935, Adjusted R-squared: 0.1612
## F-statistic: 5.997 on 1 and 25 DF, p-value: 0.02169
crPlots(r2)
plot(other.agriculture, CHOROPHYLL, pch =19, col ="blue")
abline(r2,lwd = 2, col="red")
summary(r2)
##
## Call:
## lm(formula = CHOROPHYLL ~ other.agriculture)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.059 -4.189 -2.804 0.680 40.285
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.603 2.551 3.765 0.000904 ***
## other.agriculture 67.500 27.564 2.449 0.021689 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 12.14 on 25 degrees of freedom
## Multiple R-squared: 0.1935, Adjusted R-squared: 0.1612
## F-statistic: 5.997 on 1 and 25 DF, p-value: 0.02169
plot(x=CHOROPHYLL, y=other.agriculture,
main= "Relationship Other agriculture-CHOROPHYLL on Bay of Quinte",pch=19, col="blue",
xlab="Agriculture(%)", ylab="CHOROPHYLL(mg/l)") # Plot model
abline(r2)
fitted <- predict(r2, interval = "confidence")# confidence interval
lines(other.agriculture, fitted[, "fit"],lwd=2)
lines(other.agriculture, fitted[, "lwr"], lty = "dotted",col="red",lwd=2)# lower confidence band
lines(other.agriculture, fitted[, "upr"], lty = "dotted",col="red",lwd=2) # Upper confidence band
legend("topright", bty="n", legend=paste("R2 is",
format(summary(r2)$adj.r.squared, digits=4)))# Legend
###############################################################################################################
#Overview test for selected parameter 15/06/2015
################################################################################################################
mydata
## OBJECTID_1.. Shape.. OBJECTID Year gridcode WatershedI Area
## 1 1 Polygon 1 2013 1 1 22.2131
## 2 2 Polygon 2 2013 0 2 3593.6400
## 3 3 Polygon 3 2013 3 3 63.6132
## 4 4 Polygon 4 2013 0 4 2784.3400
## 5 5 Polygon 5 2013 0 5 138.7460
## 6 6 Polygon 6 2013 0 6 1026.0600
## 7 7 Polygon 7 2013 7 7 32.7726
## 8 8 Polygon 8 2013 8 8 1052.0500
## 9 9 Polygon 9 2013 0 9 112.6950
## 10 10 Polygon 10 2012 0 1 22.2131
## 11 11 Polygon 11 2012 0 2 3593.6400
## 12 12 Polygon 12 2012 0 3 63.6132
## 13 13 Polygon 13 2012 0 4 2784.3400
## 14 14 Polygon 14 2012 0 5 138.7460
## 15 15 Polygon 15 2012 0 6 1026.0600
## 16 16 Polygon 16 2012 0 7 32.7726
## 17 17 Polygon 17 2012 0 8 1052.0500
## 18 18 Polygon 18 2012 0 9 112.6950
## 19 19 Polygon 19 Polygon 19 1 22.2131
## 20 20 Polygon 20 Polygon 20 2 3593.6400
## 21 21 Polygon 21 Polygon 21 3 63.6132
## 22 22 Polygon 22 Polygon 22 4 2784.3400
## 23 23 Polygon 23 Polygon 23 5 138.7460
## 24 24 Polygon 24 Polygon 24 6 1026.0600
## 25 25 Polygon 25 Polygon 25 7 32.7726
## 26 26 Polygon 26 Polygon 26 8 1052.0500
## 27 27 Polygon 27 Polygon 27 9 112.6950
## CHOROPHYLL CONDFIELD DO FWPH FWTEMP MCTOT PCRFU
## 1 6.225000 254.7586 9.12213 8.285350 19.78100 1.2166700 1.0564800
## 2 5.980000 255.7133 9.38837 8.119020 20.30420 0.1583330 0.7925930
## 3 5.235000 257.3951 8.71554 8.192520 20.06130 0.0300000 0.7959880
## 4 2.317778 237.7856 10.37260 8.227790 18.13300 0.9128570 0.6420000
## 5 66.570000 256.0574 8.73040 8.305170 19.85320 4.8120000 1.1596300
## 6 5.535000 246.2133 9.23891 8.070300 18.38180 1.7800000 0.5753330
## 7 11.005556 303.2860 9.96349 8.022360 16.33680 2.1545500 1.3370500
## 8 5.544286 256.8065 9.84252 8.365080 18.26880 0.8077780 1.6369400
## 9 9.917500 286.1991 8.20674 8.206740 17.08170 0.5840000 1.4309000
## 10 6.921429 258.7545 11.11249 7.946004 16.37412 4.1709414 0.7874660
## 11 7.028571 276.6121 11.69927 7.918423 16.83617 8.5060000 0.9086706
## 12 5.284615 276.8996 11.68883 7.927533 16.59223 8.5060000 0.8833761
## 13 12.876923 265.9464 12.26378 7.995238 16.54946 11.4543817 1.1190476
## 14 6.430769 250.0345 11.91570 8.017071 15.92044 0.0000000 1.0204762
## 15 7.071429 262.7923 11.51454 7.976560 16.31663 5.8325420 1.2090476
## 16 7.935714 282.0768 10.84007 7.719973 15.45208 9.8922145 1.3146599
## 17 43.600000 264.9231 11.60086 8.131879 17.28083 11.5205035 2.7264835
## 18 10.650000 280.6090 10.78354 7.985160 16.03781 12.2530000 2.0805536
## 19 5.008333 255.0377 12.67648 8.445817 17.26703 0.4649484 0.9385714
## 20 8.929167 264.1389 12.85899 8.335632 17.80013 0.1162936 1.7624339
## 21 10.091667 262.3361 11.32984 8.430801 17.93573 0.2680594 1.5152778
## 22 9.612500 276.1458 12.92521 8.401389 17.87139 0.4866084 1.2194444
## 23 8.462500 249.0417 13.14794 8.421403 17.02688 0.7218186 0.9891667
## 24 15.304545 264.2803 12.07167 8.426515 17.67545 0.7312644 1.4522727
## 25 12.866667 303.2709 10.18907 8.239279 16.67454 0.7037500 1.1322619
## 26 17.268182 262.0000 11.72590 8.530277 18.09656 1.0254015 1.3023377
## 27 13.431818 274.7917 10.68493 8.344741 16.39815 0.9445911 1.0477904
## PHYCO PON PPFT PPPT PPUT SDISC
## 1 2101.680 0.13425000 0.007300000 0.01818300 0.02190000 1.7857100
## 2 1710.530 0.12175000 0.005600000 0.01433300 0.01903300 1.6222200
## 3 1740.700 0.11575000 0.006400000 0.01763300 0.02330000 1.7000000
## 4 1280.570 0.08800000 0.006850000 0.01178000 0.01828200 1.5428600
## 5 2436.540 0.20950000 0.006900000 0.01874000 0.02370000 1.6400000
## 6 1232.410 0.11900000 0.006600000 0.00000000 0.01746700 1.7500000
## 7 2847.440 0.19600000 0.008150000 0.03329000 0.03340900 1.7090900
## 8 3314.880 0.26112500 0.008500000 0.03151000 0.03567300 1.3916700
## 9 3124.510 0.27475000 0.008500000 0.02958000 0.04150900 1.6500000
## 10 1710.526 0.18208333 0.008207143 0.01780000 0.02371429 1.8230769
## 11 1931.997 0.13266667 0.006538462 0.01360909 0.01963077 1.9285714
## 12 1879.574 0.13927273 0.006541667 0.01343000 0.01931667 1.9538462
## 13 2386.976 0.22740000 0.008275000 0.02131000 0.02719167 0.9714286
## 14 2110.712 0.15318182 0.007784615 0.01146000 0.02380000 1.5571429
## 15 2656.679 0.18541667 0.008276923 0.02113636 0.02672308 1.2892857
## 16 2830.466 0.16525000 0.013900000 0.02433636 0.03745385 2.0500000
## 17 5811.222 0.28975000 0.009914286 0.03034167 0.03985000 1.6142857
## 18 4404.485 0.25200000 0.010064286 0.02591667 0.03234286 1.8071429
## 19 1816.530 0.08981818 0.007491667 0.01169167 0.01871667 2.3463636
## 20 3804.942 0.16845455 0.006808333 0.01570833 0.02332500 1.4683333
## 21 3187.034 0.17145455 0.008225000 0.01990000 0.03035833 1.5716667
## 22 2634.910 0.14672727 0.009275000 0.01969167 0.02505833 1.4416667
## 23 2118.613 0.13872727 0.008191667 0.01525000 0.02387500 1.7550000
## 24 3100.235 0.22060000 0.008518182 0.02035455 0.03101818 1.3818182
## 25 2223.507 0.16318182 0.015208333 0.01958333 0.03748333 2.1400000
## 26 2864.650 0.15200000 0.010900000 0.01980909 0.03106364 1.6227273
## 27 2197.176 0.17680000 0.011790909 0.01804545 0.03241818 2.0108333
## Water Exposed.Land Urban Shrubland Wetland Pasture Grain
## 1 0.072930 2.029880 17.592290 17.511260 10.392500 9.586217 0.024310
## 2 4.515051 0.296273 1.920768 11.775750 7.497971 12.718620 1.210513
## 3 0.165532 0.557431 31.043540 15.272770 4.023691 10.359170 4.582537
## 4 2.670904 0.382744 2.090145 16.786900 10.693250 6.767476 0.334550
## 5 1.406956 2.733478 2.037459 19.939990 16.995040 14.888180 4.918833
## 6 3.716262 0.992044 2.154078 27.216480 11.326060 9.785450 0.242968
## 7 0.505300 8.153461 18.053500 16.658430 4.838800 12.841220 6.159721
## 8 4.645465 1.871257 2.506701 33.063790 8.285323 13.486930 0.397110
## 9 1.998132 2.695321 1.169170 32.970770 9.656038 15.287060 2.815113
## 10 0.060775 1.572042 15.744730 19.622170 10.724730 10.153450 0.109395
## 11 4.408438 0.273934 1.629153 11.719380 7.606212 13.437390 0.220088
## 12 0.142895 0.560261 25.760680 13.006252 4.182149 10.008300 0.149969
## 13 2.171827 0.306461 1.800622 17.622600 11.549570 6.715176 0.105634
## 14 1.160463 2.289142 2.016053 18.184695 17.296020 14.784390 0.558501
## 15 3.203399 0.642680 2.051453 27.497347 11.855500 10.366120 0.059645
## 16 0.483331 6.033396 17.619600 25.254035 4.783876 15.024450 0.675565
## 17 4.120462 1.003296 2.469660 34.016695 8.885350 13.138585 0.116515
## 18 1.837610 2.640217 1.157990 29.312319 9.673608 17.780340 0.242779
## 19 0.056723 1.754367 16.105330 6.981003 10.331720 18.349947 4.817419
## 20 4.829556 0.213828 1.609168 7.670526 6.561266 15.627530 1.706790
## 21 0.090547 0.350870 26.090330 7.965324 3.521437 14.648844 5.345115
## 22 2.637643 0.241878 1.791474 13.973264 10.587100 9.206715 0.743897
## 23 1.205221 0.841320 2.025783 13.401438 15.855990 19.476837 5.147163
## 24 3.418386 0.293315 1.986369 23.016125 11.197380 14.197637 1.042479
## 25 0.584940 5.843908 18.479160 9.433188 4.127535 18.597247 9.982428
## 26 4.637081 0.473161 2.282482 27.806148 8.116111 19.272143 1.376454
## 27 1.613998 1.455873 1.147608 24.550187 8.720063 23.711645 3.361365
## Corn.Products Beans other.agriculture Fruits Coniferous Broadleaf
## 1 10.534300 14.569750 0.000000 0.000000 0.093188 10.068360
## 2 5.208727 2.362924 0.004809 0.206214 7.212492 19.535140
## 3 7.552203 6.096373 0.000000 0.069325 0.739940 9.847008
## 4 1.753591 1.082778 0.004654 0.011346 7.789808 18.956080
## 5 5.222408 5.651176 0.247142 0.048650 5.806208 8.099890
## 6 0.720482 0.638645 0.017192 0.000000 9.816062 13.176380
## 7 6.983580 6.423356 0.000000 0.000000 3.861154 4.338992
## 8 1.405282 1.776215 0.000000 0.004106 6.412611 14.073360
## 9 2.014104 3.009975 0.000000 0.000000 6.311444 10.508160
## 10 17.653060 6.470494 0.000000 0.000000 0.182325 9.991383
## 11 5.189492 1.713026 0.000476 0.000852 7.336761 20.190570
## 12 17.628410 7.588988 0.000000 0.000000 0.690422 10.320970
## 13 2.414609 0.665576 0.000452 0.000000 7.547606 18.836160
## 14 13.600579 5.586310 0.000000 0.000000 5.176353 7.609499
## 15 1.188172 0.326734 0.004034 0.006491 9.529325 13.231120
## 16 7.615206 5.410009 0.032954 0.000000 3.732082 4.080850
## 17 1.377992 1.772279 0.006587 0.000000 6.358203 14.579020
## 18 8.245687 1.787297 0.000000 0.000000 6.219604 9.900414
## 19 10.911110 15.007330 0.036465 0.000000 0.024310 9.335014
## 20 4.083989 2.517848 0.048886 6.409648 6.386482 20.294830
## 21 13.225550 8.500118 0.093377 0.000000 0.302767 9.365976
## 22 1.805826 0.913758 0.013220 0.001972 6.031207 18.092070
## 23 8.274381 8.344437 0.019460 0.000000 5.629122 8.199136
## 24 1.098616 0.492250 0.020438 0.000000 8.735953 12.657730
## 25 8.576375 5.679136 0.389960 0.000000 4.168728 3.891362
## 26 3.066436 0.977718 0.008641 0.000000 5.617280 14.541640
## 27 3.103414 7.019814 0.055903 0.000000 4.929044 9.957116
## Mixed.Wood Grain1
## 1 5.299566 -3.71686749
## 2 25.435210 0.19104424
## 3 7.451752 1.52225277
## 4 30.622300 -1.09496893
## 5 7.069160 1.59307131
## 6 19.887200 -1.41482553
## 7 6.571651 1.81803148
## 8 11.667510 -0.92354196
## 9 6.781828 1.03500240
## 10 5.660163 -2.21279009
## 11 26.219640 -1.51372781
## 12 7.873362 -1.89732667
## 13 30.208760 -2.24777499
## 14 6.748070 -0.58249887
## 15 19.781680 -2.81934496
## 16 5.209537 -0.39220590
## 17 11.754170 -2.14973526
## 18 6.260333 -1.41560371
## 19 4.217773 1.57223831
## 20 28.362980 0.53461441
## 21 8.447771 1.67618306
## 22 33.914990 -0.29585269
## 23 6.489901 1.63844569
## 24 21.583580 0.04160153
## 25 5.967487 2.30082635
## 26 11.432430 0.31951063
## 27 5.759602 1.21234714
names(mydata)
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood" "Grain1"
attach(mydata)
## The following objects are masked from mydata1:
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
##
## The following objects are masked from mydata (pos = 6):
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## Grain1, gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
##
## The following objects are masked from mydata (pos = 7):
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## Grain1, gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
##
## The following objects are masked from mydata (pos = 8):
##
## Area, Beans, Broadleaf, CHOROPHYLL, CONDFIELD, Coniferous,
## Corn.Products, DO, Exposed.Land, Fruits, FWPH, FWTEMP, Grain,
## gridcode, MCTOT, Mixed.Wood, OBJECTID, OBJECTID_1..,
## other.agriculture, Pasture, PCRFU, PHYCO, PON, PPFT, PPPT,
## PPUT, SDISC, Shape.., Shrubland, Urban, Water, WatershedI,
## Wetland, Year
Model1=lm(PHYCO~Urban+Pasture+Grain+Exposed.Land+Shrubland+Corn.Products+Beans+Coniferous+Broadleaf+Mixed.Wood+other.agriculture)
summary(Model1)
##
## Call:
## lm(formula = PHYCO ~ Urban + Pasture + Grain + Exposed.Land +
## Shrubland + Corn.Products + Beans + Coniferous + Broadleaf +
## Mixed.Wood + other.agriculture)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1258.22 -445.25 -59.89 297.49 2247.80
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1993.114 11809.331 -0.169 0.868
## Urban 6.696 72.695 0.092 0.928
## Pasture 109.579 117.255 0.935 0.365
## Grain 58.610 314.636 0.186 0.855
## Exposed.Land 122.744 168.920 0.727 0.479
## Shrubland 98.618 173.378 0.569 0.578
## Corn.Products 33.399 222.460 0.150 0.883
## Beans -46.358 237.264 -0.195 0.848
## Coniferous -164.934 301.903 -0.546 0.593
## Broadleaf 78.065 152.375 0.512 0.616
## Mixed.Wood 47.550 173.331 0.274 0.788
## other.agriculture 524.178 3577.502 0.147 0.885
##
## Residual standard error: 1028 on 15 degrees of freedom
## Multiple R-squared: 0.3708, Adjusted R-squared: -0.09062
## F-statistic: 0.8036 on 11 and 15 DF, p-value: 0.637
names(mydata)
## [1] "OBJECTID_1.." "Shape.." "OBJECTID"
## [4] "Year" "gridcode" "WatershedI"
## [7] "Area" "CHOROPHYLL" "CONDFIELD"
## [10] "DO" "FWPH" "FWTEMP"
## [13] "MCTOT" "PCRFU" "PHYCO"
## [16] "PON" "PPFT" "PPPT"
## [19] "PPUT" "SDISC" "Water"
## [22] "Exposed.Land" "Urban" "Shrubland"
## [25] "Wetland" "Pasture" "Grain"
## [28] "Corn.Products" "Beans" "other.agriculture"
## [31] "Fruits" "Coniferous" "Broadleaf"
## [34] "Mixed.Wood" "Grain1"
library(knitr)
fit=lm(PPPT~Exposed.Land)
summary(fit)
##
## Call:
## lm(formula = PPPT ~ Exposed.Land)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0178810 -0.0027757 -0.0009241 0.0037052 0.0124426
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0162893 0.0016672 9.771 5.11e-10 ***
## Exposed.Land 0.0016045 0.0006387 2.512 0.0188 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006509 on 25 degrees of freedom
## Multiple R-squared: 0.2015, Adjusted R-squared: 0.1696
## F-statistic: 6.31 on 1 and 25 DF, p-value: 0.01883
#Exclusion of Liability
#In no event will Alexand Jick Neba be liable for any damages,
#including without limitation, direct or indirect, special, incidental,
#moral or consequential damages, loss of profits or data, opportunities or
#information or for expenses arising from using this R Script,
#with any software algorithms available thereon nor with any data
#or for use thereof or inability to use by interruption, defect,
#delay in operation or system failure.
#It is advised that any user should have acquired at least advanced statistical modeling
#knowledge at the master degree level, and a sound understanding of R statistical environment.