Displaying 20 results from an estimated 9000 matches similar to: "How to get the result of eval()"
2007 Jan 12
1
incorrect result of deriv (PR#9449)
Full_Name: Joerg Polzehl
Version: 2.3.1
OS: x86_64, linux-gnu
Submission from: (NULL) (62.141.176.22)
I observed an incorrect behavior of function deriv when evaluating arguments of
dnorm
deriv(~dnorm(z,0,s),"z")
expression({
.value <- dnorm(z, 0, s)
.grad <- array(0, c(length(.value), 1), list(NULL, c("z")))
.grad[, "z"] <- -(z * dnorm(z))
2009 May 10
4
Partial Derivatives in R
Quick question:
Which function do you use to calculate partial derivatives from a model
equation?
I've looked at deriv(), but think it gives derivatives, not partial
derivatives. Of course my equation isn't this simple, but as an example,
I'm looking for something that let's you control whether it's a partial or
not, such as:
somefunction(y~a+bx, with respect to x,
2010 Apr 06
2
Extracting formulae from expression() / deriv()
I am attempting to extract the derivative/ gradient from this expression
df1p <- deriv(f1, "P")
> df1p
expression({
.value <- s - c - a * P
.grad <- array(0, c(length(.value), 1L), list(NULL, c("P")))
.grad[, "P"] <- -a
attr(.value, "gradient") <- .grad
.value
})
So in this case I want to extract the "-a".
2007 Jul 30
2
deriv, loop
Hi, 2 questions:
Question 1: example of what I currently do:
for(i in 1:6){sink("temp.txt",append=TRUE)
dput(i+0)
sink()}
x=scan(file="temp.txt")
print(prod(x))
file.remove("C:/R-2.5.0/temp.txt")
But how to convert the output of the loop to a vector that I can manipulate
(by prod or sum etc), without having to write and append to a file?
Question 2:
>
2001 Oct 05
1
nls() fit to a lorentzian - can I specify partials?
First, thanks to all who helped me with my question about rescaling axes
on the fly. Using unlist() and range() to set the axis ranges in advance
worked well. I've since plotted about 300 datasets with relative ease.
Now I'm trying to fit a lossy oscillator resonance to (the square root of)
a lorentzian (testframe$y is oscillator amplitude, testframe$x is drive
frequency):
lorentz
2009 Oct 29
4
deriv() to take vector of expressions as 1st arg?
The deriv() function takes an 'expression' as its first argument). I was
wondering if the this function can take an array or a vector of
expressions as its first argument. Aside, I saw how to give a vector
argument to the second argument.
like to have something like:
deriv(c(~x^2+y^3, ~x^5+y^6), c("x","y"))
the documentation for this function talks about being able to
2006 Nov 18
1
deriv when one term is indexed
Hi,
I'm fitting a standard nonlinear model to the luminances measured
from the red, green and blue guns of a TV display, using nls.
The call is:
dd.nls <- nls(Lum ~ Blev + beta[Gun] * GL^gamm,
data = dd, start = st)
where st was initally estimated using optim()
st
$Blev
[1] -0.06551802
$beta
[1] 1.509686e-05 4.555250e-05 7.322720e-06
$gamm
[1] 2.511870
This works fine but I
2008 Mar 27
1
A faster way to compute finite-difference gradient of a scalar function of a large number of variables
Hi All,
I would like to compute the simple finite-difference approximation to the
gradient of a scalar function of a large number of variables (on the order
of 1000). Although a one-time computation using the following function
grad() is fast and simple enough, the overhead for repeated evaluation of
gradient in iterative schemes is quite significant. I was wondering whether
there are
2011 May 03
3
help with the maxBHHH routine
Hello R community,
I have been using R's inbuilt maximum likelihood functions, for the
different methods (NR, BFGS, etc).
I have figured out how to use all of them except the maxBHHH function. This
one is different from the others as it requires an observation level
gradient.
I am using the following syntax:
maxBHHH(logLik,grad=nuGradient,finalHessian="BHHH",start=prm,iterlim=2)
2012 Jan 03
1
higher derivatives using deriv
Dear everyone,
the following is obviously used to compute the nth derivative, which seems
to work
(deriv(sqrt(1 - x^2),x,n))
However, before using this, I wanted to make sure it does what I think it
does
but can't figure it out when reading the ?deriv info or any other
documentation on deriv for that matter:
deriv(expr, namevec, function.arg = NULL, tag = ".expr", hessian = FALSE,
2003 Nov 14
3
Expressions and Functions
Dear R People:
When the D function is used for a symbolic derivative,
an expression is returned, which is fine.
How do you change that expression to a function, please?
I've been experimenting with substitute and deparse, but no success
yet.
This is R 1.8.0 for Windows.
thanks in advance for the help!
Sincerely,
Erin Hodgess
mailto: hodgess at gator.uhd.edu
2004 May 14
2
NLME model question
Dear R-helpers
I have a problem related to the use of NLME
I think is simply a matter of getting the nlme coding correct, but i cannot
get my brain around it
I am analysing some 24 growth curves of some cells , and i wanted to say
that there are significant differences between the curves in two parameters
that describe the pattern of growth. these parameters are from a logistic
(r & k)
2010 Mar 12
2
Question regarding to maxNR
Hi R-users,
Recently, I use maxNR function to find maximizer. I have error appears as follows
Error in maxNRCompute(fn = fn, grad = grad, hess = hess, start = start, :
NA in the initial gradient
My code is
mu=2
s=1
n=300
library(maxLik)
set.seed(1004)
x<-rcauchy(n,mu,s)
loglik<-function(mu)
{
log(prod(dcauchy(x,mu,s)))
}
maxNR(loglik,start=median(x))$estimate
Does anyone know how
2009 Mar 02
1
initial gradient and vmmin not finite
Dear Rhelpers
I have the problem with initial values, could you please tell me how to solve it?
Thank you
June
> p = summary(maxLik(fr,start=c(0,0,0,1,0,-25,-0.2)))
Error in maxRoutine(fn = logLik, grad = grad, hess = hess, start = start, :
NA in the initial gradient
> p = summary(maxLik(fr,start=c(0,0,0,1,0,-25,-0.2),method="BFGS"))
Error in optim(start, func, gr =
2011 Nov 17
3
Obtaining a derivative of nls() SSlogis function
Hello, I am wondering if someone can help me. I have the following function
that I derived using nls() SSlogis. I would like to find its derivative. I
thought I had done this using deriv(), but for some reason this isn't
working out for me.
Here is the function:
asym <- 84.951
xmid <- 66.90742
scal <- -6.3
x.seq <- seq(1, 153,, 153)
nls.fn <- asym/((1+exp((xmid-x.seq)/scal)))
2011 Dec 23
2
missing value where TRUE/FALSE needed
Merry Xmas to all,
I am writing a function and curiously this runs sometimes on one data set
and fails on another and i cannot figure out why.
Any help much appreciated.
If i run the code below with
data <- iris[ ,1:4]
The code runs fine, but if i run on a large dataset i get the following
error (showing data structures as matrix is large)
> str(cluster.data)
num [1:9985, 1:811] 0 0 0 0
2009 Oct 19
2
How to get slope estimates from a four parameter logistic with SSfpl?
Hi,
I was hoping to get some advice on how to derive estimates of slopes from four parameter logistic models fit with SSfpl.
I fit the model using:
model<-nls(temp~SSfpl(time,a,b,c,d))
summary(model)
I am interested in the values of the lower and upper asymptotes (parameters a and b), but also in the gradient of the line at the inflection point (c) which I assume tells me my rate of
2007 Mar 20
2
Problems about Derivaties
Dear participants to the list,
this is my problem: I want to obtain an expression that represents the second
derivative of one function.
With "deriv3" (package "stats") it is possible to evaluate the second
derivative, but I do not know how I can get the (analytical) expression of this
derivative.
For example: Suppose that I have a function of this form:
2001 May 28
0
bugs in deriv(*, *, function.arg = ) (PR#953)
Also, this should have gone in R-bugs quite a while ago :
------- start of forwarded message -------
From: Martin Maechler <maechler@stat.math.ethz.ch>
To: R-core@stat.math.ethz.ch
Subject: PROTECT() bugs in deriv(*, *, function.arg = )
Date: Mon, 16 Apr 2001 21:02:10 +0200
In R versions 0.50 and 0.64.2 ,
the following worked
> deriv(expression(sin(cos(x) * y)),
2006 Mar 12
2
Numerical Derivatives in R
Hi,
Suppose I have an arbitrary function:
arbfun<-function(x) {...}
Is there a robust implementation of a numerical derivative routine in R
which I can use to take it's derivative ? Something a bit more than
simple division by delta of the difference of evaluating the function at
x and x+delta...
Perhaps there is a way to do this using D or deriv but I could not
figure it out.