# How best to code longitudinal data and design a regression with IV that only applies to later time point?

Scenario: I have data comparing the number of tree stems in 30 forest plots between two sampling years (1992 and 2012). Each plot experienced hurricane damage between these 2 sampling years (in 1996) -- this damage was coded as being 0-100% of trees felled/damaged.

Interest: my ultimate hypothesis I'm trying to investigate is that the number of stems did not increase with time except in plots with greatest hurricane damage. (So, I'd like to know the effect of the hurricane on stem counts between plots while accounting for changes in time).

Data: designed as follows:

Plot  Year  HurrDam  Count
1  1992      ???     11
1  2012       30    115
2  1992      ???     22
2  2012       60    381
....


I've placed question marks (???) in the above example because I'm not sure how to best enter (and therefore analyze) my data.

• Technically, all plots had 0% hurricane damage in 1992 because they occurred before the hurricane. So to provide a value here seems kind of artificial.

• One option is to replace the ??? with 0' for all data rows from 1992.

• Alternatively, my other thought was to treat the hurricane damage of any given plot as an unchanging characteristic of that plot overall -- i.e., regardless of year of sample. Under this scenario, the ??? would be replaced not with 0 but with the HurrDam value from 2012. So in my example data above, the ??? would be replaced with 30 and 60, respectively.

• The result would be that HurrDam would be identical for both samples of any given plot although such a value only really applies to the latter sampling period for each plot in real life.

Which of these approaches is more appropriate for analyzing this data using linear regression (i.e., lm() in R)?

I feel like making HurrDam = 0 for all 1992 data creates a strong temporally-structured trend between years (which I'm not interested in investigating when it comes to hurricane damage -- In fact, this is the whole point of including Year as its own variable: I want to tease the effects of hurricane damage and simple passage of time apart).

• I could make HurrDam = 0 for all 1992 samples, then eliminate Year as a variable from my model, and instead just rely on the differences in HurrDam between years to account for this change, but this is problematic because 1) it ignores the repeated-measures structure of my data and 2) I feel like it accentuates the differences in HurrDam between years when I'm really only interested in knowing the effects of differences in HurrDam between plots in the latter year (while, again, simply accounting for any changes due to the passage of time across plots).

I also noticed that if I want to add an interaction term between Year and HurrDam in my ultimate linear model, the values for that interaction term becomes NA if I zero out the 1992 data.

Any suggestions/insights would be appreciated!

• To summarize quickly: I want to see if greater hurricane damage leads to increases in tree stem counts while showing that the stem counts did not significantly increase due to the passage of time alone. In my mind, this is a simply-constructed linear regression (StemCount ~ HurrDam + Year) that enables me to comment on the coefficient and significance of both hurricane damage (my variable of interest) and the simple passage of time (something I'm essentially hoping to show had insignificant impact). I just don't know how to design my input data to do so correctly. Apr 10, 2023 at 19:34
• If I just keep HurrDam the same for both years for each plot (e.g., 30 in my plot 1 example in my post) but avoid including an interaction term in my model, will I be able to accomplish my goal? Apr 10, 2023 at 20:25
• "To summarize quickly" <- can you put this comment into the body of your post? It is important Apr 11, 2023 at 11:33

Note: I am not an ecologist. So take inspiration from my answer but adjust if necessary.

I think the two-rows-per-plot formatting of the data is misleading. I think it's really one row per plot with three variables: the count at 1992, the hurricane damage at 1996, and the count at 2012. With that in mind...

Here is a model: Assume that at time $$t=0$$ (1992), there are $$S_0$$ stems, and we have a constant growth rate $$\mu$$. Then prior to the hurricane event ($$t=4$$), $$S_t=\mu^tS_0$$. This can also be expressed logarithmically, $$\log(S_t)=t\log(\mu)+\log(S_0)$$.

At $$t=4$$ there was a hurricane event, in which a proportion (NOT PERCENTAGE) $$H$$ of stems were destroyed. Therefore at $$t=4$$, the number of stems is $$S_4=H\mu^4S_0$$ or $$\log(S_4)=\log(H) + 4\log(\mu)+\log(S_0)$$.

Your hypothesis is that larger $$H$$ results in a larger growth rate, post-hurricane, $$t>4$$. This could be represented generally as the growth rate post-hurricane being $$\mu H^\beta$$, for reasons which will shortly be explained.

From year 4 until the last year (2012, $$t=20$$), $$\log(S_t)=[\log(H)+t\log(\mu)+\log(S_0)] + \beta\log(H)$$ (using some basic algebra, not shown).

The cool thing about this is that the $$\beta$$ is pretty close to a form that we could put into a linear model. Since we only have two time observations, I suggest something like this (algebra not shown):

$$\log(S_{20}/S_0) = 20\log(\mu) + \log(H) + \beta\log(H)$$

The first term is the intercept, and an estimate of the baseline growth due to time. I suggest putting the second term in as an offset` just for ease of interpretation of the third term. The third term accounts for the effect of the hurricane damage on the growth rate.

How do we interpret the third term's coefficient? If $$\beta$$ is zero, then the amount of hurricane damage doesn't affect the growth rate. If $$\beta$$ is negative, then this corresponds to hurricane damage increasing the growth rate. If $$\beta$$ is positive, then hurricane damage decreases the growth rate.

This can probably be done with a standard linear model. Or a GLM. You might also have to deal with zero proportions. Haven't really thought about that.