R version 2.6.1 (2007-11-26) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > ## > library(arm) Loading required package: MASS Loading required package: Matrix Loading required package: lattice Attaching package: 'Matrix' The following object(s) are masked from package:stats : xtabs Loading required package: lme4 Loading required package: R2WinBUGS Loading required package: coda arm (Version 1.1-1, built: 2008-1-13) Working directory is D:/Program Files/R/R-2.6.1 options( digits = 2 ) Loading required package: car Loading required package: foreign Warning messages: 1: In namespaceImportFrom(self, asNamespace(ns)) : replacing previous import: cov2cor 2: In namespaceImportFrom(self, asNamespace(ns)) : replacing previous import: xtabs 3: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called 'car' > gala=read.table(file.choose(),header=T) > gala Species Area Elevation Nearest Scruz Adjacent Baltra 58 25.09 346 0.6 0.6 1.84 Bartolome 31 1.24 109 0.6 26.3 572.33 Caldwell 3 0.21 114 2.8 58.7 0.78 Champion 25 0.10 46 1.9 47.4 0.18 Coamano 2 0.05 77 1.9 1.9 903.82 Daphne.Major 18 0.34 119 8.0 8.0 1.84 Daphne.Minor 24 0.08 93 6.0 12.0 0.34 Darwin 10 2.33 168 34.1 290.2 2.85 Eden 8 0.03 71 0.4 0.4 17.95 Enderby 2 0.18 112 2.6 50.2 0.10 Espanola 97 58.27 198 1.1 88.3 0.57 Fernandina 93 634.49 1494 4.3 95.3 4669.32 Gardner1 58 0.57 49 1.1 93.1 58.27 Gardner2 5 0.78 227 4.6 62.2 0.21 Genovesa 40 17.35 76 47.4 92.2 129.49 Isabela 347 4669.32 1707 0.7 28.1 634.49 Marchena 51 129.49 343 29.1 85.9 59.56 Onslow 2 0.01 25 3.3 45.9 0.10 Pinta 104 59.56 777 29.1 119.6 129.49 Pinzon 108 17.95 458 10.7 10.7 0.03 Las.Plazas 12 0.23 94 0.5 0.6 25.09 Rabida 70 4.89 367 4.4 24.4 572.33 SanCristobal 280 551.62 716 45.2 66.6 0.57 SanSalvador 237 572.33 906 0.2 19.8 4.89 SantaCruz 444 903.82 864 0.6 0.1 0.52 SantaFe 62 24.08 259 16.5 16.5 0.52 SantaMaria 285 170.92 640 2.6 49.2 0.10 Seymour 44 1.84 147 0.6 9.6 25.09 Tortuga 16 1.24 186 6.8 50.9 17.95 Wolf 21 2.85 253 34.1 254.7 2.33 > attach(gala) > xyplot(Species~ Area) > xyplot(Species~ Area,type=c('p','t')) > xyplot(Species~ Area,type=c('p','r')) > xyplot(Species~ log(Area)) > xyplot(Species~ Elevation) > xyplot(Species~ log(Elevation)) > xyplot(Species~ log(Elevation)) > xyplot(Species~ Nearest) > xyplot(Species~ log(Nearest)) > xyplot(Species~ Scruz) > xyplot(Species~ log(Scruz)) > xyplot(Species~ Adjacent) > xyplot(Species~ log(Adjacent)) > > fit3=glm(Species~log(Area)+Elevation+log(Nearest)+Scruz+log(Adjacent),family=poisson) > display(fit3,digit=5) glm(formula = Species ~ log(Area) + Elevation + log(Nearest) + Scruz + log(Adjacent), family = poisson) coef.est coef.se (Intercept) 3.49648 0.05238 log(Area) 0.35249 0.01482 Elevation 0.00003 0.00010 log(Nearest) -0.02180 0.01452 Scruz -0.00263 0.00059 log(Adjacent) -0.08775 0.00875 --- n = 30, k = 6 residual deviance = 345.6, null deviance = 3510.7 (difference = 3165.2) > fit3=glm(Species~log(Area)+Elevation+Nearest+Scruz+log(Adjacent),family=poisson) > display(fit3,digit=5) glm(formula = Species ~ log(Area) + Elevation + Nearest + Scruz + log(Adjacent), family = poisson) coef.est coef.se (Intercept) 3.48837 0.05207 log(Area) 0.35741 0.01584 Elevation 0.00001 0.00010 Nearest -0.00182 0.00167 Scruz -0.00279 0.00058 log(Adjacent) -0.08630 0.00872 --- n = 30, k = 6 residual deviance = 346.6, null deviance = 3510.7 (difference = 3164.1) > fit1=glm(Species~Area+Elevation+Nearest+Scruz+Adjacent,family=poisson) > display(fit1,digit=5) glm(formula = Species ~ Area + Elevation + Nearest + Scruz + Adjacent, family = poisson) coef.est coef.se (Intercept) 3.15472 0.05175 Area -0.00058 0.00003 Elevation 0.00354 0.00009 Nearest 0.00881 0.00182 Scruz -0.00571 0.00063 Adjacent -0.00066 0.00003 --- n = 30, k = 6 residual deviance = 717.0, null deviance = 3510.7 (difference = 2793.7) > mean(gala); sd(gala) Species Area Elevation Nearest Scruz Adjacent 85 262 368 10 57 261 Species Area Elevation Nearest Scruz Adjacent 115 864 422 14 68 865 > exp( predict(fit3, data.frame(Area=mean(Area),Elevation=mean(Elevation),Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 125 > exp( predict(fit3, data.frame(Area=mean(Area)+sd(Area),Elevation=mean(Elevation),Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 210 > exp( predict(fit3, data.frame(Area=mean(Area),Elevation=mean(Elevation),Nearest=mean(Nearest)+sd(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 121 > exp( predict(fit3, data.frame(Area=exp(mean(log(Area))),Elevation=mean(Elevation),Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=exp(mean(log(Adjacent))))) ) [1] 41 > exp( predict(fit3, data.frame(Area=exp(mean(log(Area))+sd(log(Area))),Elevation=mean(Elevation),Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=exp(mean(log(Adjacent))))) ) [1] 144 > mean(log(gala)); sd(lof(gala)) Species Area Elevation Nearest Scruz Adjacent 3.5 1.6 5.4 1.2 3.1 1.7 Error in sd(lof(gala)) : could not find function "lof" > mean(log(gala)); sd(log(gala)) Species Area Elevation Nearest Scruz Adjacent 3.5 1.6 5.4 1.2 3.1 1.7 Species Area Elevation Nearest Scruz Adjacent 1.6 3.5 1.1 1.6 2.0 3.3 > display(fit3,digit=5) glm(formula = Species ~ log(Area) + Elevation + Nearest + Scruz + log(Adjacent), family = poisson) coef.est coef.se (Intercept) 3.48837 0.05207 log(Area) 0.35741 0.01584 Elevation 0.00001 0.00010 Nearest -0.00182 0.00167 Scruz -0.00279 0.00058 log(Adjacent) -0.08630 0.00872 --- n = 30, k = 6 residual deviance = 346.6, null deviance = 3510.7 (difference = 3164.1) > fit4=glm(Species~log(Area)+Nearest+Scruz+log(Adjacent),family=poisson) > display(fit4,digit=5) glm(formula = Species ~ log(Area) + Nearest + Scruz + log(Adjacent), family = poisson) coef.est coef.se (Intercept) 3.48916 0.05158 log(Area) 0.35889 0.00812 Nearest -0.00189 0.00157 Scruz -0.00279 0.00058 log(Adjacent) -0.08568 0.00657 --- n = 30, k = 5 residual deviance = 346.6, null deviance = 3510.7 (difference = 3164.1) > exp( predict(fit3, data.frame(Area=mean(Area),Elevation=1000,Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 125 > exp( predict(fit4, data.frame(Area=mean(Area),Elevation=1000,Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 125 > exp( predict(fit3, data.frame(Area=mean(Area),Elevation=30,Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 124 > exp( predict(fit4, data.frame(Area=mean(Area),Elevation=30,Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 125 > fit4=glm(Species~log(Area)+Nearest+Scruz+log(Adjacent),family=quasipoisson) > fit4=glm(Species~log(Area)+Nearest+Scruz+log(Adjacent),family=poisson) > fit5=glm(Species~log(Area)+Nearest+Scruz+log(Adjacent),family=quasipoisson) > display(fit4,digit=5) glm(formula = Species ~ log(Area) + Nearest + Scruz + log(Adjacent), family = poisson) coef.est coef.se (Intercept) 3.48916 0.05158 log(Area) 0.35889 0.00812 Nearest -0.00189 0.00157 Scruz -0.00279 0.00058 log(Adjacent) -0.08568 0.00657 --- n = 30, k = 5 residual deviance = 346.6, null deviance = 3510.7 (difference = 3164.1) > display(fit5,digit=5) glm(formula = Species ~ log(Area) + Nearest + Scruz + log(Adjacent), family = quasipoisson) coef.est coef.se (Intercept) 3.48916 0.20301 log(Area) 0.35889 0.03195 Nearest -0.00189 0.00616 Scruz -0.00279 0.00228 log(Adjacent) -0.08568 0.02584 --- n = 30, k = 5 residual deviance = 346.6, null deviance = 3510.7 (difference = 3164.1) overdispersion parameter = 15.5 > sqrt(15.5) [1] 3.9 > fit6=glm(Species~Nearest+Scruz+log(Adjacent),offset=log(Area)+family=poisson) Error: unexpected '=' in "fit6=glm(Species~Nearest+Scruz+log(Adjacent),offset=log(Area)+family=" > fit6=glm(Species~Nearest+Scruz+log(Adjacent),offset=log(Area),family=poisson) > display(fit6,digit=5) glm(formula = Species ~ Nearest + Scruz + log(Adjacent), family = poisson, offset = log(Area)) coef.est coef.se (Intercept) -0.62124 0.02861 Nearest -0.01670 0.00143 Scruz 0.01368 0.00052 log(Adjacent) -0.28524 0.00602 --- n = 30, k = 4 residual deviance = 3317.4, null deviance = 5766.9 (difference = 2449.5) > exp( predict(fit4, data.frame(Area=10,Elevation=mean(Elevation),Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 39 > exp( predict(fit6, data.frame(Area=10,Elevation=mean(Elevation),Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 2.0 > exp( predict(fit4, data.frame(Area=1500,Elevation=mean(Elevation),Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 235 > exp( predict(fit6, data.frame(Area=1500,Elevation=mean(Elevation),Nearest=mean(Nearest),Scruz=mean(Scruz),Adjacent=mean(Adjacent))) ) [1] 304 > >