An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111009/f3e7e689/attachment.pl>
Finding solution
4 messages · Christofer Bogaso, Peter Dalgaard, Bert Gunter +1 more
On Oct 9, 2011, at 14:02 , Bogaso Christofer wrote:
Dear all, I have a system of simultaneous equations with 2 unknowns as follows: x*y + (1-x) = 0.05 x*(y - .5)^2 + (1-x)*0.6 = 0.56^2 Ofcourse I can do it manually however wondering whether there is any direct way in R available to get the solution of this system?
Not really (can't vouch for all 3000+ packages, though...) You can sometimes get away with converting to a minimization problem:
f <- function(xy,x=xy[1],y=xy[2])(x*y + (1-x) - 0.05)^2+(x*(y - .5)^2 + (1-x)*0.6 - 0.56^2)^2 optim(par=c(0,0),f,method="BFGS")$par
[1] 0.91674574 -0.03627402
$value
[1] 5.351777e-13
$counts
function gradient
39 13
$convergence
[1] 0
$message
NULL
Notice that there is some risk of falling into a local minimum which has nothing to do with the solution. Always check that the minimum actually comes out as zero.
Thanks and regards, [[alternative HTML version deleted]]
______________________________________________ R-help at 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.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111009/68d4d22b/attachment.pl>
1 day later
Bogaso wrote:
Dear all, I have a system of simultaneous equations with 2 unknowns as follows: x*y + (1-x) = 0.05 x*(y - .5)^2 + (1-x)*0.6 = 0.56^2 Ofcourse I can do it manually however wondering whether there is any direct way in R available to get the solution of this system?
Look at the Task view Optimization. Two packages for solving systems of nonlinear equations are available: nleqslv and BB. Berend -- View this message in context: http://r.789695.n4.nabble.com/Finding-solution-tp3887148p3892804.html Sent from the R help mailing list archive at Nabble.com.