similar to: adding overall constraint in optim()

Displaying 20 results from an estimated 300 matches similar to: "adding overall constraint in optim()"

2018 May 03
4
adding overall constraint in optim()
Hi ? This is giving me a headache. I?m trying to do a relatively simple optimization ? actually trying to approximate the output from the Excel Solver function but at roughly 1000x the speed. ? The optimization parameters look like this. The only trouble is that I want to add a constraint that sum(wgt.vect)=1, and I can?t figure out how to do that in optim. Mo.vect <-
2018 May 03
2
adding overall constraint in optim()
Thanks Bert. But everyone on that forum wants to use finance tools rather than general optimization stuff! And I am not optimizing a traditional Markowitz mean-variance problem. Plus, smarter people here. :-) > On May 3, 2018, at 3:01 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote: > > You can't -- at least as I read the docs for ?optim (but I'm pretty > ignorant
2018 May 03
0
adding overall constraint in optim()
You can't -- at least as I read the docs for ?optim (but I'm pretty ignorant about this, so maybe there's a way to tweak it so you can). See here: https://cran.r-project.org/web/views/Optimization.html for other R optimization capabilities. Also, given your credentials, the r-sig-finance list might be a better place for you to post your query. Cheers, Bert Bert Gunter
2018 May 04
0
adding overall constraint in optim()
On Thu, May 3, 2018 at 2:03 PM, Michael Ashton <m.ashton at enduringinvestments.com> wrote: > Thanks Bert. But everyone on that forum wants to use finance tools rather than general optimization stuff! And I am not optimizing a traditional Markowitz mean-variance problem. Plus, smarter people here. :-) > I'm very confused by these statements. Most of the "finance tools"
2018 May 06
1
adding overall constraint in optim()
Hi Michael, A few comments 1. To add the constraint sum(wgt.vect=1) you would use the method of Lagrange multipliers. What this means is that in addition to the w_i (the components of the weight variables) you would add an additional variable, call it lambda. Then you would modify your optim.fun() function to add the term lambda * (sum(wgt.vect - 1) 2. Are you sure that you have defined
2005 Jan 13
1
how to use solve.QP
At the risk of ridicule for my deficient linear algebra skills, I ask for help using the solve.QP function to do portfolio optimization. I am trying to following a textbook example and need help converting the problem into the format required by solve.QP. Below is my sample code if anyone is willing to go through it. This problem will not solve because it is not set up properly. I hope I
2010 Feb 02
2
Subset and plot
Here is a runable program. When I plot Day and Wgt, it graphs all the data points. All I need is daily.sub1 plotted. I also need each "Tanks" to have its own col or pch. When I run it with the line with pch, it gives me nothing. rm(list=ls()) Trial<-rep(c(1,2),each=12) Tanks=rep(c("a3","a4","c4","h4"),each=3,2) Day=rep(c(1:12),2)
2007 Sep 03
2
The quadprog package
Hi everybody, I'm using Windows XP Prof, R 2.5.1 and a Pentium 4 Processor. Now, I want to solve a quadratic optimization program (Portfolio Selection) with the quadprog package I want to minimize (\omega'%*%\Sigma%*%\omega) Subject to (1) \iota' %*% \omega = 1 (full investment) (2) R'%*%\omega = \mu (predefined expectation value) (3) \omega \ge 0 (no short sales). Where
2009 May 31
1
Bug in gmodels CrossTable()?
Is the code below showing a bug in Crosstable()? My expectation was that the values produced by xtabs were rounded instead of truncated: library(gmodels) abc <- c("a", "a", "b", "b", "c", "c") def <- c("d", "e", "f", "f", "d", "e") wgt <- c(0.8, 0.6, 0.4, 0.5, 1.4, 1.3)
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
2004 Sep 21
2
Ever see a stata import problem like this?
Greetings Everybody: I generated a 1.2MB dta file based on the general social survey with Stata8 for linux. The file can be re-opened with Stata, but when I bring it into R, it says all the values are missing for most of the variables. This dataset is called "morgen.dta" and I dropped a copy online in case you are interested http://www.ku.edu/~pauljohn/R/morgen.dta looks like this
2011 May 30
0
definition of meq at spg
For my problem I have #Constraints b11<-0 b21<-0 b12<-0 b22<-0 n1>=0 n2>=0 n1<=1 n1<=1 n1+n2=1 In order to use spg I set Amat<-matrix(rbind(c(rep(0,10)),c(rep(0,10)),c(rep(0,2),1,rep(0,7)), c(rep(0,3),1,rep(0,6)),c(rep(0,10)),c(rep(0,10)), c(rep(0,6),1,rep(0,3)),c(rep(0,7),1,rep(0,2)), c(rep(0,8),1,rep(0,1)),c(rep(0,9),1,rep(0,0)),
2013 Mar 15
1
quadprog issues---how to define the constriants
Hi list: This is my first time to post my question on the list. Thanks for your help. I am solving a quadratic programming using R. Here is my question: w = arg min 0.5*w'Mw - w'N s. t. sum(w) = 1; w>0 note: w is weight vector, each w_i must >=0, and the sum of w =1. Here is my R code: A <-matrix(c(2.26,1.26,1.12,1.12,2.27,1.13,1.12,1.13,2.2),3,3); B <-
2010 Feb 02
1
Subset and point plot
OK, I need help plotting. I have column headings of Day, Wgt, Foodin, Rep, Grp and Tanks. Rep=c(1,2,3) and Tanks=c(a1,a2,a3,a4,a5,a6, c1,c2,c3,c4,c5,c6, h1,h2,h3,h4,h5,h6). I created a subset where I only would like Rep=2, and Tanks=c(a4,c4,h4) and would like to graph (points) of Wgt and Day. I would think that I only need 3 colors, but when I run with only 3, only 2 lines show up. When I add
2006 Apr 19
1
Trouble with glm() .... non-integer #successes in a binomial glm
Hi R-people: When I use the command to fit a model with an intercept, only: glm ( formula=haspdata ~ 1, data=dat, family=binomial, weights= dat$hy.wgt.s, subset=(dat$haspdat0!=3) ) I get the message: Warning message: non-integer #successes in a binomial glm! in: eval(expr, envir, enclos) Does anyone know what this means?? The data for this command is listed below. Thanks, Phil Smith CDC
2009 Nov 14
4
Weighted descriptives by levels of another variables
I've noticed that R has a number of very useful functions for obtaining descriptive statistics on groups of variables, including summary {stats}, describe {Hmisc}, and describe {psych}, but none that I have found is able to provided weighted descriptives of subsets of a data set (ex. descriptives for both males and females for age, where accurate results require use of sampling
2003 Aug 24
1
regression constraints (again)
Im trying to do regressions with constraints that the weights are all >=0 and sum(weights) = 1. I've read the archive and have set the problem up with solve.QP and just the non-negativity constraints along the lines of: y as the data vector X as the design matrix D <- t(X) %*% X d <- t(t(y) %*% X) A <- diag(ncol(X)) b <- rep(0,ncol(X)) fit <-
2005 Nov 29
1
Constraints in Quadprog
I'm having difficulty figuring out how to implement the following set of constraints in Quadprog: 1). x1+x2+x3+x4=a1 2). x1+x2+x5+x6=a2 3). x1+x3+x5+x7=a3 4). x1+x2=b1 5). x1+x3=b2 6). x1+x5=b3 for the problem: MIN (x1-c1)2+(x2-c2)2+...+(x8-c8)2. As far a I understand, "solve.QP(Dmat, dvec, Amat, bvec, meq=0, factorized=FALSE)" reads contraints using an element-by-element
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
2010 Sep 27
3
Alphabetical sequence of data along the x-axis in a box plot
Hello All, I noticed when I generated some boxplots, the data is presented in alphabetical order along the x-axis (the data in this case was the four quandrants of a sample area (NE,NW, SE, SW) that was my first column of data). Is there a way to have R plot the data in a different order? I imagine you could use a dummy variable, but didn't know if there might be a simple argument that