# How to calculate a "Predicted line"? [duplicate]

Here is a regression realized with R

> degree=2
> frml = formula(A~factor(B)*poly(C,degree=degree))
> m = lm(frml,data=data)
> summary(m)$coeff Estimate Std. Error t value Pr(>|t|) (Intercept) 0.050882 0.001591 31.980 < 2e-16 *** factor(B)2 0.090513 0.002250 40.227 < 2e-16 *** factor(B)3 0.245776 0.002250 109.231 < 2e-16 *** factor(B)4 0.483829 0.002250 215.030 < 2e-16 *** factor(B)5 0.741211 0.002250 329.419 < 2e-16 *** factor(B)6 0.907053 0.002250 403.125 < 2e-16 *** poly(C, degree)1 0.008182 0.016988 0.482 0.63114 poly(C, degree)2 -0.004527 0.016988 -0.266 0.79044 factor(B)2:poly(C, degree)1 -0.014671 0.024024 -0.611 0.54284 factor(B)3:poly(C, degree)1 0.010721 0.024024 0.446 0.65640 factor(B)4:poly(C, degree)1 0.037756 0.024024 1.572 0.11933 factor(B)5:poly(C, degree)1 0.031446 0.024024 1.309 0.19368 factor(B)6:poly(C, degree)1 0.011876 0.024024 0.494 0.62220 factor(B)2:poly(C, degree)2 0.006151 0.024024 0.256 0.79846 factor(B)3:poly(C, degree)2 -0.033512 0.024024 -1.395 0.16625 factor(B)4:poly(C, degree)2 -0.064164 0.024024 -2.671 0.00889 ** factor(B)5:poly(C, degree)2 -0.008938 0.024024 -0.372 0.71068 factor(B)6:poly(C, degree)2 -0.024527 0.024024 -1.021 0.30985  What do we call a "predicted line"? How can we calculate this function from these data? I think it should be something like y=0.050882+0.090513+0.008182x-0.004527x^2+...Is it correct? What would be the following. Are there other name for this "predicted line"? What is the difference between adding this predicting line on a plot than adding a simple lm (of the first or second degree)? What would be the predicted line if I computed B as a covariate (measuring a surface) instead of a factor? Thanks a lot for your help! ## 2 Answers In my opinion showing six polynomial lines (each corresponds to certain level of factor B) is better than an interpolated surface. This can be done as par(mfrow = c(2,3)) sapply(levels(factor(data$B)), function(x){
C_val=seq(min(data$C),max(data$C),by=(max(data$C)-min(data$C))/100)
plot(C_val,
predict(m, newdata = data.frame(C=C_val,B=rep(x,101))),
type="l",
ylab = x)
}
)


Well, you could call it the "line of best fit" or the "trend line".

The simple lm simply fits a straight line relationship, the polynomial line posits a more complex, non-linear relationship between the variables. Can you think what processes might drive such a relationship?

EDIT: As you say if you treat B as another variable you'll get a 2D surface for predicting the value of A, with interpolated points. Does this make sense or does B only take discrete values?