[R] Help quadratic plateau

John Kane jrkrideau at inbox.com
Sat Dec 12 13:25:33 CET 2015


Please have a look at
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and/or http://adv-r.had.co.nz/Reproducibility.html

It appears that you posted in HTML and the results are very close to unreadable.

Please resend in plain text. 

John Kane
Kingston ON Canada


> -----Original Message-----
> From: brunu_higa at hotmail.com
> Sent: Fri, 11 Dec 2015 13:32:41 -0200
> To: r-help at r-project.org
> Subject: [R] Help quadratic plateau
> 
> i need to do a quadratic plateau. I saw the code and try to put my datas,
> but i had some errors.
> This is my code ,
> for (mun in 1:dm[1]){  # for (mun in 8:dm[1]){    if(nu[mun]>= nmin) {
> y1=arquivov[mun,ncv[mun]:27]      vy = as.numeric(y1)
> x=seq(1:nu[mun])
>       cr=lm(vy~x+I(x^2))      ca_q[mun]=cr$coefficients[[1]]
> cl_q[mun]=cr$coefficients[[2]]      cq_q[mun]=cr$coefficients[[3]]
> alpha_q=as.numeric(ca_q[mun])      beta_q=as.numeric(cl_q[mun])
> gamma_q=as.numeric(cq_q[mun])             fm <- nls(vy ~ Mean(x, alpha,
> beta, gamma), start=list(alpha=alpha_q, beta=beta_q,
> gamma=gamma_q),control = list(maxiter = dm[1]))       fm      summary(fm)
> plot(vy ~ x)      lines(fitted(fm) ~ x)      with(as.list(coef(fm)),
> abline(v = -beta/(2 * gamma)))
>     }    else{          }}
>> vy [1]  77.25989  58.00000  58.00000  58.00000 109.68317  58.00000
>> 80.00000  80.00000  71.33333  69.66667  68.00000  65.33333[13]  58.00000
>> 57.00000  57.00000  57.00000  57.00000  67.00000> alpha_q[1] 67.69373>
>> beta_q[1] 1.321098> gamma_q[1] -0.1129059
> 
> 
> 
> Error in nls(vy ~ Mean(x, alpha, beta, gamma), start = list(alpha =
> alpha_q,  :   singular gradient
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!



More information about the R-help mailing list