[R] constrOptim - error: initial value not feasible
Herb
r-p at reggaeboy.de
Wed Mar 17 16:46:16 CET 2010
Hello at all,
working with a dataset I try to optimize a non-linear function with
constraint.
test<-read.csv2("C:/Users/Herb/Desktop/Opti/NORM.csv")
fkt<- function(x){
a<-c(0)
s<-c(0)
#Minimizing square error
for(j in 1:107){
s<-(test[j,2] - (x[1] * test[j,3]) - (x[2] * test[j,4]) - (x[3]*test[j,5]) -
(x[4]*test[j,6]) - (x[5]*test[j,7]))^2
a<- a+s}
a<-as.double(a)
return(a)}
constrOptim(c(0,0,0.5,0,0.5), fkt, NULL, ui=rbind(c(1,1,1,1,1)), ci=c(1)
It works perfekt in the previews way, adding a second constraint, to
simulize the equal to 1 constraint, it doesn't work anymore:
constrOptim(c(0,0,0.5,0,0.5), fkt, NULL,
ui=rbind(c(1,1,1,1,1),c(-1,-1,-1,-1,-1)), ci=c(1,-1))
the error message: initial value not feasible
Thats the structure of the data file:
test
Date CPURNSA_2 SPTR_2 JNGWUS_2 CORP FNAR_2 CRY_2
1 28.02.2001 0.0040 -0.0912 -0.0043 -0.0104 0.0098 -0.0181
2 31.03.2001 0.0023 -0.0634 0.0088 -0.0519 0.0078 0.0013
3 30.04.2001 0.0040 0.0777 0.0202 0.0202 -0.0052 0.0213
4 31.05.2001 0.0045 0.0067 -0.0358 -0.0256 0.0102 0.0194
5 30.06.2001 0.0017 -0.0243 0.0032 -0.0165 0.0045 0.0508
6 31.07.2001 -0.0028 -0.0098 0.0072 -0.0139 0.0280 -0.0234
7 31.08.2001 0.0000 -0.0626 -0.0270 -0.0151 0.0108 0.0275
8 30.09.2001 0.0045 -0.0808 -0.0283 -0.0458 0.0028 -0.0476
9 31.10.2001 -0.0034 0.0191 -0.0034 -0.0254 0.0220 -0.0320
.
.
.
107 31.12.2009 -0.0018 0.0193 0.0040 0.0216 -0.0100 0.0561
May be anyone can see the problem or has an idea?
Thanks in advance!
Herb
--
View this message in context: http://n4.nabble.com/constrOptim-error-initial-value-not-feasible-tp1596640p1596640.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list