similar to: Optim with two constraints

Displaying 20 results from an estimated 1000 matches similar to: "Optim with two constraints"

2012 May 08
1
Translation of Linear minimization probelm from matlab to r
Hi everyone, i?m a new user of R and i?m trying to translate an linear optimization problem from Matlab into r. The matlab code is as follow: options = optimset('Diagnostics','on'); [x fval exitflag] = linprog(f,A,b,Aeq,beq,lb,ub,[],options); exitflag fval x=round(x); Where: f = Linear objective function vector (vector of 45,rows) A = Matrix for linear inequality
2009 Feb 16
2
solve.QP with box and equality constraints
Dear list, I am trying to follow an example that estimates a 2x2 markov transition matrix across several periods from aggregate data using restricted least squares. I seem to be making headway using solve.QP(quadprog) as the unrestricted solution matches the example I am following, and I can specify simple equality and inequality constraints. However, I cannot correctly specify a constraint
2001 Jan 04
6
regression constraints?
gday R gurus, I have a multivariate regression for which I want to constrain the coefficients to be > 0. Is this possible? I've check the doco and searched CRAN but can't find anything. thanks, John Strumila -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send
2007 Sep 07
1
'initial value not feasible' in constrOptim
Dear friends. I am using function constrOptim(c(0.5,0.3,0.5), fit.error, fit.error.grr, ui=-1*ui,ci=-1*ci) and I am confronted with error message "initial value not feasible" I plug in the initial value of (0.5,0.3,0.5) to function fit.error and fit.error.grr and have pretty reasonable result. I inequality "ui %*% theta - ci >= 0" as suggested in the R manual and it is
2007 Jul 02
1
QP for solving Support Vector Regression
Dear R users, I'm trying to run the Support Vector Regression by a general quadratic programming function like ipop ( ) in kernlab or solve.QP ( ) in quadprog packages. Since they are general, their application in Support Vector Regression can lead to misunderstanding, particularly when constructing matrices. Even their examples are general and applied in Support Vector
2003 Oct 31
1
help with constrOptim function
Hello. I had previously posted a question concerning the optimization of a nonlinear function conditional on equality constraints. I was pointed towards the contrOptim function. However, I do not understand the syntax of this function with respect to specifying the constraints and so I don’t know if it is what I need. The command is: constrOptim(theta, f, grad,ui,ci,…). “theta” is the
2017 Jul 14
0
Help with R script
@Don your solution does not solve Vijayan's scenario 2. I used spread and gather for that. An alternative solution to insert mising Fval - picking up with Don's newtst - is newtst <- c("FName: fname1", "Fval: Fval1.name1", "FName: fname2", "Fval: Fval2.name2", "FName: fname3", "FName: fname4", "Fval: fval4.fname4")
2017 Jul 13
2
Help with R script
Using Ulrik?s example data (and assuming I understand what is wanted), here is what I would do: ex.dat <- c("FName: fname1", "Fval: Fval1.name1", "Fval: ", "FName: fname2", "Fval: Fval2.name2", "FName: fname3") tst <- data.frame(x = ex.dat, stringsAsFactors=FALSE) sp <- strsplit(tst$x, ':', fixed=TRUE) chk <-
2008 Mar 03
2
Constrained regression
Dear list members, I am trying to get information on how to fit a linear regression with constrained parameters. Specifically, I have 8 predictors , their coeffiecients should all be non-negative and add up to 1. I understand it is a quadratic programming problem but I have no experience in the subject. I searched the archives but the results were inconclusive. Could someone provide suggestions
2017 Jul 13
0
Help with R script
Hi Vijayan, one way going about it *could* be this: library(dplyr) library(tidyr) library(purrr) ex_dat <- c("FName: fname1", "Fval: Fval1.name1", "Fval: ", "FName: fname2", "Fval: Fval2.name2", "FName: fname3") data.frame(x = ex_dat) %>% separate(x, c("F1", "F2"), sep = ": ") %>% filter(F2
2010 Jan 20
2
Error meaning
Hi r-users,   I have the following code to solve 4 simultaneous eqns with 4 unknowns using newton iteration method.  But I got the error message:   pars <- c(1.15, 40, 50, 0.78) newton.input2 <- function(pars) {  ## parameters to estimate      alp <- pars[1]    b1  <- pars[2]     b2  <- pars[3]    rho <- pars[4]   f1 <- pars[1]*pars[2] f2 <-
2009 May 27
1
Constrained fits: y~a+b*x-c*x^2, with a,b,c >=0
I wonder whether R has methods for constrained fitting of linear models. I am trying fm<-lm(y~x+I(x^2), data=dat) which most of the time gives indeed the coefficients of an inverted parabola. I know in advance that it has to be an inverted parabola with the maximum constrained to positive (or zero) values of x. The help pages for lm do not contain any info on constrained fitting. Does anyone
2004 Aug 09
4
linear constraint optim with bounds/reparametrization
Hello All, I would like to optimize a (log-)likelihood function subject to a number of linear constraints between parameters. These constraints are equality constraints of the form A%*%theta=c, ie (1,1) %*% 0.8,0.2)^t = 1 meaning that these parameters should sum to one. Moreover, there are bounds on the individual parameters, in most cases that I am considering parameters are bound between zero
2007 Dec 05
1
Quadratic programming
Hi, I'm quite new at R and I haven't found the answer to my question anywhere on the net, so either it is trivial or not documented. So, bare with be. I am using the quadprog package and its solve.QP routine to solve and quadratic programming problem with inconsistent constraints, which obviously doesn't work since the constraint matrix doesn't have full rank. A way to solve this
2012 Mar 16
1
quadprog error?
I forgot to attach the problem data, 'quadprog.Rdata' file, in my prior email. I want to report a following error with quadprog. The solve.QP function finds a solution to the problem below that violates the last equality constraint. I tried to solve the same problem using ipop from kernlab package and get the solution in which all equality constraints are enforced. I also tried an old
2008 Jun 17
2
constrOptim with method = "L-BFGS-B"
Hi, i need to minimize a quadratic function with boundary condidtions and one equality condition. In order to do that i converted the equality constraint into 2 inequality constaints and passed everything cia constrOptim, as the manual said: everything included in the ... will be passed to Optim that will pass it back to fn in case it does not need it. My code is the following: mat <-
2009 Oct 20
1
Buglet in optim() SANN
I think SANN method in optim() is failing to report that it has not converged. Here is an example genrose.f<- function(x, gs=NULL){ # objective function ## One generalization of the Rosenbrock banana valley function (n parameters) n <- length(x) if(is.null(gs)) { gs=100.0 } fval<-1.0 + sum (gs*(x[1:(n-1)]^2 - x[2:n])^2 + (x[2:n] - 1)^2) return(fval) }
2007 Sep 25
2
Constraining Predicted Values to be Greater Than 0
I have a WLS regression with 1 dependent variable and 3 independent variables. I wish to constrain the predicted values (the fitted values) so that they are greater than zero (i.e. they are positive). I do not know how to impose this constraint in R. Please respond if you have any suggestions. There are some previous postings about constraining the coefficients, but this won't accomplish
2008 Sep 12
2
[LLVMdev] Selection Condition Codes
I am attempting to lower the selectCC instruction to the instruction set of the backend I'm working on and I cannot seem to find a way to correctly implement this instruction. I know how this instruction should get implemented; I just have yet to find a way to do it. I want the select_cc instruction to be lowered into a comparison followed by a conditional move. I've attempted to use a
2005 Oct 19
1
ipop (kernlab) gives pars < lower bound ?
hi everyone, ipop very quickly and accurately identifies the correct parameters in a toy dataset i built, but when i use ipop on the real dataset i get values for the parameters " primal(res) " that are less than zero, even though i specify zero for the lower bound : l = rep(0, length(c)) , where length(c) is the number of parameters i'm trying to identify. the parameters are