Question: write a program in word VBA that will use the method of least squares (linear regression) to calculate the m, b and r values for

write a program in word VBA that will use the method of least squares (linear regression) to calculate the m, b and r values for a given set of data points. The given data represents information about the volume of water through a culvert (in ft3/s), as a function of the height of the water in the culvert (in inches).

Program requirements:

-Use a main program and a Subroutine subprogram.

-In the main program, read from the given file (LeastSqrs.txt): on line 1 of the file, read a number which equals the number of data pairs, n (n will never be more than 100); then starting on line 2 of the file the data pairs are listed, (x, y), one per line. Read the data pairs into one-dimensional arrays (one array will contain the x values and the other the y values).

-In the main program, ask the user if they want you to calculate the regression equation for a linear, exponential or power situation.

-Based on the users response, calculate and send to the Subroutine the correct form of the x and y values (you may need Lny, etc.).

-Use only ONE Subroutine to calculate the m, b and r values using the method of least squares to do Linear Regression (see equations on back of sheet).

-In the main program, output to the screen the linear, exponential or power equation with the calculated values of m and b inserted in the equations. Also output the r value.

file content shown below

1.2, 0.06 1.4, 0.08 1.9, 0.15 2.3, 0.28 2.8, 0.40 3.5, 0.48 4.9, 1.25 6.7, 2.44 12.3, 5.15 15.8, 10.55 24.8, 15.28 

-On line one, read the value of n (the count of data pair in the file).

-Starting on line two, the data is given as X, Y

n=11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!