I am trying to calculate an R-Squared for a harmonic linear regression I did with two dependent variables across an image collection, using the linearRegression reducer on Google Earth Engine. The reduction produces an image with two bands, 'coefficients' and 'residuals'. I can get the coefficients as bands by projecting it as an array, and then splitting the array by the number of coefficients. However, I am really struggling to calculate the R-Squared by the same method. I've consulted a stack exchange message that says that I can do it, but does not explain how:
Calculating residual sum of squares and standard error from linearFit model
And there is this Google Earth Engine help file, but that also does not how to do it with an image collection:
https://developers.google.com/earth-engine/guides/reducers_regression
I would post the file, but GEE is not allowing me to do so, and I do not know how to do that either. You can see the code for it here:
https://code.earthengine.google.com/accept_repo=users/elijahtangenberg/Shareable