{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Engineering 160 Due November 4th

# Engineering 160 Due November 4th - T he power function is...

This preview shows pages 1–3. Sign up to view the full content.

The power function is the best fit for the data because the r-value is the closest to 1. And the closer the value is to 1 or to -1 means the stronger the correlation of the line to the data in the graph. Option Explicit Private Sub CommandButton1_Click() LeastSquares End Sub Sub LeastSquares() Dim x(1 To 100) As Single, Y(1 To 100) As Single, LnX(1 To 100) As Single, LnY(1 To 100) As Single Dim m As Single, b As Single, LnB As Single, n As Integer, I As Integer, G As String, r As Single Open ("C: \Users \Cooper \Desktop \LeastSqrs.txt") For Input As 1 Input #1, n

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
For I = 1 To n Input #1, x(I), Y(I) LnX(I) = Log(x(I)) LnY(I) = Log(Y(I)) Next I G = InputBox("What is the graph type? (linear, exponential or power)") If (G = "linear") Then Call equations(x(), Y(), n, m, b, r) MsgBox ("m = " & m & " b = " & b & " r = " & r & vbCrLf & "The linear regression equation is Y = " & m & "X + " & b) ElseIf (G = "power") Then Call equations(LnX(), LnY(), n, m, LnB, r) b = Exp(LnB) MsgBox ("m = " & m & " b = " & b & " r = " & r & vbCrLf & "The power regression equation is Y = " & b & "X^" & m) ElseIf (G = "exponential") Then Call equations(x(), LnY(), n, m, LnB, r) b = Exp(LnB)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}