I have collected environmental data on animals, and am seeking help on how to deal with certain variables where a non-numeric value is informative, but also problematic. I have three variables that rely on each other: log, distance to log, and diameter of nearest log. These qualities are measured within a sample area of 4 m radius around a 1-m squared quadrant, where the animal is located.

  • In the case of log: NA would mean I was unable to sample the quadrant or surrounding 4m area (inaccessible), None means no log(s) present in sample area, which means it could logically be equal to 0.
  • For distance to log, if log is "none" or "0", then NA is not appropriate because again, that means I was unable to sample the space but a value of '0' for the distance to the log would mean the log was within the 1-m squared quadrant, which is incorrect if there is truly no log within the 4 m sample area. [The 1-m squared quadrant acts as a proxy for the whole animal].
  • The same issue with diameter of nearest log exists: NA would mean I was unable to sample the space, but a value of 0 would mean the diameter of the log measured '0 cm', and a log cannot realistically have a diameter of zero (in this experiment, logs were pieces of wood greater than 7.5 cm in diameter).

Hence, for distance and diameter of nearest log, 0 cannot be the logical result if a log is not present, but zero can be the distance to the nearest log if there are logs present. Any suggestions on how to resolve this character vs numeric issue for statistical analysis? The solution may have to be making these categorical variables with the values of 'none', '0-1', '1-2', etc, and I'd need to touch up on multivariate models that handle repeated measures using categorical and numerical data.

The end goal is to do a multivariate analysis with many environmental variables to compare the animal chosen environment versus available, randomly chosen environments within the forest.

Thank you in advance.


You are dealing with a situation where you have variables (distance to log, diameter of nearest log) that only have meaning in the presence of a previous variable condition (log is present). You can deal with this by coding your variables so that the conditional variables are set to zero if there is no log present, so that the log-indicator variable captures the entire "effect" of the absence of a log. For data points where you could not observe the area, you would code both variables as NA and treat these as missing data. Here is an example of what I mean.

$$\begin{array} {|r|r|r|} \hline \text{Outcome} & \text{Log (Indicator)} & \text{Distance (m)} & \text{Diameter (m)} \\ \hline \text{Inaccessible site} & \text{NA} & \text{NA} & \text{NA} \\ \hline \text{No log on site} & 0 & 0 & 0 \\ \hline \text{Log on site} & 1 & 2.34 & 1.21 \\ \hline \end{array}$$

If you were to put this kind of data into a regression model, the indicator variable for the presence of a log would allow the model to give a different prediction for no log than it would give for a very small log that is very nearby (distance and diameter near zero). This would allow you to interpret the parameters in your model so that you get a predictive result when there is no log, and a result where there is a log, with this latter effect depending on the distance and diameter. If you want to make sure your model does not allow an outcome with no log, but with positive effects for the other conditional variables, you could code the conditional variables as interaction effects as follows:

Response ~ Intercept + Log + Log:Distance + Log:Diameter

If you code your model this way then a value of $\text{Log} = 0$ means that there are no coefficients other than the intercept in that outcome. You would then treat NA values as missing data, using standard techniques (imputation, etc.) to deal with these.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.