I am trying to write a subroutine that performs a linear regression using the AvgSpa, StdDevSpa and CovSpa functions. However it looks like the AvgSpa, StdDevSpa and CovSpa functions do not behave as expected when dereferencing a pointer to an element in the array. Any suggestions?
Sub LinearRegression(x As Float!, y As Float!, number_of_points As Long, slope As Float, intercept As Float) ' Calculate slope and intercept ' ' Args: ' x, pointer to array containing independent data ' y, pointer to array containing dependent data ' number_of_points, the number of regression points ' slope, the fitted slope ' intercept, the fitted intercept with the y-axis Dim cov_x_y As Float Dim std_x As Float Dim avg_x As Float Dim avg_y As Float Dim index As Long CovSpa(cov_x_y, 1, number_of_points, !x(1), !y(1)) StdDevSpa(std_x, number_of_points, !x(1)) AvgSpa(avg_x, number_of_points, !x(1)) AvgSpa(avg_y, number_of_points, !y(1)) slope = cov_x_y / (std_x^2) intercept = avg_y - slope * avg_x EndSub