oahfidsigbosga igoahaighaoeighoaw lagihsgibsohgaiesubg \suigh\seugbeisugi\seubvieu usgziseugbisu\bgzdbgz zgbzdsgubgisugziu fu\iesgi\eliueg\zjxbvkzsdbgi khifsohi\eg

1 comentario

Star Strider
Star Strider el 4 de Mzo. de 2015
Context: ‘Mary292’ originally asked how to determine the error with respect to a linear regression applied to perturbed data with a model derived from unperturbed data on the same system. The system was initially unperturbed (the first 2000 data pairs, on which the regression was performed), then perturbed.

Iniciar sesión para comentar.

 Respuesta aceptada

Star Strider
Star Strider el 21 de Feb. de 2015

0 votos

Your model is the linear regression of the first 2000 points. To get the model predictions for the rest of the data, ‘plug in’ the values for your independent variable for the rest of your data in your model. The output of your model are the predictions for those values. To get the error, subtract your predictions from the dependent variable data for those same values of the independent variable.
To illustrate:
x = linspace(0,200); % Create Data
y1 = 0.5*x(1:50) + 0.1*randn(1,50) + 1.2; % Create Data To Fit
y2 = 0.6*x(51:100) + 0.1*randn(1,50) + 1.5; % Create Data To Evaluate Error
b = polyfit(x(1:50), y1, 1); % Parameter Estimates
yfit = polyval(b, x); % Predict Entire Data Set
model_error = yfit - [y1 y2]; % Calculate Error
figure(1)
plot(x, [y1 y2], 'xr')
hold on
plot(x, yfit, '-b')
hold off
grid
legend('Data', 'Model Fit', 'Location','SE')

5 comentarios

Mary292
Mary292 el 21 de Feb. de 2015
Am I just calculating the model error for columns 9 and 10 as that's what I was told to calculate the regression model from?
Is my independent variable 'Data point number' and my dependent variable 'Amplitude'?
I have calculated the gradient and intercept for my regression model:
x=X(1:2000,9);
y=X(1:2000,10);
m=(2000*sum(x.*y)-sum(x)*sum(y))/(2000*sum(x.^2)-sum(x).^2); %calculates slope
c=(sum(y)*sum(x.^2)-sum(x)*sum(x.*y))/(2000*sum(x.^2)-sum(x).^2); %calculates intercept
So now do I use the equation y=mx+c? Is this what I'm supposed to plug my independent variable into for the value of x?
Sorry about all the questions I'm just having a really hard time understanding it. I've never used things like 'polyfit' or 'polyval' before, I only really know the basics of matlab.
Star Strider
Star Strider el 21 de Feb. de 2015
‘Is my independent variable 'Data point number' and my dependent variable 'Amplitude'?’
On the basis of what else you wrote, it would seem so. Ask your professor if you want be certain.
‘So now do I use the equation y=mx+c? Is this what I'm supposed to plug my independent variable into for the value of x?’
Calculate it exactly as written. Specifically:
x=X(1:2000,9);
yfit = m*x + c;
I called it ‘yfit’ so you would not confuse it with your ‘y’ variable. It is your ‘model fit’.
You are using traditional least squares calculations to estimate ‘m’ and ‘b’, so don’t worry about polyfit and polyval just now. I had no idea how you were calculating them from reading your question.
Continuing, your error then is:
model_error = yfit - y;
Star Strider
Star Strider el 22 de Feb. de 2015
That looks correct to me.
The model error can be a straight line (I don’t have your data so I can’t say for certain), but it doesn’t have to be, especially if it is experimental (or simulated experimental) data. Real-world data always has some amount of error associated with it.
Mary292
Mary292 el 22 de Feb. de 2015
Thank you! You've been a great help
Star Strider
Star Strider el 22 de Feb. de 2015
My pleasure! And thank you for the compliment!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Descriptive Statistics en Centro de ayuda y File Exchange.

Preguntada:

el 21 de Feb. de 2015

Comentada:

el 4 de Mzo. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by