search for: numderiv

Displaying 20 results from an estimated 58 matches for "numderiv".

2008 Apr 29
1
NumDeriv - derivatives of covariance matrix
...er<-matrix(0,n,n) for (i in 1:n) { for (j in i:n) { Cder[i,j]<-(-0.5*((x[i,index]-x[j,index])^2))*theta*exp(-0.5* sum(eta*(x[i,]-x[j,])^2)) } } Cder<-0.5*(Cder+t(Cder)) Cder } I was wondering whether it might be possible to speed up things using numDeriv (jacobian). If so, what would be the right way to implement a suitable method ? Cheers, Gao Daomeng [[alternative HTML version deleted]]
2009 Nov 20
2
Problem with Numerical derivatives (numDeriv) and mvtnorm
I'm trying to obtain numerical derivative of a probability computed with mvtnorm with respect to its parameters using grad() and jacobian() from NumDeriv. To simplify the matter, here is an example: PP1 <- function(p){ thetac <- p thetae <- 0.323340333 thetab <- -0.280970036 thetao <- 0.770768082 ssigma <- diag(4) ssigma[1,2] <- 0.229502120 ssigma[1,3] <- 0.677949335 ssigma[1,4] <- 0.55290774...
2010 Nov 06
1
saddle points in optim
Hi, I've been trying to use optim to minimise least squares for a function, and then get a guess at the error using the hessian matrix (calculated from numDeriv::hessian, which I read in some other r-help post was meant to be more accurate than the hessian given in optim). To get the standard error estimates, I'm calculating sqrt(diag(solve(x))), hope that's correct. I've found that using numDeriv's hessian gets me some NaNs for errors, w...
2012 Nov 15
1
hessian fails for box-constrained problems when close to boundary?
...ollowing questions: 1) is this solution to use smaller steps good at all? 2) I am not sure either I understand the reasons why the hessian in a constrained optim problem is evaluated without the constraints, or at least the problem transformed into a warning? Furthermore, I realised that using the numDeriv package, the function hessian() does not offer either constraints for the parameters, yet in the special case of the example above, it does not fail (although would have problems with parameter even closer to the bound), unlike the optimHessian() function? See: library(numDeriv) hessian(LLNorm, op$...
2010 Sep 21
5
Can ucminf be installed in 64 bit R and one more question?
...did not connect my computer to internet. did anyone meet this problem and is there a version of ucminf for 64 bit R? the question is: why the ucminf (for 32 bit R) with option hessian=3 always give hessian matrix while most of other methods?failed (includiing the option hessian=1 which using numDeriv)? thanks for any information Nan from Montreal
2009 Jun 22
1
The gradient of a multivariate normal density with respect to its parameters
...adient) of the multivariate normal density with respect to the *parameters*? It?s easy enough to implement myself, but I?d like to avoid reinventing the wheel (with some bugs) if possible. Here?s a simple example of the result I?d like, using numerical differentiation: library(mvtnorm) library(numDeriv) f=function(pars, xx, yy) { mu=pars[1:2] sig1=pars[3] sig2=pars[4] rho=pars[5] sig=matrix(c(sig1^2,rho*sig1*sig2,rho*sig1*sig2,sig2^2),2) dmvnorm(cbind(x,y),mu,sig) } mu1=1 mu2=2 sig1=3 sig2=4 rho=.5 x=2 # or a x vector y=3 # or a y vector jacobian(f,c(mu1,mu2,sig1,sig2,rho),xx=x,yy=y)...
2006 Nov 01
2
Hessian matrix
Dear all R users, Is there any way to calculate hessian matrix of a given function at any given point? Regards [[alternative HTML version deleted]]
2011 Aug 29
3
gradient function in OPTIMX
Dear R users When I use OPTIM with BFGS, I've got a significant result without an error message. However, when I use OPTIMX with BFGS( or spg), I've got the following an error message. ---------------------------------------------------------------------------------------------------- > optimx(par=theta0, fn=obj.fy, gr=gr.fy, method="BFGS", >
2013 Sep 13
2
R CMD check fails in R-devel r63910
...ckage for lazy loading Error in reconcilePropertiesAndPrototype(name, slots, prototype, superClasses, : no definition was found for superclass "merMod" in the specification of class "merModLmerTest" In DESCRIPTION file I have: Depends: Matrix, stats, methods, lme4 Imports: numDeriv, MASS, Hmisc, gplots, pbkrtest I have classes.R file where I specify that "merModLmerTest" class should inherit "merMod": merModLmerTest <- setClass("merModLmerTest", contains = "merMod") But it seems like in R devel r63910 this line cannot be seen......
2009 Apr 29
2
Optim and hessian
Hi, my name is Marcel R. Lopes. My problem is, I made a code to calculate the estimates of a Cox model with random effects. Used to optimize the R command for this. The estimates were calculated correctly, but the Hessian matrix does not have good values. The same thing was done in SAS and gave good results for the Hessian Matrix. Where is the problem in R? As the Hessian is calculated?. How
2007 Aug 20
3
Differentiation
Hi, Could anyone tell me what is the command used in R to do 1. Differentiation 2. Newton Raphson method (Numerical Analysis in general...) Are there any packages separately for this? Thanks for your help! BR, Shubha [[alternative HTML version deleted]]
2008 Jan 26
1
Any numeric differentiation routine in R for boundary points?
...ed function with several variables. One of the variables is restricted to be non-negative. For example, f(x,y)=sqrt(x)*exp(y), then x should be non-negative. I need the gradient and hessian for some vector (0,y), i.e., I need the gradient and hessian at the boudary of parameter space. The "numderiv" package does not work, even for f(x)=sqrt(x), if you do "genD(f,x=0)", warning message comes out. I need the one sided derivatives. Thanks if you could provide some help. -- View this message in context: http://www.nabble.com/Any-numeric-differentiation-routine-in-R-for-boundary...
2008 Sep 08
1
Vorticity and Divergence
Hi all, I have some wind data (U and V components) and I would like to compute Vorticity and Divergence of these fields. Is there any R function that can easily do that? Thanks in advance for any help Igor Oliveira CSAG, Dept. Environmental & Geographical Science, University of Cape Town, Private Bag X3, Rondebosch 7701. Tel.: +27 (0)21 650 5774 South Africa Fax: +27 (0)21
2012 Mar 31
2
gradient
Hello In matlab we have " gradient(F,h) " where h is a scalar uses h as the spacing between points in each direction. Now I need to use this function in R. and I dont know how can I should define my function that I haave "h" in R? thanks [[alternative HTML version deleted]]
2009 Nov 23
0
R-help Digest, Vol 81, Issue 23
...better to standardize your data matrix > first when you do principal (Uwe Ligges) > 22. how do i persuade IT to install R on PCs ?? ...and should I > ?? (frenchcr) > 23. Computing multivariate normal probabilities. Was: Re: Problem > with Numerical derivatives (numDeriv) and mvtnorm (Ravi Varadhan) > 24. Re: consecutive numbering of elements in a matrix (Jim Bouldin) > 25. Re: Why F value and Pr are not show in summary() of an aov() > result? (Sundar Dorai-Raj) > 26. scatter plot & equation (Rofizah Mohammad) > 27. Re: python (Pete...
2013 Nov 28
2
derivar una función
Las dos Enviado desde mi iPhone > El 28/11/2013, a las 18:07, "Carlos J. Gil Bellosta " <cgb en datanalytics.com> escribió: > > ¿Numérica o simbólicamente? > > Un saludo, > > Carlos J. Gil Bellosta > http://www.datanalytics.com > > El día 28 de noviembre de 2013 18:03, jmcontreras <jmcontreras en ugr.es> escribió: >> Hola a todos
2009 Aug 20
1
how to compute this summation...
...x1 <- c(0,0,0,0,0,1,0,0,0,0) x2 <- c(1,1,0,1,0,0,0,0,0,0) x3 <- c(0,0,1,0,0,0,0,0,0,0) x4 <- c(0,0,0,0,0,0,0,0,0,0) x5 <- c(0,0,0,0,0,0,0,0,0,1) x6 <- c(0,0,0,0,1,0,0,0,0,0) n <- length(yy) x <- cbind(x1,x2,x3,x4,x5,x6) X <- cbind(1,x) p <- 7 #### p:#beta library(numDeriv) # u function ------------------------------------------------------- obj <- function(theta,i,j) { beta <- theta[1:p] alp <- theta[p+1] log(dnbinom(yy[j], mu=exp(rowSums(X[i,] * t(beta))), size=1/alp)) } list <- expand.grid(j=seq(1,n),i=seq(1,n)) func <- function(i,j) { gr...
2010 Jun 25
1
Different standard errors from R and other software
...FGS command. Since I wrote the log-likelihood myself, in order to double check, I run the same model in Limdep. It turns out that the coefficient estimates are quite close; however, the standard errors are very different. I also computed the hessian and outer product of the gradients in R using the numDeriv package, but the results are still very different from those in Limdep. Is it the routine to compute the inverse hessian that causes the difference? Thank you very much! Best wishes. Min -- Min Chen Ph.D. Candidate Department of Agricultural, Food, and Resource Economics 125 Cook Hall Mi...
2009 Nov 02
1
need help in using Hessian matrix
...s[1:N1],shape,1) w=N1+1 V<- Us[w:r] N2<- length(V) V1<-theta2*qgamma(V,shape,1) Tj<-V1+tau1-(theta2/theta1)*tau1 c1<-matrix(Ti,ncol=1) c2<-matrix(Tj,ncol=1) cc<-data.frame(rbind(c1,c2))[,1] require(numDeriv) m1<- function(x) #a function that generates the estimates { loglik<-function(alpha,theta1,theta2){ -( log(factorial(n)/(factorial(N1)*factorial(N2)))-r*lgamma(alpha)-alpha*N1*log(theta1) -alpha*(r-N1)*log(theta2)+(alpha-1)*sum(log(cc[1:N1]))+(alpha-1)*sum(log(cc[w:r]-tau1+ (thet...
2007 Jun 26
2
fisher information matrix
Hi All, a colleague wants to calculate the Fisher information matrix for a model he wrote (not in R). He can easily get the neg-log-likelihood and the best fit parameters at the minimum. He can also get negLLs for other parameter values too. Given these data, is there a way in R to calculate the Fisher information matrix? Best, Federico -- Federico C. F. Calboli Department of Epidemiology