Skip to content

Amakihi in Distance 1.0.3 vs DistWin 7.3 #40

Description

@erex

Fitting 3 models to Amakihi in both R and Distwin:
Models hr(OBs+MAS), hn(OBs), hn(OBs+scale(MAS)) note that curiously, hn(OBs+MAS) fails

There are some degrees of freedom discrepancies, but note also that point estimates of density have best agreement for hn(OBs+scale(MAS) and least agreement for hn(OBs), intermediate for hr(OBs+MAS)

library(Distance)
data("amakihi")
amakihi$Area <- 1
amakihi$OBs <- relevel(amakihi$OBs, ref="TKP")
trunc <- 82.5
conv <- convert_units("meter", NULL, "hectare")
aukhr <- ds(data=amakihi, transect = "point", convert.units = conv,
key="hr", formula=~OBs+MAS, truncation = trunc)
aukhn1 <- ds(data=amakihi, transect = "point", convert.units = conv,
key="hn", formula=~OBs, truncation = trunc)
aukhn2 <- ds(data=amakihi, transect = "point", convert.units = conv,
key="hn", formula=~OBs+scale(MAS), truncation = trunc)
# should fail
aukhn2 <- ds(data=amakihi, transect = "point", convert.units = conv,
key="hn", formula=~OBs+MAS, truncation = trunc)
#
distwinhr <- read.table(text=
"
July 92 7.7366 9.58 173.17 6.4060 9.3436 Dec 92 6.0996 12.11 110.67 4.8020 7.7479 Apr 93 6.9409 7.85 117.23 5.9432 8.1060 July 93 8.9561 9.06 157.23 7.4913 10.707 Jan 94 4.9471 9.49 100.15 4.1000 5.9693 Apr 94 7.5291 8.22 130.38 6.4013 8.8557 Apr 95 7.9978 11.25 79.71 6.3984 9.9970
", stringsAsFactors=FALSE)
names(distwinhr) <- c("month", "year", "density", "cv", "df", "lcl", "ucl")
distwinhr$survey <- paste0(distwinhr$month, distwinhr$year)
rpack103hr <- aukhr$dht$individuals$D
rpack103hr <- rpack103hr[-8,] # remove total row
rpack103hr <- rpack103hr[c(6,1,3,7,2,4,5), ] # chronological ordering
plot(rpack103hr$Estimate,
ylim=range(c(distwinhr$density, rpack103hr$Estimate)), xaxt="n",
xlab="Survey", main="Amakihi hr(OBs+MAS)\nDistwin vs Distance 1.0.3")
axis(1, at=1:7, labels=distwinhr$survey)
points(distwinhr$density, pch=20)
legend("bottomright", legend = c("R", "DistWin"), pch=c(1,20))
pcthr <- data.frame(survey=distwinhr$survey,
percenthr=round(rpack103hr$Estimate / distwinhr$density, 4))
pcthr
comphr <- data.frame(dfR=rpack103hr$df, dfD=distwinhr$df,
lclR=rpack103hr$lcl, lclD=distwinhr$lcl,
cvR=rpack103hr$cv, cvD=distwinhr$cv/100)
comphr
#================================= Only OBs covar, MAS fails
distwinhn <- read.table(text=
"
July 92 7.8171 9.27 168.17 6.5118 9.3840 Dec 92 6.6367 11.64 99.29 5.2726 8.3537 Apr 93 9.3903 8.09 128.31 8.0039 11.017 July 93 9.4015 8.60 138.88 7.9338 11.141 Jan 94 6.9919 9.81 110.57 5.7593 8.4884 Apr 94 9.7917 8.52 136.87 8.2761 11.585 Apr 95 9.4284 11.07 75.41 7.5674 11.747 ", stringsAsFactors=FALSE)
names(distwinhn) <- c("month", "year", "density", "cv", "df", "lcl", "ucl")
distwinhn$survey <- paste0(distwinhn$month, distwinhn$year)
rpack103hn <- aukhn1$dht$individuals$D
rpack103hn <- rpack103hn[-8,] # remove total row
rpack103hn <- rpack103hn[c(6,1,3,7,2,4,5), ] # chronological ordering
plot(rpack103hn$Estimate, ylim=range(c(distwinhn$density, rpack103hn$Estimate)), xaxt="n",
xlab="Survey", main="Amakihi hn(OBs)\nDistwin vs Distance 1.0.3")
axis(1, at=1:7, labels=distwinhn$survey)
points(distwinhn$density, pch=20)
legend("bottomright", legend = c("R", "DistWin"), pch=c(1,20))
pcthn <- data.frame(survey=distwinhn$survey,
percenthr=round(rpack103hn$Estimate / distwinhn$density, 4))
pcthn
comphn <- data.frame(dfR=rpack103hn$df, dfD=distwinhn$df,
lclR=rpack103hn$lcl, lclD=distwinhn$lcl,
cvR=rpack103hn$cv, cvD=distwinhn$cv/100)
comphn
#================================= OBs+scale(MAS) covar
distwinhn <- read.table(text=
"
July 92 6.0353 9.09 164.77 5.0452 7.2197 Dec 92 4.9281 11.48 95.51 3.9268 6.1847 Apr 93 7.1205 7.88 118.53 6.0938 8.3203 July 93 7.5425 8.50 134.89 6.3768 8.9213 Jan 94 4.9985 9.50 100.53 4.1416 6.0326 Apr 94 7.8371 8.28 131.74 6.6552 9.2290 Apr 95 7.2941 10.93 72.03 5.8696 9.0643 ", stringsAsFactors=FALSE)
names(distwinhn) <- c("month", "year", "density", "cv", "df", "lcl", "ucl")
distwinhn$survey <- paste0(distwinhn$month, distwinhn$year)
rpack103hn <- aukhn2$dht$individuals$D
rpack103hn <- rpack103hn[-8,] # remove total row
rpack103hn <- rpack103hn[c(6,1,3,7,2,4,5), ] # chronological ordering
plot(rpack103hn$Estimate, ylim=range(c(distwinhn$density, rpack103hn$Estimate)), xaxt="n",
xlab="Survey", main="Amakihi hn(OBs+scale(MAS))\nDistwin vs Distance 1.0.3")
axis(1, at=1:7, labels=distwinhn$survey)
points(distwinhn$density, pch=20)
legend("bottomright", legend = c("R", "DistWin"), pch=c(1,20))
pcthn <- data.frame(survey=distwinhn$survey,
percenthr=round(rpack103hn$Estimate / distwinhn$density, 4))
pcthn
comphn <- data.frame(dfR=rpack103hn$df, dfD=distwinhn$df,
lclR=rpack103hn$lcl, lclD=distwinhn$lcl,
cvR=rpack103hn$cv, cvD=distwinhn$cv/100)
comphn

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions