Hierarchical Modelling of Species Communities (HMSC) is a model-based approach for analyzing community ecological data (Ovaskainen et a.2017a).

The obligatory data for HMSC-analyses includes a matrix of species occurrences or abundances and a matrix of environmental covariates. Additional and optional data include information about species traits and phylogenetic relationships, and information about the spatiotemporal context of the sampling design. HMSC partitions variation in species occurrences to components that relate to environmental filtering, species interactions, and random processes. HMSC yields inference both at species and community levels. It can be used to generate simulated communities under given environmental conditions, and thus its predictions can be compared to independent validation data, and it can be used for scenario simulations.


The current version of the R-package Hmsc is found on CRAN. For a description of the software, see

The development version is found on Github.

The old matlab and R versions of HMSC can be found here.

HMSC book

The first copies of the book now exist, fresh from the printing press!

The official publication date (for both the printed book and the ebook) for the UK and Europe has been set as 11th June 2020. Further global publication dates will depend on shipping schedules and will be available on

Click here to order from the publisher's site - use offer code JSDM2020 to get 20% off.

Executable scripts

As supporting information to the book, we provide here R-scripts and data files for the three real data examples of the book: the plant example of Section 6.7, the fungal example of Section 7.9, and the bird example of Section 11.1. The scripts were originally developed by Otso Ovaskainen and Nerea Abrego, and Jari Oksanen has made further improvements to them.

HMSC course 2022



Teachers: Otso Ovaskainen, Gleb Tikhonov, Jari Oksanen, Ryan Burner, Jenni Niku, Mirkka Jones and Sara Taskinen.


NB: THE SATURDAY 6 AM SESSION IS CANCELLED. Please send any outstanding questions via email.

The course is organized in the hybrid mode: physically at Jyväskylä University, and remotely through zoom.

The zoom link to all sessions is the same:

All plenary sessions will be recorded and made available on YouTube asap after the session:

All course material (R-scripts and datafiles) are placed in the section “Course materials downloads” below

The recommended version of the R-package Hmsc to be used during the course is the version available at CRAN at the beginning of the course. Thus, you are recommended to update your Hmsc package just before starting the computer exercises.

The daily schedule is the same for all days (all times are given in Finnish time which is EEST = Eastern European Summer Time; currently UTC + 3):

9am – 2pm (including lunch break at 12-13): Plenary sessions (lectures and R-demonstrations). Both physical (Agora building Ag B103 = Auditorium 3) and on Zoom.

2pm – 4pm: Alternative 1 for computer exercises. Both physical (Ag B112.1 for those without laptop and Ag C231.1 for those with laptop) and on Zoom. In the zoom session, there will be multiple teachers. In the main zoom room (which you enter by clicking the zoom link above), you can ask for help with the computer exercise by asking questions either via the chat or by raising your hand and opening your microphone when the teacher indicates that it is your turn to ask a question. Questions that do not relate to the given exercise will be answered in separate break-out rooms to which you can move from the main zoom room. The teacher will let you know in which break-out room your question will be discussed.

7pm – 9pm (11am – 1pm US Central time): Alternative 2 for computer exercises (targeted especially for American time zones). Zoom only, with one teacher available to answer questions.

10pm – 12pm (2pm – 4pm US Central time): Alternative 3 for computer exercises (targeted especially for American time zones). Zoom only, with one teacher available to answer questions.

the next morning 6am – 8am (1pm – 3pm Sydney time): Alternative 4 for computer exercises (targeted especially for Australian time zones). Zoom only, with one teacher available to answer questions. NB: CANCELLED SATURDAY

By default, you are expected join only one of these three break-out groups daily. You don’t need to register beforehand, just join the session that fits you the best. However, you are welcome to visit a second group if you have any further questions after your initial session has ended.



Monday 15th August 2022

Plenary sessions

  • Lecture (by Otso Ovaskainen). Welcome & introduction to the course.
  • Lecture (by Otso Ovaskainen). Overview of HMSC.
  • Introduction to case studied used in this course: plants, birds, fungi, and phenology.
  • R demonstration (by Otso Ovaskainen). What is the Hmsc pipeline and how to apply it? Setting up a model, fitting it, and producing standard output.
  • Lecture (by Otso Ovaskainen). Introduction to the case study to be used in the break-out groups.

Break-out groups

Exercise 1. Apply the Hmsc pipeline to the provided case study data. Define a simplified Hmsc model (no traits, no phylogeny, no random effects), and follow the Hmsc pipeline to generate basic output on parameter estimates. Participants are encouraged to work independently, the teacher is there mainly to help if questions arise.

