search for: feval

Displaying 16 results from an estimated 16 matches for "feval".

Did you mean: eval
2007 Mar 27
3
Use of 'defineVar' and 'install' in .Call
...parameters: f: expression for which we will find the root guesses: interval for the solution stol: tolerance rho: environment The original functions I use are: SEXP mkans(double x) { SEXP ans; PROTECT(ans = allocVector(REALSXP, 1)); REAL(ans)[0] = x; UNPROTECT(1); return ans; } double feval(double x, SEXP f, SEXP rho) { defineVar(install("x"), mkans(x), rho); return(REAL(eval(f, rho))[0]); } SEXP zero(SEXP f, SEXP guesses, SEXP stol, SEXP rho) { double x0 = REAL(guesses)[0], x1 = REAL(guesses)[1], tol = REAL(stol)[0]; double f0, f1, fc, xc; if(tol <= 0.0) error(...
2007 Mar 27
3
Use of 'defineVar' and 'install' in .Call
...parameters: f: expression for which we will find the root guesses: interval for the solution stol: tolerance rho: environment The original functions I use are: SEXP mkans(double x) { SEXP ans; PROTECT(ans = allocVector(REALSXP, 1)); REAL(ans)[0] = x; UNPROTECT(1); return ans; } double feval(double x, SEXP f, SEXP rho) { defineVar(install("x"), mkans(x), rho); return(REAL(eval(f, rho))[0]); } SEXP zero(SEXP f, SEXP guesses, SEXP stol, SEXP rho) { double x0 = REAL(guesses)[0], x1 = REAL(guesses)[1], tol = REAL(stol)[0]; double f0, f1, fc, xc; if(tol <= 0.0) error(...
2005 Jun 24
3
Counterpart for Matlab's 'feval'?
Hi! I've just begun writing a program that searches for the minimum of a function with golden section search. In order to do this in a nice way I need a function that takes a function name and an argument and returns the function value for that argument, i .e just like Matlab's 'feval'. Is there any? Thanks before hand! Best regards, Fredrik Thuring, Codan Insurance A/S Research Department ------------------------------------------------------------------------------ This e-mail and any attachment may be confidential and may also be privileged. If you are not the intend...
2004 Jan 30
1
MATLAB to R
Ladies and Gentlemen, In MATLAB, I can write: for J=1:M Y(J+1)=Y(J)+ h * feval(f,T(J),Y(J)); ... In R, I can write above as: for (J in 2:M) { y = y + h * f(t,y) ... } ---- In MATLAB, I can write: for J=1:M k1 = feval(f,T(J),Y(J)); k2 = feval(f,T(J+1),Y(J)+ h * k1 How do I write k2 in R? k1 = f(t,y) k2 = ? Thanks, /oal
2011 Aug 15
0
Stopping criterion in option "control" of BBsolve( )
...else { return(c(2,2)); } } > system.time( { R.ptm = proc.time(); tst = BBsolve(par=c(1,1), fn = tst.fn , control = list(maxit = 10000, noimp=10000)) } ) Unsuccessful convergence. user system elapsed 0.25 0.00 0.25 > tst $par [1] 0.5 0.6 $residual [1] 2 $fn.reduction [1] 0 $feval [1] 186 $iter [1] 100 $convergence [1] 5 $message [1] "Lack of improvement in objective function" $cpar method M NM 2 50 1 Example 2: The equation tst.fn() returns a constant vector c(2,2), thus it will never converge. I specified maxit = 1000 and noimp=10...
2004 Jun 11
1
bug or correct behaviour ?
...argc,argv){ ... Rf_initEmbeddedR(argc,argv); ... Test_tryEval("source(test.r)"); ... } ############# # test.r ############# ... dyn.load("toload.so") tmp <-matrix(data=1,nrow=narray*2,ncol=nclust) .Call("Init",tmp,...) while(...) { criteria <-feval(tmp) if (criteria < criteria.min) tmp.last <- tmp else tmp <- tmp.last ... .Call("replace",tmp,...) } #################################### When I try to recover tmp tmp <- tmp.last I got the modified value of tmp. It means that tmp....
2008 Jan 16
1
Pb with defineVar() example in the "Writing R Extensions" manual
Hi, I'm wondering if this code from the "Writing R Extensions" manual is really safe: SEXP mkans(double x) { SEXP ans; PROTECT(ans = allocVector(REALSXP, 1)); REAL(ans)[0] = x; UNPROTECT(1); return ans; } double feval(double x, SEXP f, SEXP rho) { defineVar(install("x"), mkans(x), rho); return(REAL(eval(f, rho))[0]); } In C, the order in which function arguments are evaluated before the function itself is called is undefined. Hence there is no guarantee that install("x...
2010 Apr 29
1
BB package
...p[3]*(1-p[4]))^2   f   }   p0 <- c(1.3, 50,60,0.8) dfsane(par=p0, fn = test_fn, control=list(trace=FALSE))   and got this output   > dfsane(par=p0, fn = test_fn, control=list(trace=FALSE)) $par [1]  2.1327328  6.3213205 60.3580481  0.9097743 $residual [1] 0.4251058 $fn.reduction [1] 4833.46 $feval [1] 140 $iter [1] 137 $convergence [1] 5 $message [1] "Lack of improvement in objective function"   My question is how to improve the solution if I want to put some constraint for the parameters such as p[1], p[2] and p[3] > 0.0001 and -1<p[4]<1.     Regards,   Roslina...
2017 Dec 26
1
identifying convergence or non-convergence of mixed-effects regression model in lme4 from model output
...yqa" ? ..$ control? :List of 1 ? .. ..$ iprint: int 0 ? ..$ derivs?? :List of 2 ? .. ..$ gradient: num [1:4] 9.81e-06 -5.34e-06 -1.60e-05 7.06e-05 ? .. ..$ Hessian : num [1:4, 1:4] 245.9 28.5 3.3 -13.7 28.5 ... ? ..$ conv???? :List of 2 ? .. ..$ opt : int 0 ? .. ..$ lme4: list() ? ..$ feval??? : int 107 ? ..$ warnings : list() ? ..$ val????? : num [1:4] 0.6919 0.2705 0.0314 0.223 ?- attr(*, "class")= chr "summary.merMod" I'd appreciate any advice you may have! Thank you, Aleksander G??wka PhD Candidate Department of Linguistics Stanford University ** [[...
2011 Nov 10
3
optim seems to be finding a local minimum
Hello! I am trying to create an R optimization routine for a task that's currently being done using Excel (lots of tables, formulas, and Solver). However, otpim seems to be finding a local minimum. Example data, functions, and comparison with the solution found in Excel are below. I am not experienced in optimizations so thanks a lot for your advice! Dimitri ### 2 Inputs:
2008 Apr 25
5
Non-linear system of equations
Hello R users, I am trying to estimate the parameters of a bimodal normal distribution using moments matching, so I have to solve a non-linear system of equations. How can I solve the following simple example? x^2 - y^2 = 6 x ? y = 3 I heard about nlsystemfit, but I don?t know how to run it exactly. I have tried the following code, but it doesn?t really work: f1 <-y~ x[1]^2-x[2]^2-6 f2
2012 Oct 18
3
Upper limit in nlsLM not working as expected
Dear all, I am using the nlsLM function to fit a Lorentzian function to my experimental data. The LM algorithm should allow to specify limits, but the upper limit appears not to work as expected in my code. The parameter 'w', which is peak width at half maximuim always hits the upper limit if the limit is specified. I would expect the value to be in-between the upper and lower limit with
2017 Jun 18
0
R_using non linear regression with constraints
I've seen a number of problems like this over the years. The fact that the singular values of the Jacobian have a ration larger than the usual convergence tolerances can mean the codes stop well before the best fit. That is the "numerical analyst" view. David and Jeff have given geometric and statistical arguments. All views are useful, but it takes some time to sort them all out and
2012 Apr 17
3
error using nls with logistic derivative
Hi I?m trying to fit a nonlinear model to a derivative of the logistic function y = a/(1+exp((b-x)/c)) (this is the parametrization for the SSlogis function with nls) The derivative calculated with D function is: > logis<- expression(a/(1+exp((b-x)/c))) > D(logis, "x") a * (exp((b - x)/c) * (1/c))/(1 + exp((b - x)/c))^2 So I enter this expression in the nls function:
2009 Jul 17
6
Solving two nonlinear equations with two knowns
Dear R users, I have two nonlinear equations, f1(x1,x2)=0 and f2(x1,x2)=0. I try to use optim command by minimize f1^2+f2^2 to find x1 and x2. I found the optimal solution changes when I change initial values. How to solve this? BTW, I also try to use grid searching. But I have no information on ranges of x1 and x2, respectively. Any suggestion to solve this question? Thanks, Kate
2017 Jun 18
3
R_using non linear regression with constraints
I am not as expert as John, but I thought it worth pointing out that the variable substitution technique gives up one set of constraints for another (b=0 in this case). I also find that plots help me see what is going on, so here is my reproducible example (note inclusion of library calls for completeness). Note that NONE of the optimizers mentioned so far appear to be finding the true best