Question

HW8_4 Fit the data in the table using linear regression. Plot the data points as well as the regression line. Determine the vPlease write the codes in MATLAB.

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

%we are supposed to answer 1 question at a time

%HW8_4

clear
clc
close all
x=1:10;
y=[26.7 20.2 16.8 15.3 15.1 9.3 5.1 2.8 -1.1 -8.4];
%y=mx+c
p1=polyfit(x,y,1);
plot(x,y,'*',x,p1(1)*x+p1(2))
xlabel('x')
ylabel('y')
title(sprintf(' y = (%f) x + (%f)',p1))
legend('Data points','Linear fit')
sse=sum((y-polyval(p1,x)).^2);
ssto=sum((y-mean(y)).^2);
r21=1-sse/ssto;
fprintf(' y = (%f) x + (%f)\n',p1)
fprintf(' R squared value: %f\n',r21)
fprintf(' value of y when x = 7.2: %f\n',p1(1)*7.2+p1(2))
%x = ym + c

p2=polyfit(y,x,1);
figure
plot(y,x,'*',y,p2(1)*(y)+p2(2))
ylabel('x')
xlabel('y')
title(sprintf(' x = (%f) y + (%f)',p2))
legend('Data points','Linear fit')
sse=sum((x-polyval(p2,y)).^2);
ssto=sum((x-mean(x)).^2);
r22=1-sse/ssto;
fprintf(' x = (%f) y + (%f)\n',p2)
fprintf(' R squared value: %f\n',r22)
fprintf(' value of x when y = 15: %f\n',p2(1)*15+p2(2))

Command Window y-3.463030) x+(29.226667) R squared value: 0.968985 value of y when x = 7.2: 4.292848 x= (-0.279808) y + (8.34

Add a comment
Know the answer?
Add Answer to:
HW8_4 Fit the data in the table using linear regression. Plot the data points as well as the regr...
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
  • Exercise 2. Consider the iris data set. (a) Fit a linear regression model for Sepal.Width using S...

    Exercise 2. Consider the iris data set. (a) Fit a linear regression model for Sepal.Width using Sepal.Length and Species as predictors. Recall that Species is a categorical variable with 3 levels (setosa versicolor, and virginica). Use summary) to print the results. What is the base- line level for Species in the model? (b) Fit a linear regression model for Sepal.Width using Sepal.Length, Species, and the interaction between Sepal.Length and Species as predictors. Use summary ) to print the results. (c)...

  • please solve using matlab 4. Nonlinear Regression Fit the below data with the following curve-fit equation y bi (ebr + 2 1.0000 1.5431 3.7622 10.0677 27.3082 Define a function of the sum of squar...

    please solve using matlab 4. Nonlinear Regression Fit the below data with the following curve-fit equation y bi (ebr + 2 1.0000 1.5431 3.7622 10.0677 27.3082 Define a function of the sum of squared residuals (fSSR) as a function of the regression coefficients, b's. Minimize the fSSR function and determine the regression coefficients. Guess what would be the built-in math function to generate the original data? Plot the function in the existing figure with a smooth dashed line, calculate the...

  • Using the data file provided with both variables, x and y, answer the following questions using...

    Using the data file provided with both variables, x and y, answer the following questions using Excel*: 1.Create a scatterplot with the data. Comment on direction, form, strength, outliers and/or other significant findings. 2.Use the linear model to fit a line to the data and determine the equation ỹ = b0 + b1x and Interpret b0and b1. 3.Calculate the coefficient of correlation. Discuss the strength of correlation between the explanatory and response variables. 4.Predict the value for ỹ when you...

  • Using the Linear Regression Fit Line: y=0.409x+2.963, calculate a forecast for the 18th month. 2 Pts...

    Using the Linear Regression Fit Line: y=0.409x+2.963, calculate a forecast for the 18th month. 2 Pts Actuals 12 0.4093x+2 9632 10 Calculate a Forecast for Month 18 18th Month Forecast a) b) Does this look like a good use of a regression approach & why? c) List any concerns you 2 might have if I asked you to forecast month 24 with the data for months 1 through 17 only? 0123456789 10 11 12 13 14 15 16 17 18

  • Find the equation of the regression line for the given data. Then construct a scatter plot...

    Find the equation of the regression line for the given data. Then construct a scatter plot of the data and draw the regression line. (The pair of variables have a significa correlation.) Then use the regression equation to predict the value of y for each of the given x-values, if meaningful. The table below shows the heights (in feet) and the number of stories of six notable buildings in a city. Height, x 758 621 518 510 492 483 (a)...

  • 4. (35 points) Use multiple linear regression to fit the following experimental data, 12 1 4...

    4. (35 points) Use multiple linear regression to fit the following experimental data, 12 1 4 5.5 1.5 5 y 13 22 16 9 9 (a) Compute the coefficients, the coefficient of determination , the standard deviation Sy, and the standard error of the estimate S/. Show your calculations. (b) Write a MATLAB script that solves part (a).

  • please help me answer these questions based on the data Part 5: Correlation, Regression, and Goodness-of-fit test analysis. (20 pts) Using the midpoints as the x-variable and the frequencies as t...

    please help me answer these questions based on the data Part 5: Correlation, Regression, and Goodness-of-fit test analysis. (20 pts) Using the midpoints as the x-variable and the frequencies as the y-variable of the different data sets of both groups of players, complete the following: I. Graph the scatterplot of points (x, y) to determine the outliers and influential points. Calculate the value for the Linear Correlation Coefficient (r) and give the interpretation. Using a significance level of 0.05, determine...

  • Question 12 [15 Points] Show proper work. Topic: Linear regression The following data represents the number...

    Question 12 [15 Points] Show proper work. Topic: Linear regression The following data represents the number of full-time employees (x) and the number of job openings postedly) for the top 10 hospitals in Boston metro area (Source: Boston Medical Journal 2009). 2450 3900 9600 9900 13235 1900 5530 6700 7785 4300 210 280 490 565 625 175 435 420 680 350 Consider the following: Exy - 32,536,925 Ex544,958,625 Zyl. 2,053,600 Ex-_65,315 Ey - 4,230 PLEASE DO DETAILED WORK IN THE...

  • D. We will use pinv function to find a linear regression model to map the measurement data to tru...

    d. We will use pinv function to find a linear regression model to map the measurement data to truth data. Our model will be Y-AX. Y is the truth data matrix Y [ yı; y2i yai ya; ysi yg: y7 ]. A is the tmeasurement data matrix A=[ 1 mh; 1 m2. 1 mai 1 m4; 1 ms: 1 mt 6:1 m7 I . and X-[Xo: x1] is the coefficient of your regression model. Truth Data yn -1 0 Measurement...

  • Perform a linear regression to determine the slope of the plot of Ln(A/A0) vs time that...

    Perform a linear regression to determine the slope of the plot of Ln(A/A0) vs time that is discussed on page 16. Recall from page 12 that the slope for this plot is -k (where k is the radioactive decay constant). Input below the value for k obtained from this data set. Answer=0.0715 Note that your k value should be positive, since it is the negative of the slope. All reaction rate constants are positive values. The units for this k...

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