# Poisson CQO with equal tolerances
set.seed(111) # This leads to the global solution
hspider[,1:6] = scale(hspider[,1:6]) # Good idea when ITolerances = TRUE
p1 = cqo(cbind(Alopacce, Alopcune, Alopfabr, Arctlute, Arctperi, Auloalbi,
Pardlugu, Pardmont, Pardnigr, Pardpull, Trocterr, Zoraspin) ~
WaterCon + BareSand + FallTwig + CoveMoss + CoveHerb + ReflLux,
quasipoissonff, data = hspider, EqualTolerances = TRUE)
sort(p1@misc$deviance.Bestof) # A history of all the iterations
(isdlv = sd(lv(p1))) # Should be approx isdlv
# Refit the model with better initial values
set.seed(111) # This leads to the global solution
p1 = cqo(cbind(Alopacce, Alopcune, Alopfabr, Arctlute, Arctperi, Auloalbi,
Pardlugu, Pardmont, Pardnigr, Pardpull, Trocterr, Zoraspin) ~
WaterCon + BareSand + FallTwig + CoveMoss + CoveHerb + ReflLux,
ITolerances = TRUE, isdlv = isdlv, # Note the use of isdlv here
fam = quasipoissonff, data = hspider)
sort(p1@misc$deviance.Bestof) # A history of all the iterations
# Negative binomial CQO; smallest deviance is about 275.389
set.seed(1234) # This leads to a reasonable (but not the global) solution?
nb1 = cqo(cbind(Alopacce, Alopcune, Alopfabr, Arctlute, Arctperi, Auloalbi,
Pardlugu, Pardmont, Pardnigr, Pardpull, Trocterr, Zoraspin) ~
WaterCon + BareSand + FallTwig + CoveMoss + CoveHerb + ReflLux,
ITol = FALSE, EqualTol = TRUE, # A good idea for negbinomial
fam = negbinomial, data = hspider)
sort(nb1@misc$deviance.Bestof) # A history of all the iterations
summary(nb1)
lvplot(nb1, lcol=1:12, y = TRUE, pcol=1:12)
Run the code above in your browser using DataLab