Question on error variance in multiple linear regression

4 views (last 30 days)
I'm trying to generate a regression line through simulation for my research purpose, here I'm explaining the simplified idea.
I generate x1 and x2 observations with their respective means and variances. I then define Y to be a function of x1 and x2 plus some residuals. I know how to use something like
X = [ones(size(X1)) X1 X2];
[coeff,~,~,~,temp] = regress(Y1,X);
Error_Variance=temp(4);
to find the regression line and error variance, but my problem is that I need to find the regression line with a specific error variance (e.g. 400). A conceptual problem here could be that it is not possible to get the regression line with the error value that I want, with my synthetic x1 and x2 observations, but I am going to apply optimization in which the means and standard deviations of x1 and x2 are going to be optimized, where the ErrorVariance remains fixed.
Any idea how to ask Matlab to find a regression line with a fixed error variance that I already have?
Thanks,

Answers (1)

Tom Lane
Tom Lane on 27 Aug 2012
The fourth element of the temp output is an estimate of the variance of the residuals. This depends on the noise rather than the distribution of the x data. For example:
>> x = randn(100000,2);
>> x(:,3) = 1;
>> y = x*(1:3)' + pi*randn(100000,1);
>> [b,bint,r,rint,s] = regress(y,x);
>> s(4)
ans =
9.8885
>> pi^2
ans =
9.8696
Are you hoping to set something other than the fourth element of temp to a fixed value? Perhaps you could explain more.

Community Treasure Hunt

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

Start Hunting!