Private Sub Кнопка11_Click()
Dim n As Variant
n = 8
ReDim ArrayXY(1 To 2, 1 To n) As Integer
Dim SumX, SumY, SumX2, SumXY, SumX3, SumX4, SumX2Y, SumLnY, SumXLnY As Double
Dim OPRlin, OPRkvadr, OPRa1, OPRa2, OPRa3 As Double
Dim a1lin, a2lin, a1kvadr, a2kvadr, a3kvadr, a1exp, a2exp, cexp As Double
Dim Xsr, Ysr, S1, S2, S3, Skvadr, Sexp, Slin As Double
Dim Kkor, KdetLin, KdetKvadr, KdetExp As Double
Dim i As Integer
ArrayXY(1, 1) = поле1.Value
ArrayXY(1, 2) = поле2.Value
ArrayXY(1, 3) = поле3.Value
ArrayXY(1, 4) = поле4.Value
ArrayXY(1, 5) = поле5.Value
ArrayXY(1, 6) = поле6.Value
ArrayXY(1, 7) = поле7.Value
ArrayXY(1, 8) = поле8.Value
ArrayXY(2, 1) = Поле34.Value
ArrayXY(2, 2) = Поле35.Value
ArrayXY(2, 3) = Поле36.Value
ArrayXY(2, 4) = Поле37.Value
ArrayXY(2, 5) = Поле38.Value
ArrayXY(2, 6) = Поле39.Value
ArrayXY(2, 7) = Поле40.Value
ArrayXY(2, 8) = Поле41.Value
SumX = 0
SumY = 0
SumXY = 0
SumX2 = 0
SumX3 = 0
SumX4 = 0
SumX2Y = 0
SumLnY = 0
SumXLnY = 0
'Вычисление сумм x, y, x*y, x^2, x^3, x^4, (x^2)*y, Ln(y), x*Ln(y)
For i = 1 To n
SumX = SumX + ArrayXY(1, i)
SumY = SumY + ArrayXY(2, i)
SumXY = SumXY + ArrayXY(1, i) * ArrayXY(2, i)
SumX2 = SumX2 + Sqr(ArrayXY(1, i))
SumX3 = SumX3 + ArrayXY(1, i) * ArrayXY(1, i) * ArrayXY(1, i)
SumX4 = SumX4 + Sqr(ArrayXY(1, i)) * Sqr(ArrayXY(1, i))
SumX2Y = SumX2Y + Sqr(ArrayXY(1, i)) * ArrayXY(2, i)
SumLnY = SumLnY + Log(ArrayXY(2, i))
SumXLnY = SumXLnY + ArrayXY(1, i) * Log(ArrayXY(2, i))
Next i
'Вычисление коэффициентов
OPRlin = 0
a1lin = 0
a2lin = 0
a1kvadr = 0
OPRkvadr = 0
a2kvadr = 0
a2kvadr = 0
a1exp = 0
a2exp = 0
OPRlin = n * SumX2 - SumX * SumX
a1lin = (SumX2 * SumY - SumX * SumXY) / OPRlin
a2lin = (n * SumXY - SumX * SumY) / OPRlin
OPRkvadr = n * SumX2 * SumX4 + SumX * SumX3 * SumX2 + SumX2 * SumX * SumX3 - SumX2 * SumX2 * SumX2 - n * SumX3 * SumX3 - SumX * SumX * SumX4
a1kvadr = (SumY * SumX2 * SumX4 + SumX * SumX2Y * SumX3 + SumX2 * SumXY * SumX3 - SumX2 * SumX2 * SumX2Y - SumY * SumX3 * SumX3 - SumX * SumXY * SumX4) / OPRkvadr
a2kvadr = (n * SumXY * SumX4 + SumY * SumX3 * SumX2 + SumX2 * SumX * SumX2Y - SumX2 * SumX2 * SumXY - n * SumX3 * SumX2Y - SumY * SumX * SumX4) / OPRkvadr
a3kvadr = (n * SumX2 * SumX2Y + SumX * SumXY * SumX2 + SumY * SumX * SumX3 - SumY * SumX2 * SumX2 - n * SumXY * SumX3 - SumX * SumX * SumX2Y) / OPRkvadr
a2exp = (n * SumXLnY - SumX * SumLnY) / OPRlin
cexp = (SumX2 * SumLnY - SumX * SumXLnY) / OPRlin
a1exp = Exp(cexp)
'Вычисление средних арифметических x и y
Xsr = SumX / n
Ysr = SumY / n
S1 = 0
S2 = 0
S3 = 0
Slin = 0
Skvadr = 0
Sexp = 0
Kkor = 0
KdetLin = 0
KdetKvadr = 0
KdetExp = 0
For i = 1 To n
S1 = S1 + (ArrayXY(1, i) - Xsr) * (ArrayXY(2, i) - Ysr)
S2 = S2 + Sqr(ArrayXY(1, i) - Xsr)
S3 = S3 + Sqr(ArrayXY(2, i) - Ysr)
Slin = Slin + Sqr(a1lin + a2lin * ArrayXY(1, i) - ArrayXY(2, i))
Skvadr = Skvadr + Sqr(a1kvadr + a2kvadr * ArrayXY(1, i) + a3kvadr * ArrayXY(1, i) * ArrayXY(1, i) - ArrayXY(2, i))
Sexp = Sexp + Sqr(a1exp * Exp(a2exp * ArrayXY(1, i)) - ArrayXY(2, i))
Next i
'Вычисление коэффициентов корреляции и детерминированности
Kkor = S1 / Sqr(S2 * S3)
KdetLin = 1 - Slin / S3
KdetKvadr = 1 - Skvadr / S3
KdetExp = 1 - Sexp / S3
'Вывод результатов
'Линейная функция
Поле13.Value = a1lin
Поле15.Value = a2lin
'Квадратичная функция
Поле21.Value = a1kvadr
Поле22.Value = a2kvadr
Поле23.Value = a3kvadr
'Экспоненциальная функция
Поле24.Value = a1exp
Поле25.Value = a2exp
Поле26.Value = cexp
Поле31.Value = Xsr
Поле32.Value = Ysr
'Коэффициенты функция
Поле28.Value = Kkor
Поле29.Value = KdetLin
Поле30.Value = KdetKvadr
Поле33.Value = KdetExp
End Sub