Re: [R] Problem defining a system of odes as a C library with lsoda
I think the problem is in odesolve (something I thought I'd already fixed). I don't have a 64-bit system to test on, so could you try these changes and let me know (offline) if they fix the problem? There is a type mismatch in odesolve; I want to know if that is the cause of your problem. In any case, I'll get an updated version of odesolve on CRAN ASAP. in mymod.c: change the line mymod(void(* odeparms)(int *, double *)) to mymod(void(* odeparms)(long int *, double *)) and the line int N=3; to long int N=3; Woody -Original Message- From: Dylan Childs [EMAIL PROTECTED] Sent: Nov 6, 2005 2:39 PM To: r-help@stat.math.ethz.ch Subject: [R] Problem defining a system of odes as a C library with lsoda I have been trying to make use of the odesolve library on my university's Linux grid - currently R version 2.0.1 is installed and the system runs 64-bit Scientific Linux based on Redhat. ... [deleted] However, the call to lsoda fails with the following error: Error in lsoda(c(1, 0, 0), times, myderivs, parms, rtol = 1e-04, atol = my.atol, : Confusion over the length of parms ... [deleted] Dr. Dylan Z. Childs Department of Animal and Plant Sciences, University of Sheffield, Sheffield, S10 2TN, UK. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Woodrow Setzer National Center for Computational Toxicology US Environmental Protection Agency Research Triangle Park, NC 27711 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Fitting of Non-Linear Diff Equations and Parameter Estimation
Raja Jayaraman rajnmsu79 at gmail.com writes: Hello Everybody, I am running R 2.2.0 with Windows XP i am trying to fit nonlinear differential equation to data sets which looks like this: [SNIP] and i need to fit these data to the following diff equation: dNdt=a*N-b*N*C, dCdt=N^2, Where a=birth rate, b=death rate and N= Current count, C= Cumulative Count. i need to fit the differential equation, solve and obtain parameters a,b. can someone help with this, Thanks Raj Try looking at the package odesolve for solving the ode system. Woody Setzer National Center for Computational Toxicology US EPA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] solving ODE's in matrix form with lsoda()
Jorge, If you'll send me details of the error messages, I'll see what I can do to help. I notice in your posting there is a missing ')' in the next to last line of model, but no error message; I don't suppose that could have anything to do with it? (send the details to my work email: setzer.woodrow AT epa DOT gov). In general, I'm willing to help people trying to use lsoda, but it is generally better to email me directly (as the package author, as recommended in the posting guide) rather than through r-help. Woody Setzer Woodrow Setzer National Center for Computational Toxicology US Environmental Protection Agency Research Triangle Park, NC 27711 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] solving ODE's in matrix form with lsoda()
Just a followup. I suppose you meant something like this: library(odesolve) y - c(10, 20, 10, 20) parms - matrix(c(0.05, 0.1, 0.2, 0.05, 0.1, 0.2), nc=3, byrow=T) model - function(times, y, parms) { P - y[1:2] V - y[3:4] beta - parms[,1] mu - parms[,2] r - parms[,3] dPdT - beta*P*V - mu*P dVdt - r*V - beta*P*V list(c(dPdT, dVdt)) } out - lsoda(y, times=(0:100), model, parms) which gives the following output (for the first 8 time units) and no errors or warnings: source(C:/home/testode.R) out time 12 34 [1,]0 10.000 20.0 10. 2.00e+01 [2,]1 13.7603737 33.615668238 6.72208454 6.079882e+00 [3,]2 16.1560654 35.516702438 3.85780113 1.275331e+00 [4,]3 16.8730079 33.195852918 2.05089685 2.778086e-01 [5,]4 16.4682671 30.260712324 1.08485347 6.942984e-02 [6,]5 15.5186874 27.434895458 0.59474861 2.006117e-02 [7,]6 14.3655789 24.839030740 0.34399530 6.638867e-03 [8,]7 13.1757074 22.479990536 0.21106101 2.486824e-03 [9,]8 12.0240882 20.342411249 0.13733214 1.042244e-03 Perhaps you have some errors in your model code? Woody Woodrow Setzer National Center for Computational Toxicology US Environmental Protection Agency Research Triangle Park, NC 27711 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] input line length in Sweave
I am having trouble in Sweave with input line lengths. For example, I may have in my input file the chunk = BrainSections - levels(AggData$sctn)[grep( (^BRAIN)|(^WHOLEBRAIN)|(LEFT HEMISPHERE)| (HALFBRAIN), levels(AggData$sctn))] @ This is translated in the tex file: \begin{Sinput} BrainSections - levels(AggData$sctn)[grep((^BRAIN)|(^WHOLEBRAIN)|(LEFT HEMISPHERE)| (HALFBRAIN), + levels(AggData$sctn))] \end{Sinput} The problem is that the line produced is too long. I read the answer to the Sweave FAQ question 13 (How can I change the line length of S input and output?) to mean that options(width) controls both input and output; however, the first code chunk in the above example contains = options(width=66) @ Is there a way to get Sweave to wrap long input lines better, or get it to use my own formatting of the input? I realize I can edit the output tex file, but that is impractical in my application (too many). I am using R version 2.0.1 Patched (2005-01-26) on a Linux system (so, I suppose one possible answer is that this is fixed in 2.1.0; I cannot switch right now). Woodrow Setzer National Center for Computational Toxicology US Environmental Protection Agency Research Triangle Park, NC 27711 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ugly loop
Almost there; you need the transpose of v, since Bill originally had columns changing faster: e.g. x - pt$x[t(ver)] -Original Message- From: Marc Schwartz [EMAIL PROTECTED] Sent: Apr 22, 2005 9:17 AM To: Bill Simpson [EMAIL PROTECTED] Cc: R-Help r-help@stat.math.ethz.ch Subject: Re: [R] ugly loop On Fri, 2005-04-22 at 08:58 -0400, Bill Simpson wrote: The following code is slow and ugly: count-0 for(i in 1:nrow(ver)) for(j in 1:ncol(ver)) { count-count+1 x[count]-pt$x[ver[i,j]] y[count]-pt$y[ver[i,j]] z[count]-pt$z[ver[i,j]] } Please help me make it better. Thanks! The following should work: ver - matrix(sample(1:16, 16), ncol = 4) pt - data.frame(x = sample(1:16, 16), + y = sample(1:16, 16), + z = sample(1:16, 16)) ver [,1] [,2] [,3] [,4] [1,]895 13 [2,] 14 161 10 [3,] 122 117 [4,]634 15 pt x y z 1 6 15 15 2 9 2 3 3 11 1 5 4 14 4 10 5 13 7 14 6 1 14 7 7 15 10 4 8 10 5 12 9 4 12 2 10 8 8 13 11 16 11 1 12 7 13 9 13 2 16 11 14 3 9 16 15 5 6 8 16 12 3 6 x - pt$x[ver] y - pt$y[ver] z - pt$z[ver] x [1] 10 3 7 1 4 12 9 11 13 6 16 14 2 8 15 5 y [1] 5 9 13 14 12 3 2 1 7 15 11 4 16 8 10 6 z [1] 12 16 9 7 2 6 3 5 14 15 1 10 11 13 4 8 Keep in mind that a matrix is a vector with dims, so you can fill a vector from the matrix simply by doing the indexing with a single value, which will do the fill indexed column by column. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html