<div dir="ltr"><div><div>Desculpe Fernando, seguem os dados:<br><br>> dput(file)<br>structure(list(x = 0:372, y = c(1.552918816, 1.177870257, 0.728582521, <br>0.754977859, 1.014857186, 0.952781237, 0.92487764, 0.930448803, <br>
0.825743421, 1.061320976, 0.778891815, 0.987829557, 0.839076467, <br>
1.035174095, 1.026961486, 1.180269616, 0.897432732, 0.750135342, <br>0.713731659, 0.986891474, 0.814066753, 0.838472048, 0.819105964, <br>0.913483671, 1.134245404, 0.790984967, 0.785299927, 0.795018406, <br>0.839324923, 0.735915178, 0.593269981, 0.923184631, 1.018998131, <br>
0.803540789, 0.80479661, 0.72999522, 0.699068733, 0.618802888, <br>0.815272405, 0.803152178, 0.701841573, 0.734495312, 0.73549551, <br>0.903936404, 0.99491774, 0.990528339, 0.752979853, 0.708288706, <br>0.822200524, 0.787724769, 0.852584706, 0.741692593, 0.833094394, <br>
0.835140976, 0.843551076, 0.789762592, 0.71986185, 0.641050114, <br>0.800506751, 0.884314696, 0.987518987, 0.768463801, 0.866236287, <br>1.065961223, 0.806744447, 0.766739735, 0.751533707, 0.696793602, <br>0.936172067, 0.998768819, 0.790549371, 1.112424217, 0.727549674, <br>
0.91716513, 0.785049082, 0.835587721, 0.673062803, 0.849652599, <br>0.849677285, 0.792995714, 0.817868458, 0.790538222, 0.718977121, <br>0.969363333, 0.821173251, 0.682762966, 0.547801611, 0.864380029, <br>0.637068436, 0.716060144, 0.925191396, 0.82309242, 1.217327091, <br>
0.950335691, 0.825029108, 0.858161444, 0.620884509, 0.743739175, <br>0.782014247, 0.815065357, 0.746548647, 0.778370215, 0.747050338, <br>0.85151045, 0.853198681, 0.741675073, 0.980756505, 0.78396288, <br>0.87737065, 0.76027349, 0.814334321, 0.955472852, 0.797915475, <br>
0.64547774, 0.703556084, 1.160420157, 0.697551714, 0.680614453, <br>0.87038201, 0.885639002, 0.931712588, 0.634435751, 0.771353703, <br>0.723837157, 0.864745547, 0.683628583, 0.677707032, 0.625280281, <br>0.780408834, 0.740849273, 0.816243934, 0.743649986, 0.767603759, <br>
0.788182662, 0.638866562, 0.749819197, 0.61128548, 0.699447788, <br>0.742390183, 0.654970059, 0.621842501, 0.841482993, 0.71000242, <br>0.719206466, 0.651004308, 0.657988171, 0.659939193, 0.590479621, <br>0.916040704, 0.735814044, 0.780472541, 0.690410176, 0.852647617, <br>
0.663802217, 0.774593992, 0.679669203, 0.841208257, 0.644216344, <br>0.790331175, 0.655288593, 0.598600651, 0.850198089, 0.639451072, <br>0.790941168, 0.56980038, 0.751766237, 0.800986145, 0.661843231, <br>0.699207295, 0.729910808, 0.713261821, 0.658346522, 0.698184004, <br>
0.725423458, 0.754622693, 0.681435475, 0.471715731, 0.705996852, <br>0.570707406, 0.660579447, 0.738280295, 0.68915117, 0.568583579, <br>0.61153553, 1.02975742, 0.661527086, 0.567946511, 0.543164549, <br>0.702431658, 0.509399922, 0.511034002, 0.683268639, 0.743713692, <br>
0.583393828, 0.599969552, 0.722769271, 0.562765552, 0.596352596, <br>0.640454455, 0.610732823, 0.734572557, 0.644839078, 0.714663372, <br>0.679286961, 0.669174296, 0.639958338, 0.732628702, 0.521852221, <br>0.591436817, 0.622606983, 0.592701398, 0.584728486, 0.808503552, <br>
0.557689709, 0.683618231, 0.671007461, 0.612336643, 0.867552629, <br>0.71857975, 0.581004025, 0.57724771, 0.65777316, 0.53544089, <br>0.81379122, 0.607679673, 0.561732705, 0.583045033, 0.642250988, <br>0.612925931, 0.619729026, 0.655734541, 0.674082112, 1.199682684, <br>
0.565012811, 0.59800977, 0.839234937, 0.806546956, 0.58329986, <br>0.673788265, 0.627473389, 0.69975597, 0.795051056, 0.606857855, <br>0.767389545, 0.691856322, 0.637890254, 0.615875558, 0.527046717, <br>0.69097876, 0.543992738, 0.721710941, 0.541890412, 0.623967124, <br>
0.765809615, 0.697307239, 0.648002123, 0.695423905, 0.58107251, <br>0.663865924, 0.676050654, 0.576674348, 0.75346084, 0.684342896, <br>0.692429683, 0.749339007, 0.681089865, 0.694518471, 0.61196794, <br>0.704916225, 0.752186703, 0.973376864, 0.884314696, 0.892780539, <br>
0.644331016, 0.810050036, 0.659620659, 0.875652955, 0.739896856, <br>1.050720157, 0.701284935, 0.939293702, 1.023670231, 0.841587313, <br>0.925278197, 0.780156396, 0.887787516, 0.823984315, 0.985433384, <br>0.894676614, 0.83659827, 0.96598687, 0.787544001, 0.764039361, <br>
0.898974437, 0.861125405, 0.933638924, 0.86870652, 0.861905018, <br>0.992322483, 1.381073587, 0.899413218, 1.055144597, 1.048128881, <br>0.947446586, 0.816658028, 0.85940532, 0.972548675, 0.875777979, <br>0.974942459, 0.790028568, 0.71600679, 0.792859541, 0.889052096, <br>
0.966600048, 0.89341283, 0.958572986, 1.020383755, 0.76941144, <br>1.110825175, 0.843357567, 1.120730793, 0.889411244, 0.999906782, <br>1.02455496, 1.051479065, 1.095087992, 0.923559705, 1.128647961, <br>1.313131831, 0.915153587, 1.058557692, 0.853607998, 0.949029701, <br>
0.969001, 1.091106314, 1.033087696, 0.957625347, 0.90042775, <br>1.315533579, 0.86301272, 0.970012346, 0.996177543, 0.872745533, <br>1.169665612, 1.130164184, 1.12352832, 1.059315803, 1.008628249, <br>1.296573626, 1.045684131, 1.193302444, 1.181863084, 1.096267365, <br>
1.240134937, 1.16928576, 1.233877333, 1.092117661, 1.15841578, <br>1.500965885, 1.229769834, 1.438586533, 1.346249834, 1.459758706, <br>1.542678738, 1.583001188, 1.512468952, 1.330386034, 1.215865019, <br>1.642284388, 1.588310357, 1.602909577, 1.479793712, 1.527826283<br>
)), .Names = c("x", "y"), class = "data.frame", row.names = c(NA, <br>-373L))<br><br><br><br><br>Boa Tarde,<br><br>Eu estou fazendo um fit nâo linear com um polinômio. Porém, a fiunção que eu estou usando : <br>
y=
- {[a*(x^(2*n)) + b]/[(x-186)(x+186)]} apresenta duas assíntotas em +-
186 e por isso dá um erro no fit: Erro em numericDeriv(form[[3l]],
names(ind), env): obtido valor faltante ou infinito quando avaliando o
modelo.<br>Pelo que eu entendi, o motivo é que a derivada também possui assíntotas nestes mesmo postos e daí na função vai para o infinito.<br>Eu
fiz D( (-(a*(x^(2*n)) + b)/((x-186)(x+186))), "x") e a mensagem de erro
foi: Erro em x^(2*n)argumento não numérico para operador binário. Aí eu
pensei que era por causa do n e deixei então só o x^2 e o erro foi o
mesmo. Eu procurei na internet e não achei nada que explicasse o que
está querendo dizer. O que seria um operador binário? <br><br>Voltando
às assintotas, eu achei uma função chamada ‘NLSstAsymptotic(xy)’ que é
para assintotas verticais em gráficos mas eu tentei emplementá-la e nâo
deu certo. Tem outra função que eu possa usar para que o fit seja feito
mesmo que a função usada para o fit apresente singularidades?<br></div><br></div>Abaixo está o código:<br><br><div><br><br>file <- read.table(file="/Users/bau/Desktop/teste/DISparam.txt", col.names=c('x','y'))<br>
plot(x=file$x, y=file$y, xlab='Valores de x', ylab='Valores de y', lwd=0.5,)<br><br><br>dados <- data.frame(x=file$x,y=file$y)<br><br>#chute inicial<br>guess <- list(a=1, b=3, n=3)<br><br># funcao usada para o fit #<br>
func <- function(x,n, a, b){<br> y <- (-(a*(x^(2*n)) +b)/((x-186)*(x+186))) <br> return(y)<br>}<br><br>#executa o fit e armazena resultado na variavel 'fit'<br>fit <- nls(y ~ func(x,n,a,b), data=dados, start=guess, lower=-200, upper=200)<br>
fit<br>summary(fit)<br>#gera valores de y a partir do resultado do fit, para plotar<br>#o resultado no mesmo grafico que os dados<br>yfit <- predict(fit)<br>#plota a linha do fit<br>lines(dados$x, yfit, col='blue',lwd=2)<br>
#carrega os parametros<br>param <- coef(fit)<br><br></div><div>Obrigada,<br><br></div>Michelle</div>