Tuesday 16th August 2022

Plenary sessions

  • R demonstration (by Otso Ovaskainen). Recap of Exercise 1.
  • Lecture (by Otso Ovaskainen). The fixed and random effect components of HMSC and their links to ecological theory.
  • Lecture (by Sara Taskinen): Using variational approximation for fast estimation of joint species distribution models with various response distributions (note: this lecture is not related to HMSC but to joint species distribution modelling more generally).

Break-out groups

Exercise 2. Continue from Exercise 1 by defining a full HMSC model (with traits, phylogeny, and random effects) and apply the Hmsc pipeline to produce some basic model outputs.

Wednesday 17th August 2022

Plenary sessions

  • R demonstration (by Otso Ovaskainen). Recap of Exercise 2.
  • R demonstration (by Otso Ovaskainen). Measuring explanatory and predictive power by different cross-validation strategies.
  • R demonstration (by Otso Ovaskainen). Making predictions over environmental gradients.
  • R demonstration (by Otso Ovaskainen). Checking MCMC convergence and examining model fit.
  • Lecture (by Gleb Tikhonov). How is Hmsc fitted to data? Overview on prior distributions and posterior sampling.
  • R demonstration (by Gleb Tikhonov). How to modify the prior distributions and make choices related to posterior sampling.

Break-out groups

Exercise 3. Continue from Exercise 2 by checking MCMC convergence, examining model fit, and making predictions over environmental gradients.

Thursday 18th August 2022

Plenary sessions

  • R demonstration (by Otso Ovaskainen). Recap of Exercise 3.
  • R demonstration (by Otso Ovaskainen). How to set up different types of random levels in Hmsc: hierarchical, spatial and temporal.
  • R demonstration (by Otso Ovaskainen). Setting up different response distributions.
  • R demonstration (by Otso Ovaskainen). Making predictions over spatial gradients.
  • Lecture and R demonstration (by Otso Ovaskainen). Variable selection, reduced rank regression, and other methods to deal with cases with many potential covariates.

Break-out groups

  • Exercise 4. Continue from Exercise 3 by trying out different models and selecting among them.

Friday 19th August 2022

Plenary sessions

  • R demonstration (by Otso Ovaskainen). Recap of Exercise 4.
  • Discussion session (lead by Otso Ovaskainen, Gleb Tikhonov and Jari Oksanen). Recent and future development needs of HMSC: Overview of recently implemented and ongoing developments, and discussion on what users would like to see implemented.
  • Discussion session. Based, e.g., on questions that came up during lectures and/or break-out groups that could not have been addressed there.

Break-out groups

In the break-out groups, discussions on topics suggested by the participants, including guidance on working with their own data.


6 pm. Workshop dinner for participants physically present in Jyväskylä


Course materials downloads:

Lecture 1: Welcome (pdf)

Lecture 2: Overview of HMSC (pdf)

Lecture 3: Fixed and random effects (pdf, updated Aug 16)

Lecture 4: Fast ML based estimation of JSDMs (pdf)

Lecture 5: How is HMSC fitted to data? (pdf)

Lecture 6: Model selection (pdf)

Lecture 7: Ongoing developments (pdf)

Hmsc development (pdf)

Introduction to case studies (pdf)

How to apply the Hmsc pipeline (pdf)

Hmsc pipeline (zipped folder via Dropbox)

Case study: Plants (zipped folder via Dropbox, updated Aug 16)

Case study: Birds (zipped folder via Dropbox, updated Aug 22)

Case study: Fungi (zipped folder via Dropbox)

Case study: Phenology (zipped folder via Dropbox)

Case study: Exercises (zipped folder via Dropbox, updated Aug 22)


Past HMSC courses

see this page


Core papers about HMSC

Ovaskainen, O., Tikhonov, G., Norberg, A., Blanchet, F. G., Duan, L., Dunson, D., Roslin, T. and Abrego, N. 2017a. How to make more out of community data? A conceptual framework and its implementation as models and software. Ecology Letters 20, 561-576.

Ovaskainen, O., Tikhonov, G., Dunson, D., Grøtan, V., Engen, S., Sæther, B.-E. and Abrego, N. 2017b. How are species interactions structured in species rich communities? A new method for analysing time-series data. Proceedings of the Royal Society B: Biological Sciences, 284, 20170768.

Tikhonov, G., Abrego, N., Dunson, D. and Ovaskainen, O. 2017. Using joint species distribution models for evaluating how species-to-species associations depend on the environmental context. Methods in Ecology and Evolution 8, 443-452.

