Re: [R] Maximization problem in the optim function

2012-03-14 Thread Niroshan
This is the part of the function in my likelihood function prob<-function(t1,t2,m1,m2,s_r,s_p,s_e,cor_m){ if ((t1==0) & (t2==0)) log_lik<-log(pmvnorm(lower=rep(-Inf, 2), upper=c(m1/sqrt(s_r+s_p+s_e+1),m2/sqrt(s_r+s_p+s_e+1)), mean=rep(0,2), corr=cor_m)) else if ((t1==0) & (t2==1)) log_lik<

Re: [R] Maximization problem in the optim function

2012-03-14 Thread R. Michael Weylandt
What distribution's log-likelihood are you using? If sigma is supposed to be square-rooted, you may have to put a constraint or use of abs() might suffice -- though, admittedly I'm not sure what that will do to convergence behavior -- but it's hard to help without seeing the function at hand. Mich

[R] Maximization problem in the optim function

2012-03-14 Thread Niroshan
Dear R Users I am maximizing a user defined log likelihood function. It includes variance parameter (sigma). I used R function optim with BFGS maximization method. However, it stops before the solution saying “sqrt(sigma): NaNs produced” Could anybody know a proper transformation for sigma which

Re: [R] Maximization

2011-10-30 Thread Paul Smith
On Tue, Oct 25, 2011 at 12:04 PM, Eliano wrote: > hi people, > > I'm trying to maximize this function: > > fn= function (x) {x[1]^2+5*x[2]^2} > > with this restriction > fn1 = function (x) {x[1]+x[2] <=5} > > Can someone help me how to procedure this? > > I tried in the alabama and genoud package

Re: [R] Maximization Problem

2011-10-25 Thread cberry
Eliano Marques writes: > Hi there, > > I need help in an optimization procedement. > > I'm trying to maximize the function fn=x^2+5y^2 with the restriction of > fn1=x-y<=5. > > I tried the genoud method and as well the alabama method. > > I have problems to set the constraint in R. > > Can someon

[R] Maximization Problem

2011-10-25 Thread Eliano Marques
Hi there, I need help in an optimization procedement. I'm trying to maximize the function fn=x^2+5y^2 with the restriction of fn1=x-y<=5. I tried the genoud method and as well the alabama method. I have problems to set the constraint in R. Can someone help me please? Regards, Eliano

[R] Maximization

2011-10-25 Thread Eliano
hi people, I'm trying to maximize this function: fn= function (x) {x[1]^2+5*x[2]^2} with this restriction fn1 = function (x) {x[1]+x[2] <=5} Can someone help me how to procedure this? I tried in the alabama and genoud package but i have problems with the setting of constrains. Regards, Eliano

Re: [R] Maximization of a loglikelihood function with double sums

2011-05-14 Thread Ravi Varadhan
-help-boun...@r-project.org] On Behalf Of Klaus Langohr [klaus.lang...@upc.edu] Sent: Thursday, May 12, 2011 3:29 PM To: r-help@r-project.org Subject: [R] Maximization of a loglikelihood function with double sums Dear R experts, Attached you can find the expression of a loglikelihood function which I

Re: [R] Maximization of quadratic forms

2010-05-18 Thread Ravi Varadhan
Tuesday, May 18, 2010 2:38 pm Subject: [R] Maximization of quadratic forms To: r-help@r-project.org > Dear R Help, > > I am trying to fit a nonlinear model for a mean function > $\mu(Data_i,\beta)$ for a fixed covariance matrix where $\beta$ and > $\mu$ are low-dimensional

[R] Maximization of quadratic forms

2010-05-18 Thread Russell Shinohara
Dear R Help, I am trying to fit a nonlinear model for a mean function $\mu(Data_i, \beta)$ for a fixed covariance matrix where $\beta$ and $\mu$ are low- dimensional. More specifically, for fixed variance-covariance matrices $\Sigma_{z=0}$ and $\Sigma_{z=1}$ (according to a binary covariate $

Re: [R] Weighted Sum Optimization in R (Maximization)

2008-11-12 Thread GR
There is a package "lpSolve" that you might want to look at. At the R prompt, do the following: > install.packages("lpSolve") Once the package will be installed, you can type help(lpSolve) to get details. cheers, -Girish On Nov 13, 8:37 am, "Yun, Myung Ho" <[EMAIL PROTECTED]> wrote: > Dear All,

Re: [R] Weighted Sum Optimization in R (Maximization)

2008-11-12 Thread Prof Brian Ripley
This is 'linear programming'. Try RSiteSearch("linear programming") The first few fits will give you a lot to explore. On Thu, 13 Nov 2008, Yun, Myung Ho wrote: Dear All, First of all, this is the first time for me to use R for optimization, I tried to search r-help postings & googled on wei

[R] Weighted Sum Optimization in R (Maximization)

2008-11-12 Thread Yun, Myung Ho
Dear All, First of all, this is the first time for me to use R for optimization, I tried to search r-help postings & googled on weighted sum optimization, I could not find anything applicable. I would need to optimize following function in R; MAXIMIZE function = w1*R1 + w2*R2 + w3*R3 + w4*R

Re: [R] maximization under constraits

2008-08-08 Thread bartjoosen
You wrote MAXIMIZE this function, why not using the maximize option of constrOptim? If you read the help file, you will find that if you set the control fnscale to a negative value, maximisation is performed. constrOptim(c(1,1),neg_loglik, grad=NULL, ui=rbind(c(1,0),c(0,1)), ci=c(0,0),control=li

[R] maximization under constraits

2008-08-07 Thread Daniela Garavaglia
I'm an Italian student looking for help. How can I maximize this function? neg_loglik<-function(param){ a<-param[1] b <-param[2] -(log(pr)-(a*s2)-(b*s)+n*log(2*a)-n*log(1-(b/sqrt(a))*exp((b^2)/(4*a))*(sqrt (pi))*(1-pnorm(b/(2*sqrt(a)), mean=0, sd=1))*1)) } Con > pr

Re: [R] Maximization under constraits

2008-07-27 Thread Ritwik Sinha
Hi Daniela, Will the "optim" function with the method "L-BFGS-B" work for you? Look for the "lower" argument in the function. Ritwik On Fri, Jul 25, 2008 at 9:07 AM, Daniela Garavaglia <[EMAIL PROTECTED]> wrote: > > I'm looking for a R function which can maximise this logliklihood function, > un

Re: [R] Maximization under constraits

2008-07-25 Thread Ben Bolker
Daniela Garavaglia virgilio.it> writes: > > I'm looking for a R function which can maximise this logliklihood function, > under the constraits a>0 e b>0 > > f<-function(param){ > > a<-param[1] > > b <-param[2] > > log(prod)-(a*s2)-(b*s)-n*log(1-((0.5*b/sqrt(a))*(exp((b^2)/(4*a)))*((sqrt(

[R] Maximization under constraits

2008-07-25 Thread Daniela Garavaglia
I'm looking for a R function which can maximise this logliklihood function, under the constraits a>0 e b>0 f<-function(param){ a<-param[1] b <-param[2] log(prod)-(a*s2)-(b*s)-n*log(1-((0.5*b/sqrt(a))*(exp((b^2)/(4*a)))*((sqrt(pi ))*(1-pnorm(-b/(2*sqrt(a)), mean=0, sd=1)} I've tri