I am using the varpart function present in the vegan package. this is my script:
CR_all.fun_var_part <- varpart(all_fungi, ~ age, ~ lat +long, data = Cr_var)
CR_all.fun_var_part
plot(CR_all.fun_var_part, digits=2)
my response variable, all fungi, was the abundance matrix which I transformed with the hellinger method. age (X1) represents the different ages of my forests which I scaled with scale function. if I want to use my GPS coordinates as X2 how should I treat them?should I transform them? How should the script for the varpart function be? I hope my question was not too vague and I thank everyone for any help.
Having ~ lat + long
is the same as fitting a linear trend surface. It only accounts for a linear geographical trend. This is OK if you're interested in linear trend only. If you think you need more complicated trends, then you need more complicated models: polynomial on coordinates, splines on coordinates or (like many do) PCNM variables. Transformations of coordinates will change the shape of response when plotted against original coordinates, but it is difficult to say how to transform.
The polynomials can be found with base
function poly(lon, 2)
(for 2nd degree polynomial). PCNM (principal coordinates of neighbourhood matrix) can be found with many packages, including vegan (pcnm
).
This answer only concern how to do this. I don't want to endorse any of these practices.