[R] R in rearranging equations
Hi, can anyone tell me if R can be used to rearrange very complicated equations in terms of one of the variables? I have: dx/dt = a*b*m*y*(1-x)-r*x and, having set: dy/dx = 0, need to rearrange in terms of x. The problem I have is that I don't know how to rearrange equations when the variables are not yet defined (I get messages warning me that x etc can't be found). I'm not sure if R can actually do this (though I know programs like Maxima can) but ideally the solution we get should be in R. I am also aware that this isn't difficult to solve by hand, but the remaining equations I have to work through have up to double the number of variables. Any help will be appreciated! Stenort -- View this message in context: http://www.nabble.com/R-in-rearranging-equations-tp24461619p24461619.html Sent from the R help mailing list archive at Nabble.com. __ 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.
[R] Non-negative solutions to complicated equations
Hi all, I have a system of 3 equations with many defined parameters and 3 variables I need to find solutions to. I actually know the solutions I'm aiming for (.0061,0.287,0.070) but R tends to give me (0,0,0). I tried the "BB" package but don't really follow how to refine my solutions from that; these are wrong so far. Here's my code from trying that: > f<-function(x){ + x1<-x[1] + x2<-x[2] + x3<-x[3] + + F<-rep(NA,3) + F[1]<-(0.075*x3+0,175*x2)*0.065*exp(-0.03*25) + F[2]<-(x3/0.075)*((1/50)/(0.065*5.125*0.872214*(1-(x3*(56/25-0.075) + F[3]<-(x2/0.175)*((1/70)/(0.065*0.366*0.872214*(1-(x2*(66/35-0.175) + return(F) + } > p0<-c(0.1,0.1,0.1) > dfsane(par=p0,fn=f,control=list(maxit=3000)) I have substituted estimated values for all the parameters into the above equations. Thanks -- View this message in context: http://www.nabble.com/Non-negative-solutions-to-complicated-equations-tp24622867p24622867.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Non-negative solutions to complicated equations
Hi Ravi, apologies for the typos. I believe these have been corrected, please see the new version of the question on the forum page Ravi Varadhan wrote: > > Hi, > > I found at least 2 typos in your function. Can you check your equations > carefully to make sure that they are correct and then send me a > reproducible > version of the code that I can cut and paste into my R session? > > Ravi. > > > > --- > > Ravi Varadhan, Ph.D. > > Assistant Professor, The Center on Aging and Health > > Division of Geriatric Medicine and Gerontology > > Johns Hopkins University > > Ph: (410) 502-2619 > > Fax: (410) 614-9625 > > Email: rvarad...@jhmi.edu > > Webpage: > http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h > tml > > > > > > > > -----Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On > Behalf Of stenort > Sent: Thursday, July 23, 2009 6:08 AM > To: r-help@r-project.org > Subject: [R] Non-negative solutions to complicated equations > > > Hi all, > I have a system of 3 equations with many defined parameters and 3 > variables > I need to find solutions to. I actually know the solutions I'm aiming for > (0.07,0.287,0.0061) but R tends to give me (0,0,0). > I tried the "BB" package but don't really follow how to refine my > solutions > from that; these are wrong so far. Here's my code from trying that: >> f<-function(x){ > + x1<-x[1] > + x2<-x[2] > + x3<-x[3] > + > + F<-rep(NA,3) > + F[1]<-(0.075*x3+0,175*x2)*0.065*exp(-0.03*25) > + F[2]<-(x2/0.075)*((1/50)/(0.065*0.5.125*0.872214*(1-(x2*(56/25-0.1 > + 75) > + F[3]<-(x3/0.175)*((1/70)/(0.065*0.366*0.872214*(1-(x3*(66/35-0.075 > + ) > + return(F) > + } >> p0<-c(0.1,0.1,0.1) >> dfsane(par=p0,fn=f,control=list(maxit=3000)) > > > I have substituted estimated values for all the parameters into the above > equations. > Thanks > -- > View this message in context: > http://www.nabble.com/Non-negative-solutions-to-complicated-equations-tp2462 > 2867p24622867.html > Sent from the R help mailing list archive at Nabble.com. > > __ > 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. > > __ > 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. > > -- View this message in context: http://www.nabble.com/Non-negative-solutions-to-complicated-equations-tp24622867p24628265.html Sent from the R help mailing list archive at Nabble.com. __ 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.
[R] Problem runnin rSymPy
Hi all, I'm having major difficulty using the rSymPy package this week, but I have used it without problems before now. Here is an example of what's happening: > library(rSymPy) Loading required package: rJava > sympy("var('a b c d')") Error in .jcheck() : No running detected. Maybe .jinit() would help. And I have no idea how to fix it. I Have tried re-installing but that doesn't seem to work either. Any help would be great, thanks! -- View this message in context: http://www.nabble.com/Problem-runnin-rSymPy-tp24697166p24697166.html Sent from the R help mailing list archive at Nabble.com. __ 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.