| age | R Documentation |
Age distributions for 57 communes in Upper Austria (Oberoesterreich), separated by sex. Each observation represents the age distribution of either the male or female population in a commune, given as proportions across 19 five-year age groups.
age
A list with three components:
A data frame with 114 rows (57 communes x 2 sexes) and 22 columns:
Character. Four-digit commune code.
Character. Name of the municipality (e.g., "Linz", "Steyr"). German umlauts have been transliterated to ASCII (ue, oe, ae, ss).
Factor with levels "male" and "female".
Numeric. Proportions for each age group. Column names indicate the midpoint of the 5-year age interval (e.g., AGE_2 = ages 0-4, AGE_7 = ages 5-9, ..., AGE_92 = ages 90+).
Numeric vector of length 19. The midpoint ages: 2, 7, 12, ..., 92.
A 114 x 19 matrix of age proportions. Row names are formatted as "municipality_sex" (e.g., "Linz_male"). Each row sums to 1.
The data originates from the Austrian Register Census 2021 (Registerzaehlung 2021), which provides population counts by gender, age, and citizenship at the municipality level. The original counts have been converted to proportions (probability distributions) for distributional data analysis.
This dataset is useful for demonstrating PCA on distributional data, as it contains real-world probability distributions that vary in shape (e.g., rural vs urban communes have different age structures).
Creative Commons Attribution 4.0 International (CC BY 4.0). https://creativecommons.org/licenses/by/4.0/
Municipality names have been transliterated from German to ASCII for cross-platform compatibility, following the convention ae / oe / ue / ss for the umlauts and sharp-s (so e.g. the German "Altmuenster" and "Schoenegg" are stored with ue / oe). For an unambiguous key independent of spelling, use the four-digit codes in the 'commune' column.
Data from the Austrian Register Census 2021 (Registerzaehlung 2021), provided by the State of Upper Austria (Land Oberoesterreich) via the Open Data Portal Austria.
Land Oberoesterreich (2021). Bevoelkerung nach Geschlecht und Alter. Open Data Oesterreich. Old broken link: https://www.data.gv.at/katalog/dataset/land-ooe_bevolkerung-geschlecht-und-alter Current dataset: https://www.data.gv.at/katalog/datasets/cd33f19a-7bcc-4454-987c-9f2d76542872
data("age")
# Examine the structure
str(age)
head(age$data)
# The age midpoints
age$ages
# Plot a few age distributions
matplot(age$ages, t(age$distributions[1:6, ]), type = "l",
xlab = "Age", ylab = "Proportion",
main = "Age distributions for first 6 observations")
# Convert to BData for distributional analysis
# First, create a basis for age distributions (support 0-100)
rmAge <- ReferenceMeasureUniform(0, 100)
B2Age <- BayesSpace(rmAge)
basisAge <- BayesSpaceBasis(B2Age, nbasis = 7)
# Create histograms from the proportional data
breaks <- c(5*(0:18), 100)
ageHist <- BDataDensityHistograms(
age$distributions, breaks = breaks, basis = basisAge
)
# Convert to splines: histograms -> densities -> splines
ageDensities <- as.BDataDensities(ageHist)
ageSplines <- as.BDataSplines(ageDensities)
pcaAge <- princomp(ageSplines)
summary(pcaAge)
# Visualize PCA results
plot(pcaAge, type = "screeplot")
plot(pcaAge, type = "scores")
# Score plot with municipality labels
plot(pcaAge, type = "scores", labels = age$data$municipality, cex = 0.6)
# Color by sex
sexColors <- ifelse(age$data$sex == "male", "blue", "red")
plot(pcaAge, type = "scores", col = sexColors)
legend("topright", c("Male", "Female"), col = c("blue", "red"), pch = 19)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.