Walmes vou criar um exemplo para facilitar o entendimento<div><br></div><div>o que eu preciso é comparar pontos amostrados com os resultados de um modelo de interpolação polinomial</div><div><br></div><div>por exemplo</div>

<div><br></div><div>#minhas amostras</div><div>y=seq(1:9)</div><div>x=seq(3:11)</div><div><br></div><div>#pontos do modelo</div><div>xm=seq(2,11)</div><div>ym=seq(0:8)</div><div><br></div><div>#tirando os valores do modelo da reta</div>

<div>r=lm(ym~poly(xm,1))</div><div><br></div><div>#extraindo coeficientes</div><div>a=r$coefficients[1]</div><div>b=r$coefficients[0]
</div><div><br></div><div>validacao=vector()</div><div>#comparando cada ponto obtido pelo modelo ajustado com a amostra</div><div>for(i in c(1:length(y)){</div><div># calculando valor do modelo</div><div>m=a*x[i]+b 
</div><div># comparando modelo com amostra</div><div>ifelse(m<y[i],a='fora',a='dentro')</div><div>validacao[i]=a</div><div>}</div><div><br></div><div> é algo deste estilo porém com um polinomio de grau elevado, Quando ploto os resultados eles estão bonitos, mas quando calculo ele como o método abaixo os valores extrapolam muito da realidade e não entendo o porque, veja o  exemplo aqui</div>

<div><br></div><div><br></div><div><blockquote class="gmail_quote" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:9.600000381469727px;background-color:rgb(255,255,255);margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">y=c(-26.0000,-25.9862,-25.<u></u>9343,-25.8822,-25.8433,-25.<u></u>8054,-25.7948,-25.7872,-25.<u></u>7668,-25.7284,-25.7015,-25.<u></u>6282,-25.4612,-25.3016,-25.<br>

2564,-25.2412,-25.2412,-25.<u></u>2232,-25.0869,-25.0000,-25.<u></u>0000,-24.9856,-24.9397,-24.<u></u>8976,-24.8533,-24.6587,-24.<u></u>6373,-24.5740,-24.5406,-24<br>.4379,-24.3934,-24.3628,-24.<u></u>3277,-24.3042,-24.2972,-24.<u></u>2973,-24.3020,-24.3068,-24.<u></u>3068,-24.2956,-24.2920)<br>

</blockquote></blockquote><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:9.600000381469727px;background-color:rgb(255,255,255)"> </div><blockquote class="gmail_quote" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:9.600000381469727px;background-color:rgb(255,255,255);margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">x=c(-45.8529,-45.8302,-45.<u></u>7575,-45.6680,-45.6107,-45.<u></u>5050,-45.4574,-45.4058,-45.<u></u>3538,-45.2913,-45.2634,-45.<u></u>2264,-45.1667,-45.0719,-45.<br>

0213,-45.0000,-45.0000,-44.<u></u>9748,-44.8726,-44.8405,-44.<u></u>8405,-44.8351,-44.8259,-44.<u></u>7972,-44.7764,-44.6867,-44.<u></u>6674,-44.5912,-44.5587,-44<br>.4927,-44.4515,-44.4115,-44.<u></u>3314,-44.2664,-44.2171,-44.<u></u>1729,-44.1288,-44.0820,-44.<u></u>0509,-44.0118,-44.0000)<br>

  </blockquote></blockquote><div><br></div><div>r=lm(y~poly(x,5)) </div></div><div><br></div><div><div>b0=r$coefficient[1]</div><div>b1=r$coefficient[2]</div><div>b2=r$coefficient[3]</div><div>b3=r$coefficient[4]</div><div>

b4=r$coefficient[5]</div><div>b5=r$coefficient[6]</div></div><div><br></div><div>modelo=<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:9.600000381469727px;background-color:rgb(255,255,255)">b0+b1*x+b2*x^2+b3*x^3+</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:9.600000381469727px;background-color:rgb(255,255,255)">b4*x^4+b5*x^5</span></div>

<div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:9.600000381469727px;background-color:rgb(255,255,255)"><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:9.600000381469727px;background-color:rgb(255,255,255)">modelo</span></div>

<div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:9.600000381469727px;background-color:rgb(255,255,255)"><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:9.600000381469727px;background-color:rgb(255,255,255)">veja que os resultados estão muito fora. mas deveriam ser os mesmos, como proceder?</span></div>