# Is a regression line the same if it is computed with the mean of samples?

I have 120 samples (Y-values) at the same point, for 45 points (X-values) = 120x45 samples. Will the regression line be the same if it is computed with the mean of every 120 samples as if I would do it for all 120?

I am asking since MATLABs Curve Fit Tool Box do not accept multiple Y-values for the same X-values.

• Coefficients should be the same, but variances will differ (this assumes that all y values are means based on the exact same number of observations. If $n_i$ differs you would have to use a weighted regression). – kjetil b halvorsen Jul 31 '17 at 15:41
• Okay, the variance is important to know. Do you have any suggestion how to solve my problem with multiple y-values for same x-values? – tompak Jul 31 '17 at 16:01
• Just repeat the values! instead of having 120 y's for each x, replicate to have 120 x's with the same value. We could make some theoretical formulas, but it isn't worth the effort. Just replicate. – kjetil b halvorsen Jul 31 '17 at 16:04