# How to combine response data of different types for modelling fruit crop size?

Some context first:

For a section of my research project I am investigating how environment (soil, climate) influence the number of fruit (crop size) produced by individual trees of the same species at different sites. I have sampled 10 trees at each site.

My model would look something like this:

Crop size ~ temperature + rainfall + soil N + soil P + (1|Site) + (1|Tree)

My problem:

My crop size data consists of counts of fallen fruit (within a fixed area under each tree), and a qualitative score (0-3) for the amount of fruit that were in the canopy of each tree. I visited these sites mid-way through the season and so there were still fruit that had not yet fallen.

My problem is that I can see no way to combine these variables together to make a single response for crop size. I checked whether they are correlated, and therefore would be able to drop one of them but unfortunately they are not.

You will have to look at more details to decide if this is appropriate (e.g. sample size), but one modelling framework that allows multiple (inter)dependent variables is structural equation modelling (SEM). In such a framework you could account for the covariance between fallen fruit and canopy fruit. You could also have 'crop size data' as a latent variable represented by a function (e.g. linear combination) of canopy fruit and fallen fruit.

If you'd like to know more about SEM, here is a short introduction:

Here is a toy example. Naturally you will have to decide the correct specification of your model, but this toy example shows two different ways of tackling shared variance: latent variables or covariance. I don't necessary recommend both at once, but it gives you the rough idea. In this example we are positing that there exists an unmeasured variable 'crop size' that is indirectly measured by the number of fruit on the ground ('ground fruit': count) and the fruit still in the tree ('canopy_fruit': ordinal). The crop size is also thought to be predicted by rainfall, the site indicator, the soil phosphorus, the temperature, and the tree indicator.

The code for the above diagram was made with SemoPy, a Python package for structural equation modelling.

Installation: pip install semopy

Here is the source for the diagram.

from semopy import Model, semplot

desc = '''
DEFINE(ordinal) canopy_fruit
crop_size =~ fallen_fruit + canopy_fruit
crop_size ~ temperature + rainfall + soilP + site + tree
fallen_fruit ~~ canopy_fruit
'''

model = Model(desc)
semplot(model, 'test.png', plot_covs=True)


SemoPy Documentation: https://semopy.com/

Paper 1: https://arxiv.org/abs/1905.09376

For an example with the R programming language, consider Lavaan:

desc = '''
crop_size =~ fallen_fruit + canopy_fruit
crop_size ~ temperature + rainfall + soilP + site + tree
fallen_fruit ~~ canopy_fruit
'''

fit <- sem(model = desc,
data  = YourData)

summary(fit)


You'll have to do a little more reading to setup your categorical or ordinal variables from here: https://lavaan.ugent.be/tutorial/cat.html

• SEM sounds like a good option and not something I had heard of before. I'm only familiar with programming in R, but it seems there are packages equivalent to SemoPy. Is Thanks for your help :) Nov 5, 2021 at 20:25