Engineering 160 Due November 4th

Engineering 160 Due November 4th - The power function is...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 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...
View Full Document

Page1 / 5

Engineering 160 Due November 4th - The power function is...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online