I have run a 3rd order polynomial regression in R and have run the "summary" function, but I need to be able to replicate the "predict" function in Excel. I have my current working code below. Thank you for your help!

#Have access to this output:
AICFit <- lm(R60 ~ poly(M20, 3) + poly(M40, 3), data = mydata)

#do not have access to output: 
predict(AICFit,data.frame(M20=0.972375241,M40=0.989086129,interval ="prediction")

Basically, I don't have access to R when I have access to these numbers: 0.972375241,0.989086129.

  • $\begingroup$ Does the thread at stats.stackexchange.com/questions/31858 answer your question? If not, could you tell us explicitly what else you need? $\endgroup$
    – whuber
    Commented Jun 24, 2019 at 13:17
  • $\begingroup$ @whuber could you demonstrate the "# Compute the orthogonal polynomials in terms of the powers via OLS." step from that thread with my variables? I am having trouble understanding the "xform" part with real variables (instead of the random, reproducible ones). Thank you. And just to confirm that I am understanding this correctly, that step will convert the orthogonal polynomials into the "normal" polynomial equation, right? $\endgroup$ Commented Jun 24, 2019 at 23:59
  • $\begingroup$ xform is an lm object: it contains the result of a multiple, multivariate regression of the orthogonal polynomial terms against the powers of the original variable x. Thus, gamma <- coeff(xform) is the matrix that transforms those x-powers (previously computed in x.p) into the orthogonal variable values. You can see it employed for this purpose in the very next line, which includes the matrix multiplication x.p %*% gamma. $\endgroup$
    – whuber
    Commented Jun 25, 2019 at 14:18


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.