Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey guys i have to create a subroutine for LINEAR REGRESSION that calculates a1,

ID: 1827281 • Letter: H

Question

Hey guys i have to create a subroutine for LINEAR REGRESSION that calculates a1,a0, and R^2.

This is the code i have so far, but i cant figure out the next step. could anyone point me in the right direction?


Sub Regress(x, y, n, a1, a0, syz, r2)


sumx = 0: sumxy = 0: st = 0

sumy = 0: sumx2 = 0: sr = 0

n = 7


Do

i= 1, n

sumx = sumx + xi

sumy = sumy + yi

sumxy = sumxy + xi * yi

sumx2 = sumx2 + xi * xi

End

xm = sumx / n

ym = sumy / n

a1 = (n * sumxy - sumx * sumy) / (n * sumx2 - sumx * sumx)

a0 = ym - a1 * xm

Do i = 1, n

st = st + (yi - ym) ^ 2

sr sr + (yi - a1 * xi - a0) ^ 2

End

syx = (sr / (n - 2)) ^ (0.5)

r2 = (st - sr) / st

End Sub

Explanation / Answer

Rather than building an entire class, the code that follows is embedded in the userform and executed by the click event for the

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote