Displaying 20 results from an estimated 3000 matches similar to: "optim() argument scoping: passing parameter values into user's subfunction"
2006 Apr 20
2
nlminb( ) : one compartment open PK model
All,
I have been able to successfully use the optim( ) function with
"L-BFGS-B" to find reasonable parameters for a one-compartment
open pharmacokinetic model. My loss function in this case was
squared error, and I made no assumptions about the distribution
of the plasma values. The model appeared to fit pretty well.
Out of curiosity, I decided to try to use nlminb( ) applied to
a
2007 Apr 05
1
Plotting multiple curves with lattice graphs
Hi List,
I would like to plot multiple curves (parametric
density curves) in one plot.
For example:
# parameters for three normal density curves
parms =
data.frame(ID=c(1,2,3),mu=c(50,55,60),sigma=c(10,12,15))
# I can easily draw three normal density curves using
curve():
curve(dnorm(x,mean=parms$mu[1],sd=parms$sigma[1]),from=0,
to=150, ylab="density", col="red")
2005 Jul 19
2
Michaelis-menten equation
Dear R users:
I encountered difficulties in michaelis-menten equation. I found
that when I use right model definiens, I got wrong Km vlaue,
and I got right Km value when i use wrong model definiens.
The value of Vd and Vmax are correct in these two models.
#-----right model definiens--------
PKindex<-data.frame(time=c(0,1,2,4,6,8,10,12,16,20,24),
2006 Aug 08
1
Fitting data with optim or nls--different time scales
Hi,
I have a system of ODE's I can solve with lsoda.
Model=function(t,x,parms)
{
#parameter definitions
lambda=parms[1]; beta=parms[2];
d = parms[3]; delta = parms[4];
p=parms[5]; c=parms[6]
xdot[1] = lambda - (d*x[1])- (beta*x[3]*x[1])
xdot[2] = (beta*x[3]*x[1]) - (delta*x[2])
xdot[3] = (p*x[2]) - (c*x[3])
return(list(xdot))
}
I want
2007 Mar 03
3
How to convert List object to function arguments?
Dear R gurus,
I have a function "goftests" that receives the following arguments:
* a vector "x" of data values;
* a distribution name "dist";
* the dots list ("...") containing a list a parameters to pass to CDF
function;
and calls several goodness-of-fit tests on the given data values against
the given distribution.
That is:
##### BEGIN CODE SNIP #####
2013 Feb 21
1
using and event in deSolve
Hi All
Having been pointed the use of events and roots in deSolve, I was able to
implement the Izchikevich model of spiking neurons. However, I'm not too
sure of defining the event. The deSolve documentation says:
An event is triggered when the ball hits the ground (height = 0) Then
velocity (y2) is reversed
and reduced by 10 percent. The root function, y[1] = 0, triggers the event:
>
2006 Jan 20
1
Passing variable arguments to functions
Hi,
Is there another way to pass arguments via a vector to arbitrary functions
as in the following code example without using a series of if else
statements?
f <- test(func, x, parms, fargs1, fargs2, ...)
{
# parms is a vector of parameters to func.
# ... is for use by f, not by func.
n <- length(parms)
if (n == 0) y <- func(x)
else if (n == 1) y <- func(x,
2006 Mar 02
1
Named parameters in optim()
If I name the elements of the vector of initial values passed to
optim(), then it attaches the names to the final result, e.g.
> f <- function(parms) (parms[1]-1)^2+(parms[2]-2)^2
> optim(c(x=3,y=4), f)
$par
x y
0.9999635 2.0003241
$value
[1] 1.063637e-07
$counts
function gradient
65 NA
$convergence
[1] 0
$message
NULL
However, the vector that gets
2007 Oct 23
1
How to avoid the NaN errors in dnbinom?
Hi, The code below is giving me this error message:
Error in while (err > eps) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In dnbinom(x, size, prob, log) : NaNs produced
2: In dnbinom(x, size, prob, log) : NaNs produced
I know from the help files that for dnbinom "Invalid size or prob will
result in return value NaN, with a warning", but I am not able
2001 Aug 12
2
rpart 3.1.0 bug?
I just updated rpart to the latest version (3.1.0). There are a number of
changes between this and previous versions, and some of the code I've been
using with earlier versions (e.g. 3.0.2) no longer work.
Here is a simple illustration of a problem I'm having with xpred.rpart.
iris.test.rpart<-rpart(iris$Species~., data=iris[,1:4],
parms=list(prior=c(0.5,0.25, 0.25)))
+ )
>
2013 Feb 18
1
attempt to apply non-function
Hi All
I am getting the above mentioned error when I run the code below. I don't
know why because I have implemented the function and I'm calling the
function with a parameter. I'm obviously missing the plot ... Can someone
perhaps point out the error of my ways?
Error:
> out<-ode(y=init, times=times, func=G1999, parms=parms, method="lsoda")
Error in m_Na(v) : attempt
2017 Sep 22
0
update numeric values of list with new values...
Solved it:
test <- list(a=1,b=2,c=3)
new <- c(4,5,6)
hold <- as.list(new)
updated_test <- replace(test,c(1:3),hold)
$a
[1] 4
$b
[1] 5
$c
[1] 6
mean.parms <- as.list(mean.parms)
mm.parms <- replace(far.parms,c(1:length(far.parms)),mean.parms)
On 9/22/2017 10:34 AM, Evan Cooch wrote:
> Suppose I have the following:
>
> test <- list(a=1,b=2,c=3)
>
> I
2002 Feb 01
1
typo and user-proofing in odesolve() (PR#1295)
A couple of minor points about the odesolve package
(which I am otherwise enjoying very much):
1. "scalar" is misspelled as "scaler" in the definitions of
the rtol and atol parameters
2. it is possible to crash R by doing something dumb, e.g
failing to read the documentation carefully enough and (a)
returning only a vector of derivatives and not a list of
(derivatives,
2005 Oct 25
2
solving ODE's in matrix form with lsoda()
Hello there,
Suppose you want to solve the following system of ODE's (a simple
Lotka-Volterra predator prey model)
dP/dt = beta*P*V - mu*P
dV/dt = r*V - beta*P*V
where P and V are the numbers of predators and prey. Now, this is
easy to do, but suppose you have a system of equations like this,
dP1/dt = beta1*P1*V1 - mu1*P1
dP2/dt = beta2*P2*V2 - mu2*P2
dV1/dt = r1*V1 - beta1*P1*V1
2008 Nov 21
1
lsoda warning "too much accuracy requested"
Dear list -
Does anyone have any ideas / comments about why I am receiving the following
warning when I run lsoda:
1: lsoda-- at t (=r1), too much accuracy requested in: lsoda(start, times,
model, parms)
2: for precision of machine.. see tolsf (=r2) in: lsoda(start, times,
model, parms)
I have tried changing both rtol and atol but without success. I saw the
thread in the
2012 Jan 30
2
ode() tries to allocate an absurd amount of memory
Hi there R-helpers:
I'm having problems with the function ode() found in the package deSolve.
It seems that when my state variables are too numerous (>33000 elements),
the function throws the following error:
Error in vode(y, times, func, parms, ...) :
cannot allocate memory block of size 137438953456.0 Gb
In addition: Warning message:
In vode(y, times, func, parms, ...) : NAs
2011 Mar 19
2
problem running a function
Dear people,
I'm trying to do some analysis of a data using the models by Royle & Donazio
in their fantastic book, particular the following function:
http://www.mbr-pwrc.usgs.gov/pubanalysis/roylebook/panel4pt1.fn
that applied to my data and in the console is as follows:
> `desman.y` <- structure(c(3L,4L,3L,2L,1L), .Names = c("1", "2", "3",
2009 Sep 24
1
Fw: Re: Multiple Normal Curves
Sorry about the subject
--- On Thu, 24/9/09, KABELI MEFANE <kabelimefane@yahoo.co.uk> wrote:
From: KABELI MEFANE <kabelimefane@yahoo.co.uk>
Subject: Re: [R] Multiply Normal Curves
To: R-help@r-project.org
Date: Thursday, 24 September, 2009, 11:48 AM
R -helpers
i have been trying to do this problem without must success,i managed to do a graph for x, but it is not what i want to
2011 Apr 28
1
DLSODA error
Dear R-users,
I'm running an MLE procedure where some ODEs are solved for each iteration
in the maximization process. I use mle2 for the Maximum likelihood and
deSolve for the ODEs.
The problem is that somewhere along the way the ODE solver crashes and I get
the following error message:
DLSODA- Warning..Internal T (=R1) and H (=R2)
are
such that in the machine, T + H = T on the next
2017 Sep 22
1
update numeric values of list with new values...
Well, that's a bit like driving from Boston to New York by way of Chicago.
See ?structure
test <- list(a=1,b=2,c=3)
new <- c(4,5,6)
test.new <- structure(as.list(new), names=names(test))
test.new
$a
[1] 4
$b
[1] 5
$c
[1] 6
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka