Hi,
I am looking for a matlab function that is working similar to polyfit, but where I can use two different input function but instead of having just one linear term, I need two. At the moment the regression looks as follows:
y=b0+b1*x+error
and the code to compute R^2 is the following:
x= changePriceWithoutNaN;y=changeFWithoutNaN;p = polyfit(x,y,1);f = polyval(p,x);plot(x,y,'o',x,f,'-')yfit = polyval(p,x);yfit = p(1) * x + p(2);yresid = y - yfit;SSresid = sum(yresid.^2);SStotal = (length(y)-1) * var(y);rsq_full = 1 - SSresid/SStotal
Instead of having just one linear term, the term I am looking for is the following:
y=b0+b1*x+b2*z+error
Is there anybody how knows a function that is solving a least squared optimazation in the way to coe above does? Importat is that I do not look for a quadratic solution and therefore from what I can see polyfit(x,y,2) is not an option
Best Answer