Tikhonov, G., Opedal, Ø. H., Abrego, N., Lehikoinen, A., de Jonge, M. M., Oksanen, J. and Ovaskainen, O. 2020a. Joint species distribution modelling with the R-package Hmsc. Methods in Ecology and Evolution, in early view,

Tikhonov, G., Duan, L., Abrego, N., Newell, G., White, M., Dunson, D. and Ovaskainen, O. 2020b. Computationally efficient joint species distribution modelling of big spatial data. Ecology, e02929.

Ovaskainen, O. and Abrego, N. 2020. Joint Species Distribution Modelling – With Applications in R. Cambridge University Press, in press.

Abrego, N., Norberg, A. and Ovaskainen, O. 2017. Measuring and predicting the influence of traits on the assembly processes of wood-inhabiting fungi. Journal of Ecology 105, 1070-1081.

Ovaskainen, O., Roy, D., Fox, R. and Anderson, B. 2016. Uncovering hidden spatial structure in species communities with spatially explicit joint species distribution models. Methods in Ecology and Evolution 7, 428-436.

Ovaskainen, O., Abrego, N., Halme, P. and Dunson, D. 2016. Using latent variable models to identify large networks of species-to-species associations at different spatial scales. Methods in Ecology and Evolution 7, 549-555.

A review of joint species distribution modelling:

Warton, D., Blanchet, G., O’Hara, R., Ovaskainen, O., Taskinen, S., Walker, S. and Hui, F. K. C. 2015. So many variables: joint modelling in community ecology. Trends in Ecology and Evolution 30, 766-779.

How HMSC results link to the underlying community assembly processes:

Ovaskainen, O., Rybicki, J. and Abrego, N. 2019. What can observational data reveal about metacommunity processes? Ecography 42, 1877-1886.

The predictive performance of HMSC in comparison to other SDM methods:

Norberg, A., Abrego, N., Blanchet, F. G., Adler, F., Anderson, B., Anttila, J., Araújo, M., Dallas, T., Dunson, D., Elith, J., Foster, S., Fox, R., Franklin, J., Godsoe, W., Guisan, A., O'Hara, B., Hill, N., Holt, R. D., Hui, F., Husby, M., Kålås, J., Lehikoinen, A., Luoto, M., Mod, H., Newell, G., Renner, I., Roslin, T., Soininen, J., Thuiller, W., Vanhatalo, J., Warton, D., White, M., Zimmermann, N., Gravel, D. and Ovaskainen, O. 2019. A comprehensive evaluation of predictive performance of 33 species distribution models at species and community levels. Ecological Monographs 89, e01370.

Some empirically oriented papers applying HMSC:

Norberg, A., Halme, P., Kotiaho, J. S., Toivanen, T. and Ovaskainen, O. 2019. Experimentally induced community assembly of polypores reveals the importance of both environmental filtering and assembly history. Fungal Ecology 41, 137-146.

Minard, G., Tikhonov, G., Ovaskainen, O. and Saastamoinen, M. 2019. The microbiome of the Melitaea cinxia butterfly shows marked variation but is only little explained by the traits of the butterfly or its hostplant. Environmental Microbiology 21, 4253-4269.

Rocha, R., Ovaskainen, O., López-Baucells, A., Farneda, F. Z., Sampaio, E. M., Bobrowiec, P.E.D, Cabeza, M., Palmeirim, J. M. and Meyer, C. F. J. 2018. Secondary forest regeneration benefits old-growth specialist bats in a fragmented tropical landscape. Scientific Reports 8, 3819.

Häkkilä, M., Abrego, N., Ovaskainen, O. and Mönkkönen, M. 2018. Habitat quality is more important than matrix quality for bird communities in protected areas. Ecology and Evolution 8, 4019-4030.

Lammel, D. R., Barth, G., Ovaskainen, O., Cruz, L. M., Zanatta, J. A., Ryo, M., Souza, E. M. and Pedrosa, F. O. 2018. Direct and indirect effects of a pH gradient bring insights into the mechanisms driving prokaryotic community structures. Microbiome 6, 106.

Abrego, N., Dunson, D., Halme, P., Salcedo, I. and Ovaskainen, O. 2017. Wood-inhabiting fungi with tight associations with other species have declined as a response to forest management. Oikos 126, 269-275.

Rocha, R., Ovaskainen, O., López-Baucells, A., Farneda, F. Z., Ferreira, D. F., Bobrowiec, P.E.D, Cabeza, M., Palmeirim, J. M. and Meyer, C. F. J. 2017. Design matters: an evaluation of the impact of small man-made forest clearings on tropical bats using a before-after-control-impact design. Forest Ecology and Management 401, 8-16.