Question

Explanation and complete code gets thumbs up. For this Matlab problem. For this problem, use Matlab to plot the data and the best fit. Show the written solutions and the Matlab graphs.

Problem Use least squares regression to fit a straight line to r 0246911 121517 19 y567698710 12 12 Along with the slope and intercept, compute the correlation coefficient. Plot the data and the regression line. Then repeat the problem, but regress x versus y - that is, switch the variables.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Executable code:

clc;
clear all;
close all;
x=[0 2 4 6 9 11 12 15 17 19]
y=[5 6 7 6 9 8 7 10 12 12]
a=sum((x-mean(x)).*(y-mean(y)));
b=sum((x-mean(x)).^2);
slope=a/b
intercept=mean(y)-slope*mean(x)
p=[slope intercept];
Y_estimated=polyval(p,y);
n=numel(y);
Std_Error_Estimate=sqrt((sum(y-Y_estimated).^2)/n)
correlation_coefficient=(n*sum(x.*y)-(sum(x)*sum(y)))/((sqrt(n*sum(x.^2)-(sum(x))^2))*sqrt((n*sum(y.^2)-(sum(y))^2)))
plot(x,Y_estimated,'m')
hold on
plot(x,y,'b*')
legend('regression line','data')

Output:

12 r 11F 10 8 10 15 20

Add a comment
Know the answer?
Add Answer to:
Explanation and complete code gets thumbs up. For this Matlab problem. For this problem, use Matlab...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3) 6 11 12 15 17 19 TO 7 12 :12 Use least-squares regression to fit a straight line to the list o...

    please solve it with codes in Matlab 3) 6 11 12 15 17 19 TO 7 12 :12 Use least-squares regression to fit a straight line to the list of data in the accompanying table. Give the slope and the intercept Compute the correlation coefficient Give an estimation of y for r 10 Slope: Intercept: Your answer: Your Answer Page 1 of 1 3) 6 11 12 15 17 19 TO 7 12 :12 Use least-squares regression to fit a...

  • correlation and regression 210 Statistics EXTRA CREDIT Correlation and Regression Formulas written Assignment 1. Follow the...

    correlation and regression 210 Statistics EXTRA CREDIT Correlation and Regression Formulas written Assignment 1. Follow the instructions below to calculate the correlation coefficient and least squares regression line for the data set below. Z 22,- The sample means and sample standard deviations for the two variables are listed below: X = 4 x = 2 3 =5 Sy = 1 The linear correlation coefficient is = 52. Calculate this correlation coefficient using the steps below: (a) First, complete the columns...

  • matlab multiple regression

    peruvian.txtProblem 1 (explore the data):In this exercise use the Peruvian blood pressure data set, provided in the file peruvian.txt (A NOTE for repeat students: The data is different from the data I shared last year.). This dataset consists of variables possibly relating to blood pressures of n = 30 Peruvians who have moved from rural high altitude areas to urban lower altitude areas. The variables in this dataset are: Age, Weight, Height, Pulse, Systol and Diastol. Before reading the data into MATLAB, it can be viewed in a...

  • i neeed help for my qz2 this one is visual basic , i dont understand how...

    i neeed help for my qz2 this one is visual basic , i dont understand how to write code QZ2: Linear Regression (100 points) Given: A data table (see next page) Find: 1. Use one-dimensional array to find the equation of least-squares-fit line (slope and y-intercept; 10 points each), correlation coefficient and coefficient of the determination (10 points each) 2. Use two-dimensional array to find the equation of least-squares-fit line (slope and y-intercept; 10 points each), correlation coefficient and coefficient...

  • Problem 1 Please do not use any type of software to solve this problem; perform all...

    Problem 1 Please do not use any type of software to solve this problem; perform all the calculations and draw the charts by hand. You can use your calculator only for simple operations like addition, multiplication, finding averages and standard deviations. The owner of an apartment complex with three-bedroom units is trying to determine what rent he should set for the summer months. He believes that the rent of an apartment in his complex determines if it will be occupied...

  • A)What is the value of the correlation coefficient? B)What is the value of the coefficient of...

    A)What is the value of the correlation coefficient? B)What is the value of the coefficient of determination? C)When finding the least-squares regression for this line, what is the slope? D)When finding the least-squares regression for this line, what is the y-intercept? E)Give the equation for the least-squares regression line. F)Interpret the slope for this equation. G)Is it reasonable to give an interpretation of your y-intercept? If yes, please give one. If not, explain why. A movie theater decides to examine...

  • A group of physics students collected data from a test of the projectile motion problem that...

    A group of physics students collected data from a test of the projectile motion problem that was analyzed in a previous lab exercise (L5). In their test, the students varied the angle and initial velocity Vo at which the projectile was launched, and then measured the resulting time of flight (tright). Note that tright was the dependent variable, while and Vo were independent variables. The results are listed below. (degrees) Time of Flight (s) Initial Velocity V. (m/s) 15 20...

  • Bivariate Fit of NONFOOD PURCHASES By AGE 90 80 70 60 50 40 30 20 20...

    Bivariate Fit of NONFOOD PURCHASES By AGE 90 80 70 60 50 40 30 20 20 30 40 50 60 AGE -Linear Fit Linear Fit NONFOOD_PURCHASES = 12.956633 0.8136836 AGE Summary of Fit RSquare RSquare Adj Root Mean Square Error Mean of Response Observations (or Sum Wgts) 0.33852 0.336478 11.54086 39.1842 326 Lack Of Fit Analysis of Variance Sum of Source DF Squares Mean Square F Ratio 22084.6 165.8106 133.2 Prob > F .00011 Model 1 22084.562 Error 324 43154.032...

  • please screenshot the MATlab code if possible Need ASAP it is for a course that uses...

    please screenshot the MATlab code if possible Need ASAP it is for a course that uses MATlab to solve for missing variables and such. The following equation is available for the saturation pressure of air as a function of temperature: In (psat/Pc) = C1 x + C2 x2 + C3 In (Tsat/Tc), where x = 1/Tc - 1/Tsat Pc =3.77 MPa is the critical pressure, and Tc = 132.5 K is the critical temperature. The following data are available for...

  • please quickly Problem 1. Research performed at NASA measured the lengths of the right humerus and...

    please quickly Problem 1. Research performed at NASA measured the lengths of the right humerus and right tibia in eleven rats that were sent to space on Spacelab Life Sciences 2. The following data were collected. We will let length of the right humerus be the explanatory variable and the length of the right tibia be the response variable. Right Humerus (mm) 24.80 24.59 24.59 24.29 23.81 24.87 25.90 26.11 26.63 26.31 26.84 Right Tibia (mm) 36.05 35.57 35.57 34.58...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT