Werner Wernersen
2009-Aug-06 11:53 UTC
[R] solving system of equations involving non-linearities
Hi, I would appreciate if someone could help me on track with this problem. I want to compute some parameters from a system of equations given a number of sample observations. The system looks like this: sum_i( A+b_i>0 & A+b_i>C+d_i) = x sum_i( C+d_i>0 & C+d_i>A+b_i) = y sum_i( exp(E+f_i) * ( A+b_i>0 & A+b_i>C+d_i) = z A, C, E are free variables while the other letters represent values given from sample observations. The equations involve counts of the number of fulfilled conditions and therefore non-linearities. Furthermore, since I have many observations i, the equations will unlikely hold exactly and solving will require some closeness measure like the sum of the squared deviations or so. Is there any function in R suitable for solving this problem? Thanks so much for your help, Werner
Ravi Varadhan
2009-Aug-06 14:29 UTC
[R] solving system of equations involving non-linearities
You have two options: 1. The `BBsolve' function in the "BB" package to solve this system of 3 equations. 2. Try `nleqslv' function in the "nleqslv" package. These would work even if the residual is not zero. Hope this helps, Ravi. ____________________________________________________________________ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvaradhan at jhmi.edu ----- Original Message ----- From: Werner Wernersen <pensterfuzzer at yahoo.de> Date: Thursday, August 6, 2009 7:56 am Subject: [R] solving system of equations involving non-linearities To: r-help at stat.math.ethz.ch> Hi, > > I would appreciate if someone could help me on track with this problem. > > I want to compute some parameters from a system of equations given a > number of sample observations. The system looks like this: > > sum_i( A+b_i>0 & A+b_i>C+d_i) = x > sum_i( C+d_i>0 & C+d_i>A+b_i) = y > sum_i( exp(E+f_i) * ( A+b_i>0 & A+b_i>C+d_i) = z > > A, C, E are free variables while the other letters represent values > given from sample observations. The equations involve counts of the > number of fulfilled conditions and therefore non-linearities. > Furthermore, since I have many observations i, the equations will > unlikely hold exactly and solving will require some closeness measure > like the sum of the squared deviations or so. > > Is there any function in R suitable for solving this problem? > > Thanks so much for your help, > Werner > > > > > > ______________________________________________ > R-help at r-project.org mailing list > > PLEASE do read the posting guide > and provide commented, minimal, self-contained, reproducible code.