Displaying 20 results from an estimated 7000 matches similar to: "numericDeriv"
2007 Aug 01
1
Re : Custom axis
Maybe I do not explain well what I would like to do. I do not want to change the labels of the axis, but the scale. What I want is a general procedure for changing the scale. Its like using a logarithmic scale on a plot. Labels are the same, but the increases of x along the x-axis are defined by a known monotone and continuous function.
Florent Bresson
----- Message d'origine ----
De :
2004 Apr 28
4
numericDeriv
Dear All,
I am trying to solve a Generalized Method of Moments problem which
necessitate the gradient of moments computation to get the
standard errors of estimates.
I know optim does not output the gradient, but I can use numericDeriv to
get that. My question is: is this the best function to do this?
Thank you
Jean,
2012 May 18
1
Help for numericDeriv function
Hi,
I am stuck on something for a couple days, I am almost about to give up.
This looks simple, but I can't figure out. I hope I can get some help here.
I am trying to do some symbolic and numerical derivations. Let me explain
the problem. Let's say, I have a matrix as follows:
> load <- matrix(c(3,0,1,4,1,3),nrow=3,ncol=2,byrow=TRUE)
>
> load
[,1] [,2]
[1,] 3 0
2006 Oct 16
5
Re : Generate a random bistochastic matrix
Thanks, I tried someting like this, but computation takes times for large matrices
btransf <- function(y,X=length(y)^4) {
N <- length(y)
bm <- matrix(rep(1/N,N^2),N,N)
for(j in 1:X){
coord <- sample(1:N,4,replace=T)
d <- runif(1,0,min(bm[coord[1],coord[2]],bm[coord[3],coord[4]]))
2020 Jun 15
2
numericDeriv alters result of eval in R 4.0.1
Dear R developers,
I've run into a weird behavior of the numericDeriv function (from the stats
package) which I also posted on StackOverflow (question has same title as
this email, except for the version of R).
Running the code bellow we can see that the numericDeriv function gives an
error as the derivative of x^a wrt a is x^a * log(x) and log is not defined
for negative numbers. However,
2020 Jun 16
1
[External] numericDeriv alters result of eval in R 4.0.1
Dear all
As far as I could trace, looking at the function C function numeric_deriv,
this unwanted behavior comes from the inner most loop in, at the very end
of the function,
for(i = 0, start = 0; i < LENGTH(theta); i++) {
for(j = 0; j < LENGTH(VECTOR_ELT(pars, i)); j++, start += LENGTH(ans)) {
SEXP ans_del;
double origPar, xx, delta;
origPar = REAL(VECTOR_ELT(pars, i))[j];
2007 Feb 13
1
nls: "missing value or an infinity" (Error in numericDeriv) and "singular gradient matrix"Error in nlsModel
Hi,
I am a non-expert user of R. I am essaying the fit of two different functions to my data, but I receive two different error messages. I suppose I have two different problems here... But, of which nature? In the first instance I did try with some different starting values for the parameters, but without success.
If anyone could suggest a sensible way to proceed to solve these I would be
2005 Nov 28
3
optimization with inequalities
I have to estimate the following model for several
group of observations :
y(1-y) = p[1]*(x^2-y) + p[2]*y*(x-1) + p[3]*(x-y)
with constraints :
p[1]+p[3] >= 1
p[1]+p[2]+p[3]+1 >= 0
p[3] >= 0
I use the following code :
func <- sum((y(1-y) - p[1]*(x^2-y) + p[2]*y*(x-1) +
p[3]*(x-y))^2)
estim <- optim( c(1,0,0),func, method="L-BFGS-B" ,
lower=c(1-p[3], -p[1]-p[3]-1,
2006 Oct 16
2
Re : Re : Generate a random bistochastic matrix
Yes, you're right. In fact, it's just an adaptation of a matlab command and the author advises using N^4 replications that's why it's the default in the function. The bistochastic matrix is not my subject of interest, but I need it to perform some random tranformation of a vector of incomes.
Florent Bresson
----- Message d'origine ----
De : Richard M. Heiberger <rmh at
2005 Dec 05
3
The gamma function and infinity
I have to calculate some formula like:
gamma(x)/(gamma(x+y)
and I observed that for relatively big values of x, R
returns infinity and so cannot compute the formula. Is
it possible to force R to give the real value of
gamma(x) instead of Inf ?
thanks
2003 Apr 25
2
AW: numericDeriv and ecdf
> On only ten points, what did you expect ? Even with 1000
> observations, estimating a density is difficult, and has
> been the subject of a century of research. Kernel density
> estimates are among the most successful. For your immediate
> application, try plot(density(rnorm(10)), type="l"), etc.
wait, you misunderstood me!
I'd like to see 10 or 9 points with
2005 Oct 31
3
Applying a function to a vector
I have defined a function to compute the value of a
beta distribution of the second kind (the existing
beta distribution of th stats package is the beta
distribution of the first kind). It works perfectly
for a single value, but I want to apply it to a vector
of 22 000 values. I can use a loop for the calculation
of each value but it runs very very slowly.
So, what can I change ?
Hers's the
2006 Oct 16
2
Generate a random bistochastic matrix
Please, I would like to generate a random bistochastic matrix, that is a squared matrix of non-negative numbers with each row and each column sum to 1, for example :
.2 .3 .5
.6 .3 .1
.2 .4 .4
I don't know of to code this. Do you have any idea ?
Thanks
Florent Bresson
___________________________________________________________________________
Demandez ?
2007 Aug 24
2
Applying a function to an array
Dear R-users,
I would like to apply a function (more precisely sd()) over the third dimension of a three-dimension array. The function apply would be interesting but the chosen function can only be applied on the rows and columns of the array according to the help file. I can use a loop to cut the array in matrices and then use apply for each replication, but it's not very nice. A small
2006 Jan 12
2
tapply and weighted means
I' m trying to compute weighted mean on different
groups but it only returns NA. If I use the following
data.frame truc:
x y w
1 1 1
1 2 2
1 3 1
1 4 2
0 2 1
0 3 2
0 4 1
0 5 1
where x is a factor, and then use the command :
tapply(truc$y,list(truc$x),wtd.mean, weights=truc$w)
I just get NA. What's the problem ? What can I do ?
2007 Jan 15
2
Kernel density output
Hi,
I'm using the density() command for a given vector x and I would like to know how to get the estimated value of the density for each element of the vector x instead of values corresponding to points from a grid.
Thanks
Florent Bresson
2006 Jan 19
1
numericDeriv() giving a vector when multiple variables input
R Help List --
I have defined two time-series-vector-valued-functions, let them be f and g,
and want to find the numeric derivative of f with respect to the variable x
where f depends on x through g:
(d/dx)(f (g(x) )
Moreover, x is a vector
I tried this out the long way (naming every element of the x vector and then
making the 'theta' argument in numericDeriv() the character vector of
2005 Sep 25
2
getting variable length numerical gradient
Hi all.
I have a numerical function f(x), with x being a vector of generic
size (say k=4), and I wanna take the numerically computed gradient,
using deriv or numericDeriv (or something else).
My difficulties here are that in deriv and numericDeric the function
is passed as an expression, and one have to pass the list of variables
involved as a char vector... So, it's a pure R programming
2010 Oct 13
2
Using NLS with a Kappa function
Hi Everyone,
I am trying to use NLS to fit a dataset using a Kappa function, but I am
having problems. Depending on the start values that I provide, I get
either:
Error in numericDeriv(form[[3L]], names(ind), env) :
Missing value or an infinity produced when evaluating the model
Or
Error in nls(FldFatRate ~ funct3(MeanDepth_m, h, k, z, a), data = data1, :
singular gradient
I think these
2006 Jul 19
3
Progress in a loop
Hi, I have to use a loop to perform a quite computer
intensive estimation and I would like to know the
progress of the loop during the process. I tried to
include something like
print(paste(k,date(),sep=" : "))
where k is the number of the iteration, but the result
appears only at the end of the loop. Can someone help
me please ?