similar to: names of arguments in function for optimize

Displaying 20 results from an estimated 50000 matches similar to: "names of arguments in function for optimize"

2008 Apr 12
1
R and Excel disagreement - Goal Seek versus uniroot
Dear friends - occurring in Windows R2.6.2 I am modeling physical chemistry in collaboration with a friend who has preferred working in Excel. I used uniroot, and find a solution to a two buffer problem in acid-base chemistry which I believe is physiologically sensible. Using "goal seek" in Excel my friend found another plausible root, quite close to zero, and a plot of the function
2009 Mar 19
1
.Internal
I was trying to find source for optimize and I ran across function (f, interval, ..., lower = min(interval), upper = max(interval), maximum = FALSE, tol = .Machine$double.eps^0.25) { if (maximum) { val <- .Internal(fmin(function(arg) -f(arg, ...), lower, upper, tol)) list(maximum = val, objective = f(val, ...)) } else { val <-
2007 Feb 21
1
avoiding a needless function evaluation in optimize() (PR#9523)
Full_Name: Jelle Goeman Version: 2.4.0 OS: windows XP Submission from: (NULL) (145.88.209.33) Hi, I like to use optimize() to optimize functions whose evaluation is costly in terms of computation time. The Brent algorithm which is implemented in optimize was designed to optimize a function with as few function evaluations as possible. Therefore it bothers me that optimize() always evaluates
2005 Jan 29
2
Name conflicts when passing arguments for one function to another
I am fairly new to R. I find it surprising that f <- function(x,a) {x-a} uniroot(f, c(0,1), a=.5) works, but integrate(f, 0, 1, a=.5) gives an error: Error in integrate(f, 0, 1, a = 0.5) : argument 4 matches multiple formal arguments What is the best way of avoiding such surprises? Is there a way of telling integrate() that the 'a' argument is for f()? If I wrote my own function
2005 Oct 11
2
Sometimes having problems finding a minimum using optim(), optimize(), and nlm() (while searching for noncentral F parameters)
Hi everyone. I have a problem that I have been unable to determine either the best way to proceed and why the methods I'm trying to use sometimes fail. I'm using the pf() function in an optimization function to find a noncentrality parameter that leads to a specific value at a specified quantile. My goal is to have a general function that returns the noncentrality parameter that
2009 Oct 01
1
Using optimize with array variables
Hello, I am trying to figure out how to use optimize() with array variables as inputs. I have a for loop in the function definition: SS <- function(int,slo,x,y){ for(i in 1:length(x)) ((int+slo*x[i])-y[i])^2->squares[i] sum(squares)->>sum_squares output_txt = c ("The sum of squares is", sum_squares) print(output_txt, quote=FALSE)} Even assuming I make x and y
2011 Dec 08
1
optimize()
Hi! I have a difficulty in the use of function optimize(). Could you help me? I want to maximize this function: ##### Logaritmo da distribui??o condicional de alpha[i] lp_alphai <- function(alphai, i, beta, tau, N){ t1 <- (N[i+1] - N[i])*log(alphai) t2 <- - (N[i+1] - N[i])*alphai*log(beta[i]) t3 <- (alphai - 1)*sum(log(times[(N[i] + 1):N[i+1]])) t4 <- -
2008 Aug 21
2
Help Regarding 'integrate'
I have an R function defined as: f<-function(x){ return(dchisq(x,9,77)*((13.5/x)^5)*exp(-13.5/x)) } Numerically integrating this function, I observed a couple of things: A) Integrating the function f over the entire positive real line gives an error: > integrate(f,0,Inf) Error in integrate(f, 0, Inf) : the integral is probably divergent B) Increasing the interval of integration
2004 Nov 22
2
optimize in very small values
I hope you will forgive me this simple question on titration. I'm trying to find very small values from the algorithm below, which I believe is correctly formatted, and the constants are also correct. When SID goes over ATOT, fitted vales are much too low compared to the literature. I guess I must be using optimize in a wrong way but cannot find out how to improve it. I'm on windows, R
2008 Jan 27
2
Likelihood optimization numerically
Dear List, I am not sure how should i optimize a log-likelihood numerically: Here is a Text book example from Statistical Inference by George Casella, 2nd Edition Casella and Berger, Roger L. Berger (2002, pp. 355, ex. 7.4 # 7.2.b): data = x = c(20.0, 23.9, 20.9, 23.8, 25.0, 24.0, 21.7, 23.8, 22.8, 23.1, 23.1, 23.5, 23.0, 23.0) n <- length(x) # likelihood from a 2 parameter Gamma(alpha,
2010 Feb 17
2
Trouble with optim function
Hi all, I'm trying to make a little script to determine an "unknown" rate for a number of known exponential trials. My Code: #Set Trials and generate number trials=100 rand<-runif(1,0,1) vector=0 #Generate vector of 100 random exponentials and sum them for (i in 1:100) { vector<-rexp(trials,rate=rand) } sumvect=sum(vector) #Create the log likelihood function
2006 May 10
2
problems with optimize (again)
Can someone please explain what the $minimum result of the optimize function actually is? I'm trying to optimize the function: fitIT<-function(ampFac,ts_wave1,ts_template){ template<-stretchWaveTime(ts_template,ampFac) fit<-calcFit(ts_wave1,template) return(fit) } with >optimize(f=fitIT,interval=c(0.5,4),ts_wave1=test.data[,1],ts_template=test.data[,1]) $minimum [1]
2013 May 30
2
RFC: a "safe" uniroot() function for future R
With main R releases only happening yearly in spring, now is good time to consider *and* discuss new features for what we often call "R-devel" and more officially is R Under development (unstable) (.....) -- "Unsuffered Consequences" Here is one such example I hereby expose to public scrutiny: A few minutes ago, I've committed the following to R-devel (the
2007 Dec 19
2
can optimize solve paired euqations?
I used the command below, but R gives me the error message--syntax error. can anyone see the mistakes I made? optimize(function(x,y) + ((327.727-(1-0.114^10)*y*(1-x)/x/(1-x^y))+(9517.336-327.727 *(1+(1-x)*(1+y)/x-327.727)))^2 + interval=c(0,1)) At the same time, I use nlm() but R gives me the code $code [1] 3 function(vals) { x <- vals[1] y <- vals[2]
2009 May 24
1
using optimize() correctly ...
Hi, I am trying to use the optimize function to optimize a function. The results I am getting don't agree with what I compute on my own and when I look at the graph of f(x) = 100 + ((x-10)**2 + (x-10)) * cos(x-10), where -10 <= x <= 10 in gnuplot. I suspect I am making a mistake in the usage of the R optimize function, perhaps someone could point out where? >
2006 Dec 28
1
calling optimize/fmin from C code
Hi, To make a calculation (an innermost loop) that uses optimize faster, I think I should write things in C. Is it possible to call fmin, which is called by optimize, from C? It is not listed in Writing R extensions, but I found double Brent_fmin(double ax, double bx, double (*f)(double, void *), void *info, double tol); in Applic.h. Is this the function I am looking for?
2007 Jan 31
2
what is the purpose of an error message in uniroot?
Hi all, This is probably a blindingly obvious question: Why does it matter in the uniroot function whether the f() values at the end points that you supply are of the same sign? For example: f <- function(x,y) {y-x^2+1} #this gives a warning uniroot(f,interval=c(-5,5),y=0) Error in uniroot(f, interval=c(-5, 5), y = 0) : f() values at end points not of opposite sign #this doesn't give a
2010 Aug 25
4
Secant Method Convergence (Method to replicate Excel XIRR/IRR)
Hi, I am new to R, and as a first exercise, I decided to try to implement an XIRR function using the secant method. I did a quick search and saw another posting that used the Bisection method but wanted to see if it was possible using the secant method. I would input a Cash Flow and Date vector as well as an initial guess. I hardcoded today's initial date so I could do checks in Excel.
2007 Oct 01
3
optimize() stuck in local plateau ?
Hi all, Consider the following function: #### my.func = function(x){ y=ifelse(x>-.5,0,ifelse(x< -.8,abs(x)/2,abs(x))) print(c(x,y)) #print what was tested and what the result is return(y) } curve(my.func,from=-1,1) #### When I attempt to find the maximum of this function, which should be -.8, I find that optimize gets stuck in the plateau area and doesn't bother testing the
2010 Dec 06
1
Optimize multiple variable sets
Hi, I usually use optimize function for ML Estimation. Now I?ve got a data frame with many sets, but I can?t save estimates each time I run the code for each data set (I?m using a for loop with my loglikelihood function and works ok but when I apply another for loop to: optimize(my.loglikelihood.function[i], int=c(0.0001,10)) it doesn?t work; alternatively, using optimize inside the for loop