Title: | Data Files and Functions Accompanying the Book "Bayesian Data Analysis in Ecology using R, BUGS and Stan" |
---|---|
Description: | Data files and functions accompanying the book Korner-Nievergelt, Roth, von Felten, Guelat, Almasi, Korner-Nievergelt (2015) "Bayesian Data Analysis in Ecology using R, BUGS and Stan", Elsevier, New York. |
Authors: | Fraenzi Korner-Nievergelt, Tobias Roth, Stefanie von Felten, Jerome Guelat, Bettina Almasi, Pius Korner-Nievergelt |
Maintainer: | Fraenzi Korner-Nievergelt <[email protected]> |
License: | GPL-2 |
Version: | 1.4 |
Built: | 2025-02-08 03:36:24 UTC |
Source: | https://github.com/fraenzi/blmeco |
Data sets and functions accompagning the book Bayesian data analysis in ecology using linear models with R, BUGS and STAN
Package: | blmeco |
Type: | Package |
Version: | 1.0 |
Date: | 2014-03-03 |
License: | GPL-2 |
See book
Fraenzi Korner-Nievergelt
Maintainer: Please, complain to <[email protected]>
Korner-Nievergelt et al. book
Calculates AIC-weights from a vector of AIC values
AICweights(AIC_values)
AICweights(AIC_values)
AIC_values |
a vector of AIC values of models fitted to the same data set |
a vector of model weights
The function uses the function AICc from the package MuMIn.
F. Korner
Burnham, KP and Anderson DR (2002) Model selection and multimodel inference, a practical information-theoretic approach. Springer, New York
AICweights(c(325, 322, 330))
AICweights(c(325, 322, 330))
The data contains presence-absence data of Little owls in nest boxes and elevation
data(anoctua)
data(anoctua)
A data frame with 361 observations on the following 3 variables.
Id
nest box id
PA
indicator of Little owl presence
elevation
elevation (meters above sea level)
Gottschalk, T, Ekschmitt, K., Volters, V. (2011) Efficient placement of nest boxes for the little owl (Athene noctua). The Journal of Raptor Research 45: 1-14
data(anoctua)
data(anoctua)
The data set contains number of nestlings in Blackstork (Ciconia nigra) nests.
data(blackstork)
data(blackstork)
A data frame with 1130 observations on the following 3 variables.
nest
number of nest (nest id)
year
year
njuvs
number of nestlings
The data is property of Maris Stradz. Attention, this is a non-random subselection of the data available. Please, contact Maris Stradz, if you have interest in the whole data set. [email protected]
data(blackstork)
data(blackstork)
The function produces 9 QQ-Plots. One is for the residuals of a model. 8 of them are for a simulated sample of equal size as the first one but simulated from a normal distribution using rnorm. The QQ-plot for the residuals is placed at a random place within the 9 plots. If you immediately can find the QQ-Plot of the residuals, these may not be normally distributed. The place of residuals is printed to the R-console.
compareqqnorm(mod)
compareqqnorm(mod)
mod |
a linear model (an lm-object or any other object of which resid(mod) gives a numeric vector of numbers) |
a plot is produced and a number if given which indicates the position of the residuals (1-3 corresponds to the first row, 4-6 to the second row and 7-9 to the third row)
F. Korner
y <- rexp(50) mod <- lm(y~1) compareqqnorm(mod)
y <- rexp(50) mod <- lm(y~1) compareqqnorm(mod)
The aim of the study was to look at the corticosterone increase due to the corticosterone implants. In each brood one or two nestlings were implanted with a corticosterone-implant and one or two nestlings with a placebo-implant (variable Implant). Blood samples were taken just before implantation (day 1), 2 and 20 days after implantation. In total we have 287 measurements of 151 individuals (variable Ring) of 54 broods.
data(cortbowl)
data(cortbowl)
A data frame with 287 observations on the following 6 variables.
Brood
id of brood
Ring
id of individual
Implant
a factor with levels C
P
; treatment: C=corticosterone treatment, P=placebo
Age
age of nestling in days
days
the day of the blood sample
totCort
corticosterole measurement in the blood sample
Almasi, B., Roulin, A., Jenni-Eiermann, S., Breuner, C.W., Jenni, L., 2009. Regulation of free corticosterone and CBG capacity under different environmental conditions in altricial nestlings. Gen. Comp. Endocr. 164, 117-124.
data(cortbowl)
data(cortbowl)
Calculates the x and y-coordinates of the cross point of two srtaight lines based on their intercepts and slopes
crosspoint(a1, b1, a2, b2)
crosspoint(a1, b1, a2, b2)
a1 |
intercept of first line |
b1 |
slope of first line |
a2 |
intercept of second line |
b2 |
slope of second line |
a two column matrix with x- and y-coordinates of the cross point(s)
F. Korner
crosspoint(4, -0.1, 3, 0.1)
crosspoint(4, -0.1, 3, 0.1)
Computes the square root of the penalized residual sum of squares divided by n, the number of observations. This quantity may be interpreted as the dispersion factor of a binomial and Poisson mixed model. It may be used to correct standard errors of the model coefficients. But note that this post-hoc correction may be misleading because not all standard errors of the same model might need to be corrected by the same factor if the extra variance is explicitly included in the model structure (see e.g. Barry et al. 2003).
dispersion_glmer(modelglmer)
dispersion_glmer(modelglmer)
modelglmer |
a model that has been fitted by glmer |
the square root of the scale parameter, according to recommendations by D. Bates, if its value is between 0.75 and 1.4, there may not be an overdispersion problem.
Such one number diagnostics should not be used as the only decision criterion. It can indicate overdispersion, but if it does not, it does not mean that the model fits the data well. Thorough residual analyses or posterior predictive model checking is still needed!
she or he is unfortunately unknown to us
This function has been posted on the R-helplist. It seems to have been written or motivated by D. Bates. Here is the URL, where we downloaded the function: https://stat.ethz.ch/pipermail/r-sig-mixed-models/2011q1/015392.html
Barry SC, Brooks SP, Catchpole EA, Morgan BJT (2003) The analysis of ring-recovery data using random effects. Biometrics 59:54-65.
## Not run: data(swallowfarms) dat <- swallowfarms dat$colsize.z <- scale(dat$colsize) # scaled values for better model convergence dat$dung.z <- scale(dat$dung) dat$die <- dat$clutch - dat$fledge mod <- glmer(cbind(fledge,die) ~ colsize.z + cow + dung.z + (1|farm) , data=dat, family="binomial") dispersion_glmer(mod) ## End(Not run)
## Not run: data(swallowfarms) dat <- swallowfarms dat$colsize.z <- scale(dat$colsize) # scaled values for better model convergence dat$dung.z <- scale(dat$dung) dat$die <- dat$clutch - dat$fledge mod <- glmer(cbind(fledge,die) ~ colsize.z + cow + dung.z + (1|farm) , data=dat, family="binomial") dispersion_glmer(mod) ## End(Not run)
Heinz Ellenberg's historically important work on changes in the abundances of a community of grass species growing along experimental gradients of water table depth has played an important role in helping to identify the hydrological niches of plant species in wet meadows. The dataset comprises measurements taken from two similar experiments conducted in 1952 and 1953.
data(ellenberg)
data(ellenberg)
A data frame with 264 observations on the following 29 variables.
Year
two levels: 1952 and 1953
Soil
two levels: Loam and Sand
Water
Average distance to groundwater in cm, 10 levels for 1952, 11 levels for 1953: (-5), 5, 20, 35, 50, 65, 80, 95, 110, 125, 140
Species
6 species in 1952 and 4 species in 1953. Species 1952: Poa palustris, Festuca pratensis, Alopecurus pratensis, Dactylis glomerata, Arrhenatherum elatius, Bromus erectus. Species 1953: Alopecurus pratensis, Dactylis glomerata, Arrhenatherum elatius, Bromus erectus.
Mi.g
Individual yield of dried biomass in g in monocultures
Yi.g
Individual yield of dried biomass in g in mixtures
Mono.area.m2
Area of the yields in monocultures, 0.383 m in year 1952, 0.5 m in year 1953
Mix.area.m2
Area of the yields in mixtures, 1.2 m in year 1952, 1.5 m in year 1953
Div
Species richness, 6 in year 1952, 4 in year 1953
Moi.g.m2
Individual monoculture yields in m2
Yoi.g.m2
Individual mixture yields in m2
Mo.g.m2
Moi.g.m2 averaged over species by year, soil type and water level
Yo.g.m2
Yoi.g.m2 summed over species by year, soil type and water level
RYoi
Individual relative yield observed (Yoi.g.m2/ Moi.g.m2)
RYo
RYoi summed over species by year, soil type and water level
Yei.g.m2
Individual expected yield in m2 (Moi.g.m2 * RYe)
Ye.g.m2
Yei.g.m2 summed over species by year, soil type and water level
RRYo
Rescaled relative yield observed (RYoi/RYo)
deltaRYoi
Difference between relative observed yield and rescaled relative observed yield (RYoi - RRYo)
deltaRYo
deltaRYoi summed over species by year, soil type and water level
RYe
Relative yield expected in mixtures (1/Div)
deltaRYe
Difference between the rescaled relative yield observed and relative yield expected (RRYo- RYe)
RYT
Relative yield total summed over species by year, soil type and water level
level
two levels: species and community
NE
Net Effect (Yo.g.m2 - Ye.g.m2)
TICE
Trait-Independent Complementarity Effect (Mo.g.m2 * deltaRYo * Div)
SE
Selection Effect (NE - TICE)
TDCE
Trait-Dependent Complementarity Effect ((Moi.g.m2 - Mo.g.m2) * (deltaRYoi - deltaRYo) summed over species by year, soil type and water level)
DE
Diversity effect (SE - TDCE)
A detailed description of the data set can be found in the methods section of Hector et al. (2012).
http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0043358
Ellenberg H (1953) Physiologisches und oekologisches Verhalten derselben Pflanzenarten. Berichte der Deutschen Botanischen Gesellschaft 65: 350-361
Ellenberg H (1954) Ueber einige Fortschritte der kausalen Vegetationskunde. Plant Ecology 5/6: 199-211.
Lieth H, Ellenberg H (1958) Konkurrenz und Zuwanderung von Wiesenpflanzen. Ein Beitrag zum Problem der Entwicklung neu angelegten Gruenlands. Zeitschrift fuer Acker- und Pflanzenbau 106: 205-223.
Hector A, von Felten S, Hautier Y, Weilenmann M and Bruelheide H (2012) Effects of Dominance and Diversity on Productivity along Ellenberg's Experimental Water Table Gradients. PlosOne 7: e43358
data(ellenberg)
data(ellenberg)
Counts of the number of frogs in ponds of the Canton Aargau, Switzerland.
data(frogs)
data(frogs)
A data frame with 481 observations on the following 10 variables.
count1
number of counted frogs during the first visit
count2
number of counted frogs uring the second visit
elevation
elevation, meters above sea level
year
year
fish
presence of fish (1 = present, 0 = absent)
waterarea
area of the water body in square meters
vegetation
indicator of vegetation (1 = vegetation present, 0 = no vegetation present)
pondid
name of the pond, corresponds to observation id
x
x coordinate
y
y coordinate
The amphibian monitoring program started in 1999 and is mainly aimed to survey population trends of endangered amphibian species. Every year, about 30 water bodies in two or three randomly selected priority areas (out of ten priority areas of high amphibian diversity) are surveyed. Additionally, a random selection of water bodies that potentially are suitable for one of the endangered amphibian species but that do not belong to the priority areas were surveyed. Each water body is surveyed by single trained volunteer during two nocturnal visits per year. Volunteers recorded anurans by walking along the waters edge with precise rules for the duration of a survey taking account of the size of the surveyed water body and noting visual encounters and calls. As fare as possible, encountered individuals of the Pelophylax-complex were identified as Marsh Frog (Pelophylax ridibundus), Pool Frog (P. lessonaea) or hybrids (P. esculentus) based on morphological characteristics or based on their calls. In the given data set, however, these three taxa are lumped together.
The data is provided by Isabelle Floess, Landschaft und Gewaesser, Kanton Aargau.
Schmidt, B. R., 2005: Monitoring the distribution of pond-breeding amphibians, when species are detected imperfectly. - Aquatic conservation: marine and freshwater ecosystems 15: 681-692.
Tanadini, L. G.; Schmidt, B. R., 2011: Population size influences amphibian detection probability: implications for biodiversity monitoring programs. - Plos One 6: e28244.
data(frogs)
data(frogs)
Draws history (trace) plots for the Markov chains in a STAN- or WinBUGS-object
historyplot(fit, parameter)
historyplot(fit, parameter)
fit |
a model fit obtained by STAN or WinBUGS |
parameter |
the name, a character, of the parameter for which the history plot should be drawn |
can only handly one or two dimensional parameters up to now.
gives a plot
Fraenzi Korner
## Not run: fit <- stan(....) historyplot(fit, parameter="alpha") ## End(Not run)
## Not run: fit <- stan(....) historyplot(fit, parameter="alpha") ## End(Not run)
Bayesian leave-one-out cross-validation based on the log pointwise predictive density
loo.cv(mod, nsim = 100, bias.corr = FALSE)
loo.cv(mod, nsim = 100, bias.corr = FALSE)
mod |
an object obtained by the functions lm or glm |
nsim |
number of Monte Carlo simulations used to describe the posterior distributions. Computing time is large! |
bias.corr |
The leave-one-out cross-validation underestimates predictive fit because each prediction is conditioned n-1 data points. For large n this bias is negligible. For small n, a bias correction is recommended. |
For details see Gelman et al. (2014) p 175
LOO.CV |
leave-one-out cross-validation estimate of out-of-sample predictive fit, (log pointwise predictive density) |
bias.corrected.LOO.CV |
bias corrected leave-one-out cross-validation estimate of out-of-sample predictive fit, (log pointwise predictive density) |
minus2times_lppd |
-2*LOO.CV, transformed LOO.CV to scale of deviance |
est.peff |
estimate for the number of effective parameters |
F. Korner
Gelman A, Carlin JB, Stern HS, Dunson DB, Vehtari A and Rubin DB (2014) Bayesian Data Analysis, Third edn. CRC Press.
## Not run: x <- runif(20) y <- 2+0.5*x+rnorm(20, 0, 1) mod <- lm(y~x) loo.cv(mod, bias.corr=TRUE) # increase nsim!! ## End(Not run)
## Not run: x <- runif(20) y <- 2+0.5*x+rnorm(20, 0, 1) mod <- lm(y~x) loo.cv(mod, bias.corr=TRUE) # increase nsim!! ## End(Not run)
Simulated set of correlated variables. The code for the simulation is given in the details section.
data("mdat")
data("mdat")
A data frame with 100 observations on the following 6 variables.
y
a numeric vector
x1
a numeric vector
x2
a numeric vector
x3
a numeric vector
x4
a numeric vector
x5
a numeric vector
# data simulation library(MASS) Sigma <- matrix(c(1, -0.5, -0.8, -0.5, -0.9, -0.5, 1, 0.5, 0.3, 0.5, -0.8, 0.5, 1, 0.2, 0.5, -0.5, 0.3, 0.2, 1, 0.5, -0.9, 0.5, 0.5, 0.5, 1), ncol=5, byrow=TRUE) set.seed(242) X <-mvrnorm(n = 100, mu=runif(5, -1,1), Sigma=Sigma)
b_true <- c(3, 1.3, -0.5, 0.9, -1.3, 0.4) y_hat <- cbind(1, X) y <- y_hat + rnorm(100) dat <- data.frame(y=y, x1=X[,1], x2=X[,2], x3=X[,3], x4=X[,4], x5=X[,5]) # end of data simulation —————————————————————
data(mdat)
data(mdat)
Territory occupancy data indicating whether a Nightingale (Luscinia megarhynchos) was observed (1; 0 otherwise) in a given territory, year and during a given visit.
data(nightingales)
data(nightingales)
Three-dimensian array containing 0 (i.e. not observed) and 1 (observed) with the three dimensions referring to
1st dimension
the 1:55 territories
2nd dimension
the 1:10 study years
3rd dimension
the 1:8 visits
The data is provided by PD Dr. Valentin Amrhein.
Roth T; Amrhein V (2010) Estimating individual survival using territory occupancy data on unmarked animals. Journal of Applied Ecology 47: 386-392.
data(nightingales)
data(nightingales)
Sum of squared differences between the out-of-data prediction and the observation for the leave-one-out cross validation for linear models with normal error structure (lm-objects)
ocv(mod)
ocv(mod)
mod |
an lm-object |
the ordinary cross validation score
F. Korner
e.g. Wood, SN (2006) Generalized Additive Models, An Introduction with R. Chapman & Hall/CRC, London.
data(pondfrog1) mod1 <- lm(log(frog+1)~ph, data=pondfrog1) mod2 <- lm(log(frog+1)~waterdepth, data=pondfrog1) ocv(mod1) ocv(mod2)
data(pondfrog1) mod1 <- lm(log(frog+1)~ph, data=pondfrog1) mod2 <- lm(log(frog+1)~waterdepth, data=pondfrog1) ocv(mod1) ocv(mod2)
Counts of Great tits (Parus major) observed at the mountain pass Ulmethoechi (BL, Switzerland) between 1982 and 2007 during fall migration.
data(parusmajor)
data(parusmajor)
A data frame with 434 observations on the following 3 variables.
year
year
julian
day of the year
count
number of individuals counted
Korner-Nievergelt F, Korner-Nievergelt P, Baader E, Fischer L, Schaffner W, Kestenholz M (2007) Jahres- und tageszeitliches Auftreten von Singvoegeln auf dem Herbstzug im Jura (Ulmethoechi, Kanton Basel-Landschaft). Der Ornithologische Beobachter 104: 101-130.
data(parusmajor)
data(parusmajor)
The data is part of the study by Korner-Nievergelt & Leisler (2004) Morphological convergence in conifer-dwelling passerines. Journal of Ornithology 145: 245-255.
data(periparusater)
data(periparusater)
A data frame with 28 observations on the following 6 variables.
country
country of origin of the individual
age
numeric code for age categories as defined by www.euring.org, 3 = hatching year, 4 = not hatching year, 5 = after hatching year, 0 = missing
sex
numeric code for sex as defined by www.euring.org, 1 = male, 2 = female, 0 = missing
weight
body mass in g
P8
length of primary 8 in mm. Primary 8 is the third outermost wing feather often building the wing tip.
wing
wing length in mm
Korner-Nievergelt & Leisler (2004) Morphological convergence in conifer-dwelling passerines. Journal of Ornithology 145: 245-255.
data(periparusater)
data(periparusater)
The data contain frog population sizes in different ponds with some characteristics of ponds. The data is simulated, thus the "true" model is known. The data can serve to play with different methods for doing model selection.
data(pondfrog)
data(pondfrog)
A data frame with 130 observations on the following 9 variables.
frog
a numeric vector
fish
a numeric vector
vegdensity
a numeric vector
ph
a numeric vector
surfacearea
a numeric vector
waterdepth
a numeric vector
region
a factor with levels north
south
height
a numeric vector
temp
a numeric vector
The r-code for producing the pondfrog data is
set.seed(196453) n <- 130 # sample size height <- sample(150:1500,n) region <- sample(c("south", "north"), n, replace=TRUE, prob=c(0.2, 0.8)) waterdepth <- sample(seq(0.3, 5.5, by=0.01), n) surfacearea <- sample(seq(3, 150), n) temp <- 20 - 0.01*height + 0.5*as.numeric(region=="south") -0.005*waterdepth + 0.1*sqrt(surfacearea) +rnorm(n, 0, 1.5) ph <- 7.5 - 0.8 * as.numeric(region=="south") + rnorm(n, 0, 0.2) vegdensity.logitp <- -3.5+0.3*ph + 0.2*temp+rnorm(n,0,1) vegdensity.p <- plogis(vegdensity.logitp) vegdensity <- rbinom(n, 1, prob=vegdensity.p) fish.logitp <- -4+0.3*ph + 0.2*waterdepth+rnorm(n,0,1) fish.p <- plogis(fish.logitp) fish <- rbinom(n, 1, prob=fish.p) frog.mu <- exp(3.5 + 0.2*(temp-mean(temp)) +0.2*(ph-mean(ph)) + 0.1*(ph-mean(ph))^2 - 0.3*(waterdepth-mean(waterdepth)) - 0.5 * fish + 0.5*fish*vegdensity) frog <- rpois(n, lambda=frog.mu)
dat <- data.frame(frog=frog, fish=fish, vegdensity=vegdensity, ph=ph, surfacearea=surfacearea, waterdepth=waterdepth, region=region, height=height, temp=temp)
Thus, the "true" model for the number of pondfrog (frog) is a Poisson model with log-link function and the following linear predictor:
3.5 + 0.2*(temp-mean(temp)) +0.2*(ph-mean(ph)) + 0.1*(ph-mean(ph))^2 - 0.3*(waterdepth-mean(waterdepth)) - 0.5 * fish + 0.5*fish*vegdensity
data(pondfrog) pairs(pondfrog)
data(pondfrog) pairs(pondfrog)
Simulated data of which the true model is known. Can be used to play with model selection. This is a simplified version of the pondfrog -example (see pondfrog)
data(pondfrog1)
data(pondfrog1)
A data frame with 130 observations on the following 4 variables.
frog
a numeric vector
ph
a numeric vector
waterdepth
a numeric vector
temp
a numeric vector
The code used to simulate the data was: set.seed(333) frog.mu <- exp(3.5 + 0.2*(temp-mean(temp))+0.1*(ph-mean(ph)) - 0.3*(waterdepth-mean(waterdepth)) ) frog <- rpois(n, lambda=frog.mu)
For the simulation of the explanatory variables, see help file for the pondfrog data
data(pondfrog1) pairs(pondfrog1)
data(pondfrog1) pairs(pondfrog1)
Counts of Common Redstart (Phoenicurus phoenicurus) breeding pairs between 1993-1996 in a small part of Switzerland.
data(redstart)
data(redstart)
Data frame with 342 observations and the following 5 columns:
counts
count of Common Redstart breeding pairs in each 1 km2 plot
x
x-coordinate in CH1903-LV03 (EPSG: 21781)
y
y-coordinate in CH1903-LV03 (EPSG: 21781)
elevation
average elevation in m.
forests
forest cover
Swiss Breeding Bird Atlas 1993-1996 (Swiss Ornithological Institute): http://www.vogelwarte.ch
Schmid H., Luder R., Naef-Daenzer B., Graf R., Zbinden N. (1998) Schweizer Brutvogelatlas. Verbreitung der Brutvoegel in der Schweiz und im Fuerstentum Liechstenchstein 1993-1996. Schweizerische Vogelwarte, Sempach.
data(redstart)
data(redstart)
Number of tree sprouts that survived a management fire and the time since the last fire.
data(resprouts)
data(resprouts)
A data frame with 41 observations on the following 4 variables.
treatment
time since last fire in months
plot_ID
plot name
pre
number of tree sprouts before the fire
post
number of tree sprouts after the fire, survivors
Walters, G (2012) Customary fire regimes and vegetation structurein Gabon's Bateke Plateaux. Human Ecology 40: 943-955
data(resprouts)
data(resprouts)
Locations of roosting sites of little owls obtained by telemetry data
data(roostingsiteuse)
data(roostingsiteuse)
A data frame with 42 observations on the following 5 variables.
roosting.loc
a factor with 4 levels
roostingnum
roosting site number
temp
ambient temperature in degree celsius
familynum
number of the family
indnum
number of the individual
Bock, A., Naef-Daenzer, B., Keil, H., Korner-Nievergelt, F., Perrig, M., Grueebler, M. U. (2013) Roost site selection by Little Owls Athene noctua in relation to environmental conditions and life history stages. Ibis 155: 847-856.
data(roostingsiteuse)
data(roostingsiteuse)
Data of experiment 1 in Anthes et al. (2014) to measure the depletion rate of sperms in a hermaphrodite sea slug.
data(spermdepletion)
data(spermdepletion)
A data frame with 264 observations on the following 6 variables.
donor
the id of the focal sperm donor
matingN
the number of the mating in the sequences of matings
totalsperm
number of sperms transferred to the receiver
MeanPairSize
mean of the weight of the two slugs of the pair
RelativeDonorSize
a relative size measurement of the donor, see Anthes et al. (2014)
Dec_duration
duration of mating in decimal minutes
Anthes N, Werminghausen J, Lange R (2014) Large donors transfer more sperm, but depletion is faster in a promiscuous hermaphrodite. Behavioural Ecology and Sociobiology 68: 477-483.
data(spermdepletion)
data(spermdepletion)
Capture-histories (obtained by radio-telemetry) of Barn swallows during their first 17 days after fledging. To simplify the example (for didactical reasons), only the first broods were selected.
data(survival_swallows)
data(survival_swallows)
The format is: List of 8 $ CH : int [1:322, 1:18] 1 1 1 1 1 1 1 1 1 1 ... capture histories of 322 individuals $ I : int 322, number of individuals $ K : int 18, capture occations (inclusive the first capture) $ carez : num [1:322], covariate, intensity of care by the parents $ year : num [1:322] index of year (4 years study) $ agec : num [1:18] covariate age of the fledglings, centered $ family: num [1:322] index of the family (group the individuals belong to) $ nfam : num 72, number of families
Day 0 is the day of marking the individuals.
The data has been collected by Martin Grueebler and Beat Naef-Daenzer.
Grueebler, M.U., Naef-Daenzer, B. 2008: Fitness consequences of pre- and post-fledging timing decicions in a double-brooded passerins. Ecology 89:2736-2745.
Grueebler, M.U., Naef-Daenzer, B. 2010: Survival benefits of post-fledging care: experimental approach to a critical part of avian reproductivve strategies. J. Anim. Ecol. 79:334-341.
data(survival_swallows)
data(survival_swallows)
This is an adapted a data set from Grueebler et al. (2010) on Barn Swallow Hirundo rustica nestling survival (we have selected a non-random sample to be able to fit a simple model; hence, the results do not add unbiased knowledge about the swallow biology!). For 63 swallow broods we know the clutch size and the number of the nestlings that fledged. The broods came from 51 farms, thus some farms had more than one brood. There are three predictors measured at the level of the farm: colony size (the number of swallow broods on that farm), cow (whether there are cows on the farm or not), and dungheap (the number of dungheaps within 500 m of the farm).
data(swallowfarms)
data(swallowfarms)
A data frame with 63 observations on the following 6 variables.
farm
farm id
colsize
number of swallow broods on the farm
cow
indicator of cows on the farm
dung
number of dungheaps on the farm
clutch
clutch size
fledge
number of nestlings that survived to fledging
Grueebler MU, Korner-Nievergelt F, von Hirschheydt J (2010) The reproductive benefits of livestock farming in barn swallows Hirundo rustica: quality of nest site or foraging habitat? Journal of Applied Ecology 47:1340-1347
data(swallowfarms)
data(swallowfarms)
Number of barn swallows and house martins nesting per barn with some characteristics of the barn.
data(swallows)
data(swallows)
A data frame with 27 observations on the following 6 variables.
farm
indicator of the farm
nhirrus
number of active barn swallow nests
ndelurb
number of active house martin nests
ncows
number of cows in the barn
nesting_aid
a factor with levels artif_nest
=artificial nests were put up,
both
both artificial nests and supporting material has been provided, none
nothing has been done
to support swallow nesting, support
supporting material has been provided
ndaysempty
number of days the barn was empty, i.e. the cows have been on the meadow.
Willi T, Korner-Nievergelt F, Grueebler MU (2011) Rauchschwalben Hirundo rustica brauchen Nutztiere, Mehlschwalben Delichon urbicum Nisthilfen. Der Ornithologische Beobachter 108: 215-224
data(swallows)
data(swallows)
The function draws a normal prior distribution, the data and the posterior distribution in one plot. It serves as a tool to explore the influence of different prior on a hypotehtical set of normally distributed data
triplot.normal.knownvariance(theta.data, variance.known, n, prior.theta, prior.variance, legend = TRUE, ylim = c(0, max(yposterior)), legend.bty="n")
triplot.normal.knownvariance(theta.data, variance.known, n, prior.theta, prior.variance, legend = TRUE, ylim = c(0, max(yposterior)), legend.bty="n")
theta.data |
mean of the data |
variance.known |
known variance |
n |
sample size |
prior.theta |
mean of the prior distribution |
prior.variance |
variance of the prior distribution |
legend |
logical, if TRUE (default) a legend is drawn |
ylim |
ylim of the plot |
legend.bty |
box type of legend |
Fraenzi Korner-Nievergelt
Gelman, A., J. B. Carlin, H. S. Stern and D. B. Rubin (2004). Bayesian Data Analysis. New York, Chapman & Hall/CRC.
triplot.normal.knownvariance(theta.data=10, n=20, variance.known=5, prior.theta=0, prior.variance=100)
triplot.normal.knownvariance(theta.data=10, n=20, variance.known=5, prior.theta=0, prior.variance=100)
WAIC is a more fully Bayesian approach for estimating the out-of-sample expectation based on the log pointwise posterior predictive density
WAIC(mod, bsim = NA, nsim = 100)
WAIC(mod, bsim = NA, nsim = 100)
mod |
an object of class lm, glm or mer |
bsim |
an object of class simMer (optional), if provided computing time is reduced. |
nsim |
number of simulations used to describe the posterior distributions, if bsim is provided, this number is taken from bsim. |
We implemented the formulas given in Gelman et al. (2014) p 173. We hope that the implementation is correct! For hierarchical (mixed) models, the function gives the WAIC that measures predictive fit for the groups in the data (not for new groups). For hierarchical models the predictive fit could be measured for each level of the data. But this flexibility is not yet implemented in the WAIC function.
lppd |
log pointwise posterior predictive density: the logarithms of the predictive density integrated over the posterior distribution of the model parameters summed over all observations. |
pwaic1 |
an estimate for the number of effective parameters |
pwaic2 |
a second estimate for the number of effective parameters |
WAIC1 |
WAIC based on pwaic1 |
WAIC2 |
WAIC based on pwaic2 |
F. Korner
Gelman, A., Carlin, J.B., Stern, H.S., Dunson, D.B., Vehtari, A. & Rubin, D.B. (2014) Bayesian Data Analysis, Third edn. CRC Press.
Watanabe, S. (2010) Applicable Information Criterion in Singular Learning Theory. Journal of Machine Learning Research, 11, 3571-3594.
data(pondfrog1) mod1 <- glm(frog ~ ph + waterdepth + temp, data=pondfrog1, family=poisson) mod2 <- glm(frog ~ + waterdepth + temp, data=pondfrog1, family=poisson) mod3 <- glm(frog ~ ph + + temp, data=pondfrog1, family=poisson) mod4 <- glm(frog ~ ph + waterdepth , data=pondfrog1, family=poisson) WAIC(mod1) WAIC(mod2) WAIC(mod3) WAIC(mod4)
data(pondfrog1) mod1 <- glm(frog ~ ph + waterdepth + temp, data=pondfrog1, family=poisson) mod2 <- glm(frog ~ + waterdepth + temp, data=pondfrog1, family=poisson) mod3 <- glm(frog ~ ph + + temp, data=pondfrog1, family=poisson) mod4 <- glm(frog ~ ph + waterdepth , data=pondfrog1, family=poisson) WAIC(mod1) WAIC(mod2) WAIC(mod3) WAIC(mod4)
Number of territories of Whitethroat in wildflowerfields of different ages. The data has been collected by J-L Zollinger.
data(wildflowerfields)
data(wildflowerfields)
A data frame with 136 observations on the following 8 variables.
field
field id
year
year
age
age of the wildflower field in years
bp
number of territories of whitethroats Sylvia communis
X
x-coordinate
Y
y-coordinate
size
area of the field in ares (a, 10 x 10 m)
Nspec
number of species
Zollinger J-L, Birrer S, Zbinden N, Korner-Nievergelt F (2013) The optimal age of sown field margins for breeding farmland birds. Ibis 155: 779-791
data(wildflowerfields)
data(wildflowerfields)
The data contains wing length measurements of Barn owl nestlings that were either treated with a corticosterone or a placebo implant.
data(wingbowl)
data(wingbowl)
A data frame with 209 observations on the following 7 variables.
Brood
brood id
Ring
individual id
Age1
age of the individual at the day it received the implant, in days
Implant
type of implant: C = corticosterone, P = placebo
days
number of days after the implant
Age
age of the nestling at the day of the wing length measurement, in days
Wing
wing length measurement in mm
AlmaisB, Roulin A, Korner-Nievergelt F, Jenni-Eiermann S, Jenni L (2012) Coloration signals the ability to cope with elevated stress hormones: effects of corticosterone on growth of barn owls are associated with melanism. JOurnal of Evolutionary Biology 25: 1189-1199
data(wingbowl)
data(wingbowl)
Site-occupancy data indicating whether Yellow-bellied toads (Bombina variegata) were observed (1; 0 otherwise) in a given site and during a given visit.
data(yellow_bellied_toad)
data(yellow_bellied_toad)
List with 2 items
y
Two-dimensional matrix with the observed absence (0) or presence (1) of Yellow-bellied toads for a given territory (rows) and visit (columns).
DAY
integer vector containing the day of the year for each observation.
The data is provided by Isabelle Floess, Landschaft und Gewaesser, Kanton Aargau.
data(yellow_bellied_toad)
data(yellow_bellied_toad)