Displaying 20 results from an estimated 1000 matches similar to: "how to save output all together"
2012 Nov 26
1
Help on function please
Dear All,
I could use a bit of help here, this function is hard to figure out (for me at least) I have the following so far:
PKindex<-data.frame(Subject=c(1),time=c(1,2,3,4,6,10,12),conc=c(32,28,25,22,18,14,11))
Dose<-200
Tinf <-0.5
defun<- function(time, y, parms) {
dCpdt <- -parms["kel"] * y[1]
list(dCpdt)
}
modfun <- function(time,kel, Vd) {
out <-
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),
2007 Oct 30
2
flexible processing
Hello,
unfortunately, I don't know a better subject. I would like to be very flexible
in how to process my data.
Assume the following dataset:
par1 <- seq(0,1,length.out = 100)
par2 <- seq(1,100)
fac1 <- factor(rep(c("group1", "group2"), each = 50))
fac2 <- factor(rep(c("group3", "group4", "group5", "group6"), each =
2009 Dec 29
2
pass functions and arguments to function
Hi,
I wonder how to pass several functions and their arguments as arguments to
a function. For example, the main function is
f = function(X ) {
process1(X)
...
process2(X)
}
I have a few functions that operate on X, e.g. g1(X, par1), g2(X, par2),
g3(X, par3). par1, par2 and par3 are parameters and of different types. I
would like to pass g1, g2, g3 and their arguments to f and g1,
2006 Feb 08
1
expand.grid without expanding
Dear list,
I've recently came across a problem that I think I've solved and that I wanted
to share with you for two reasons:
- Maybe others come across the same problem.
- Maybe someone has a much simpler solution that wants to share with me ;-)
The problem is as follows: expand.grid() allows you to generate a data.frame
with all combinations of a set of values, e.g.:
>
2007 Dec 19
2
recode based on filter
Hi, I have a data frame DATA, which (simplified of course) looks like this:
know1 = c("Y","N","N","Y","N","N","Y","Y","N")
par1=c(1,4,5,3,3,2,3,3,5)
know2 = c("Y","Y","N","Y","N","N","N","Y","Y")
2011 Apr 07
2
Two functions as parametrs of a function.
Hi R users:
I'm trying to make a function where two of the parameters are
functions, but I don't know how to put each set of parameters for
each function.
What am I missing?
I try this code:
f2<-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){
force(fun1)
force(fun2)
force(n)
p1<-unlist(par1)
p2<-unlist(par2)
force(p1)
force(p2)
2010 Jun 13
1
losing line of mtext when saving to png format
I have a simple graph (oode below) which looks fine on the screen but when
I save it in png format the title (actually the last mtext line) is cut off.
I am pretty sure that I am doing something very stupid but
other than playing around with the png height and width commands which don't seem to help I have no idea of what to look for.
Any suggestions or cures would be appreciated.
Thanks
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
2004 Jan 22
4
Fitting compartmental model with nls and lsoda?
Dear Colleagues,
Our group is also working on implementing the use of R for pharmacokinetic compartmental analysis. Perhaps I have missed something, but
> fit <- nls(noisy ~ lsoda(xstart, time, one.compartment.model, c(K1=0.5, k2=0.5)),
+ data=C1.lsoda,
+ start=list(K1=0.3, k2=0.7),
+ trace=T
+ )
Error in eval(as.name(varName), data) : Object
2009 Jun 16
1
Constrained Optimization, a full example
After a few days of work, I think I nearly have it.
Unfortunately, theta is unchanged after I run this (as a script from a
file). I thought that theta would contain the fitted parameters.
The goal here is to find the least squares fit according to the function
defined as "rss" subject to the constraints defined as ui and ci.
I defined ui and ci to (hopefully) force par2 and par3
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
2008 Apr 09
3
LSODA not accurate when RK4 is; what's going on?
I'm solving the differential equation dy/dx = xy-1 with y(0) = sqrt(pi/2).
This can be used in computing the tail of the normal distribution.
(The actual solution is y(x) = exp(x^2/2) * Integral_x_inf {exp(-t^2/2) dt}
= Integral_0_inf {exp (-xt - t^2/2) dt}. For large x, y ~ 1/x, starting
around x~2.)
I'm testing both lsoda and rk4 from the package odesolve.
rk4 is accurate using step
2003 Nov 05
3
using LSODA in R
R help list subscribers,
I am a new user of R. I am attempting to use R to explore a set of
equations specifying the dynamics of a three trophic level food chain. I
have put together this code for the function that is to be evaluted by
LSODA. My equations Rprime, Cprime, and Pprime are meant to describe the
actual equation of the derivative. When I run LSODA, I do not get the
output that
2005 Jul 27
4
odesolve/lsoda differences on Windows and Mac
Hi -
I am getting different results when I run the numerical integrator
function lsoda (odesolve package) on a Mac and a PC. I am trying to
simulating a system of 10 ODE's with two exogenous pulsed inputs to the
system, and have had reasonably good success with many model parameter
sets. Under some parameter sets, however, the simulations fail on the
Mac (see error message below). The
2009 Dec 06
2
Error in eval(expr, envir, enclos) : object 'N' not found
I'm running an LSODA to generate some graphs, but I need to stop at a certain
point and use those values to generate another LSODA output. This is
working fine, but when I try to run the second LSODA, I get the "Error in
eval(expr, envir, enclos) : object 'N' not found". Any ideas what can be
causing this? I have no object 'N' anywhere in the script. I made an
2005 Nov 22
1
problem with "parse"
Hi there again,
I have a problem with the "parse"-command.
First of all, I show you in a simplified way, what I am trying to do and what "R" answers:
> test
[1] "u.g$par1, u.g$par2"
> mode(test)
[1] "character"
> ausdruck <- parse(text = test)
Error in parse(file, n, text, prompt) : syntax error in "u.g$par1,"
2004 Oct 06
1
Foreign code problem
Hello,
I wanted to test the odesolve package and tried to use compiled C-code.
But when I do:
erg <- lsoda(y, times, "mond", parms, rtol, atol, tcrit=NULL, jacfunc=NULL,
verbose=FALSE, dllname="mond", hmin=0, hmax=Inf)
I get the error message:
Error in lsoda(y, times, "mond", parms, rtol, atol, tcrit = NULL,
jacfunc =
2005 Nov 06
1
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. I cannot seem
to get lsoda working when I define the model as a shared C library. For
example, the following snippet uses the mymod.c example bundled with
the package:
### START
rm(list=ls())
2004 Sep 06
1
A naive lsoda question....
Hello,
I am an R newbie, trying to use lsoda to solve standard
Lotka-Volterra competition equations. My question is: how do I
pass a parameter that varies with time, like say, phix <- 0.7 +
runif(tmax) in the example below.
# defining function
lotvol <- function(t,n,p){
x <- n[1]; y <- n[2]
rx <- p["rx"]; ry <- p["ry"]
Kx <-