Displaying 6 results from an estimated 6 matches for "moweightsmax".
2018 May 03
4
adding overall constraint in optim()
...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 <- as.vector(tail(head(mo,i),1))
wgt.vect <- as.vector(tail(head(moWeightsMax,i),1))
cov.mat <- cov(tail(head(morets,i+12),12))
opt.fun <- function(wgt.vect) -sum(Mo.vect %*% wgt.vect) / (t(wgt.vect) %*% (cov.mat %*% wgt.vect))
LowerBounds<-c(0.2,0.05,0.1,0,0,0)
UpperBounds<-c(0.6,0.3,0.6,0.15,0.1,0.2)
OptimSolution<-optim(wgt.vect,...
2018 May 03
0
adding overall constraint in optim()
...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 <- as.vector(tail(head(mo,i),1))
> wgt.vect <- as.vector(tail(head(moWeightsMax,i),1))
> cov.mat <- cov(tail(head(morets,i+12),12))
> opt.fun <- function(wgt.vect) -sum(Mo.vect %*% wgt.vect) / (t(wgt.vect) %*% (cov.mat %*% wgt.vect))
>
> LowerBounds<-c(0.2,0.05,0.1,0,0,0)
> UpperBounds<-c(0.6,0.3,0.6,0.15,0.1,0.2)
>
> O...
2018 May 03
2
adding overall constraint in optim()
...>>
>> 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 <- as.vector(tail(head(mo,i),1))
>> wgt.vect <- as.vector(tail(head(moWeightsMax,i),1))
>> cov.mat <- cov(tail(head(morets,i+12),12))
>> opt.fun <- function(wgt.vect) -sum(Mo.vect %*% wgt.vect) / (t(wgt.vect) %*% (cov.mat %*% wgt.vect))
>>
>> LowerBounds<-c(0.2,0.05,0.1,0,0,0)
>> UpperBounds<-c(0.6,0.3,0.6,0.15,0.1,0.2)...
2018 May 04
0
adding overall constraint in optim()
...gt;> 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 <- as.vector(tail(head(mo,i),1))
>>> wgt.vect <- as.vector(tail(head(moWeightsMax,i),1))
>>> cov.mat <- cov(tail(head(morets,i+12),12))
>>> opt.fun <- function(wgt.vect) -sum(Mo.vect %*% wgt.vect) / (t(wgt.vect) %*% (cov.mat %*% wgt.vect))
>>>
>>> LowerBounds<-c(0.2,0.05,0.1,0,0,0)
>>> UpperBounds<-c(0.6,0....
2018 May 06
1
adding overall constraint in optim()
...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 <- as.vector(tail(head(mo,i),1))
> >>> wgt.vect <- as.vector(tail(head(moWeightsMax,i),1))
> >>> cov.mat <- cov(tail(head(morets,i+12),12))
> >>> opt.fun <- function(wgt.vect) -sum(Mo.vect %*% wgt.vect) /
> (t(wgt.vect) %*% (cov.mat %*% wgt.vect))
> >>>
> >>> LowerBounds<-c(0.2,0.05,0.1,0,0,0)
> >>>...
2018 May 05
1
adding overall constraint in optim()
Hi,
You can use the projectLinear argument in BB::spg to optimize with linear equality/inequality constraints.
Here is how you implement the constraint that all parameters sum to 1.
require(BB)
spg(par=p0, fn=myFn, project="projectLinear", projectArgs=list(A=matrix(1, 1, length(p0)), b=1, meq=1))
Hope this is helpful,
Ravi
[[alternative HTML version deleted]]