Hi I would like to solve a system of nonlinear equations below using dfsane 
function
 
mn <- 142.36; vr <- 9335.69 ; sk <- 0.81;  kur <- 0.25
test_fn <- function(p) 
{    f <- rep(NA, length(p))
  
  f[1] <- p[1]*(p [2]+p[3])- mn
  f[2] <- - vr + 2*p[1]*p[2]*p[3]*(p[4]-1)+p[1]*(p[2]+p[3])^2 
  f[3] <- - sk + (p[1]*(p [2]+p[3])^3*(p[1]+1)*(p[1]+2)-6*p[1]*p[2]*p[3]*(p[2]+ 
p[3])*(1- p[4])*( p 
[1]+1))/(p[1]*(p[2]+p[3])^2*(p[2]+p[3])-2*p[1]*p[2]*p[3]*(1-p[4]))^1.5 
  f[4] <- - kur + (p[1]*(p[2]+p[3])^4*(p[1]+3)*(p[1]+2)*(p[1]+1) 
-12*p[1]*p[2]*p[3]*(1-p[4])*(p[2]+p[3])^2*(p[1]+2)*(p[1]+1)+12*p[1]*p[2]^2*p[3]^2*(1-p[4])^2*(p[1]+1))/(p[1]*(p[2]+p[3])^2*(p[2]+p[3])-2*p[1]*p[2]*p[3]*(1-p[4]))^2
 
  f
  }
 
p0 <- c(1.3, 50,60,0.8)
dfsane(par=p0, fn = test_fn, control=list(trace=FALSE))
 
and got this output
 
> dfsane(par=p0, fn = test_fn, control=list(trace=FALSE))
$par
[1]  2.1327328  6.3213205 60.3580481  0.9097743
$residual
[1] 0.4251058
$fn.reduction
[1] 4833.46
$feval
[1] 140
$iter
[1] 137
$convergence
[1] 5
$message
[1] "Lack of improvement in objective function"
 
My question is how to improve the solution if I want to put some constraint for 
the parameters such as p[1], p[2] and p[3] > 0.0001 and -1<p[4]<1.
 
 
Regards,
 
Roslina




      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to