similar to: Can R solve this optimization problem?

Displaying 20 results from an estimated 10000 matches similar to: "Can R solve this optimization problem?"

2009 Jul 19
1
trouble using optim for maximalisation of 2-parameter function
Hello, I am having trouble using "optim". I want to maximalise a function to its parameters [kind of like: univariate maximum likelihood estimation, but i wrote the likelihood function myself because of data issues ] When I try to optimize a function for only one parameter there is no problem: llik.expo<-function(x,lam){(length(x)*log(lam))-(length(x)*log(1-exp(-1*lam*
2007 May 07
3
Bad optimization solution
Dear All I am trying to perform the below optimization problem, but getting (0.5,0.5) as optimal solution, which is wrong; the correct solution should be (1,0) or (0,1). Am I doing something wrong? I am using R 2.5.0 on Fedora Core 6 (Linux). Thanks in advance, Paul ------------------------------------------------------ myfunc <- function(x) { x1 <- x[1] x2 <- x[2] abs(x1-x2) }
2009 Nov 02
2
a prolem with constrOptim
Hi, I apologize for the long message but the problem I encountered can't be stated in a few lines. I am having some problems with the function constrOptim. My goal is to maximize the likelihood of product of K multinomials, each with four catagories under linear constraints on the parameter values. I have found that the function does not work for many data configurations. #The likelihood
2010 Sep 02
1
Help on glm and optim
Dear all, I'm trying to use the "optim" function to replicate the results from the "glm" using an example from the help page of "glm", but I could not get the "optim" function to work. Would you please point out where I did wrong? Thanks a lot. The following is the code: # Step 1: fit the glm clotting <- data.frame( u =
2007 Jan 05
2
maximum likelihood estimation of 5 parameters
Hi Guys, it would be great if you could help me with a MLE problem in R. I am trying to evaluate the maximum likelihood estimates of theta = (a1, b1, a2, b2, P) which defines a mixture of a Poisson distribution and two gamma prior distributions (where the Poisson means have a gamma distribution, actually 2 gammas and P is the mixing factor). The likelihood function for theta is L(theta) = Pi,j{P
2007 Nov 18
2
Getting theta in italic in a plot
Dear All, Consider the following code: plot(0,0) text(0,0.5,expression(italic(theta))) I would like to get theta in italic, but I always get it upright. Any suggestions? Thanks in advance, Paul
2008 Apr 05
2
How to improve the "OPTIM" results
Dear R users, I used to "OPTIM" to minimize the obj. function below. Even though I used the true parameter values as initial values, the results are not very good. How could I improve my results? Any suggestion will be greatly appreciated. Regards, Kathryn Lord #------------------------------------------------------------------------------------------ x = c(0.35938587,
2008 Apr 05
2
How to improve the "OPTIM" results
Dear R users, I used to "OPTIM" to minimize the obj. function below. Even though I used the true parameter values as initial values, the results are not very good. How could I improve my results? Any suggestion will be greatly appreciated. Regards, Kathryn Lord #------------------------------------------------------------------------------------------ x = c(0.35938587,
2005 Sep 26
2
constrOptim (PR#8158)
Full_Name: Haobo Ren Version: 2.1.1 OS: Windows 2000 Submission from: (NULL) (192.11.226.116) When running constrOptim, there is error message Error: subscript out of bounds
2005 May 31
1
Solved: linear regression example using MLE using optim()
Thanks to Gabor for setting me right. My code is as follows. I found it useful for learning optim(), and you might find it similarly useful. I will be most grateful if you can guide me on how to do this better. Should one be using optim() or stats4::mle? set.seed(101) # For replicability # Setup problem X <- cbind(1, runif(100)) theta.true <- c(2,3,1) y <- X
2003 May 08
2
approximation of CDF
Hi all, is there any package in R capable of smooth approximation of CDF basing on given sample? (Thus, I am not speaking about ecdf) In particular, I expect very much that the approximation should subject to the property: f(x0)<=f(x1) for x0<x1, where x0 and x1 belong to range of the sample given. Polynomial approximation could be OK for me as well. P.S.
2008 Mar 23
2
scaling problems in "optim"
Dear R users, I am trying to figure out the control parameter in "optim," especially, "fnscale" and "parscale." In the R docu., ------------------------------------------------------ fnscale An overall scaling to be applied to the value of fn and gr during optimization. If negative, turns the problem into a maximization problem. Optimization is performed on
2005 May 30
1
Trying to write a linear regression using MLE and optim()
I wrote this: # Setup problem x <- runif(100) y <- 2 + 3*x + rnorm(100) X <- cbind(1, x) # True OLS -- lm(y ~ x) # OLS likelihood function -- ols.lf <- function(theta, K, y, X) { beta <- theta[1:K] sigma <- exp(theta[K+1]) e <- (y - X%*%beta)/sigma logl <- sum(log(dnorm(e))) return(logl) } optim(c(2,3,0), ols.lf, gr=NULL, method="BFGS",
2006 Sep 22
2
"logistic" + "neg binomial" + ...
Hi Folks, I've just come across a kind of problem which leads me to wonder how to approach it in R. Basically, each a set of items is subjected to a series of "impacts" until it eventually "fails". The "force" of each impact would depend on covariates X,Y say; but as a result of preceding impacts an item would be expected to have a "cumulative
2003 Feb 28
2
optim
Dear all, I have a function MYFUN which depends on 3 positive parameters TETA[1], TETA[2], and TETA[3]; x belongs to [0,1]. I integrate the function over [0,0.1], [0.1,0.2] and [0.2,0.3] and want to choose the three parameters so that these three integrals are as close to, resp., 2300, 4600 and 5800 as possible. As I have three equations with three unknowns, I expect the exact fit, i.e., the SS
2011 Aug 17
2
An example of very slow computation
This message is about a curious difference in timing between two ways of computing the same function. One uses expm, so is expected to be a bit slower, but "a bit" turned out to be a factor of >1000. The code is below. We would be grateful if anyone can point out any egregious bad practice in our code, or enlighten us on why one approach is so much slower than the other. The problem
2011 May 23
6
Reading Data from mle into excel?
Hi there, I ran the following code: vols=read.csv(file="C:/Documents and Settings/Hugh/My Documents/PhD/Swaption vols.csv" , header=TRUE, sep=",") X<-ts(vols[,2]) #X dcOU<-function(x,t,x0,theta,log=FALSE){ Ex<-theta[1]/theta[2]+(x0-theta[1]/theta[2])*exp(-theta[2]*t) Vx<-theta[3]^2*(1-exp(-2*theta[2]*t))/(2*theta[2]) dnorm(x,mean=Ex,sd=sqrt(Vx),log=log) }
2009 Nov 29
1
optim or nlminb for minimization, which to believe?
I have constructed the function mml2 (below) based on the likelihood function described in the minimal latex I have pasted below for anyone who wants to look at it. This function finds parameter estimates for a basic Rasch (IRT) model. Using the function without the gradient, using either nlminb or optim returns the correct parameter estimates and, in the case of optim, the correct standard
2008 Aug 12
2
Maximum likelihood estimation
Hello, I am struggling for some time now to estimate AR(1) process for commodity price time series. I did it in STATA but cannot get a result in R. The equation I want to estimate is: p(t)=a+b*p(t-1)+error Using STATA I get 0.92 for a, and 0.73 for b. Code that I use in R is: p<-matrix(data$p) # price at time t lp<-cbind(1,data$lp) # price at time t-1
2001 Nov 08
3
Problem with optim (method L-BFGS-B)
Hello, I've just a little problem using the function optim. Here is the function I want to optimize : test_function(x){(exp(-0.06751 + 0.25473*((x[1]-350)/150) + 0.04455*((x[2]-40)/20) + 0.09399*((x[3]-400)/100) - 0.17238*((x[4]-250)/50)- 0.45984*((x[5]-550)/150)-0.39508*((x[1]-350)/150)* ((x[1]-350)/150) - 0.05116*((x[2]-40)/20)* ((x[2]-40)/20) - 0.27735*((x[3]-400)/100)*((x[3]-400)/100) -