Hello
I'm trying to reformat my problem below so there is less data entry each time the
package is run.
This is the 'inefficient' version and below in blue is what I would like it to look
like but can't get it to work.
InDATA<- read.table ("C:/Data/March 2004/DATA2.txt",header=T)
WO=dim(InDATA)[1]
DI=dim(InDATA)[2]-1
B <- matrix(rep(0,WO*DI), c(WO,DI))
j=1
while (j <DI+1) {B[,j]=InDATA[,j]
j=j+1
next}
print(B)
y <- matrix(c(InDATA[,DI+1]),c(WO,1))
fr <- function(X) {
for (j in 1:DI) { j <- X[j]}
p <-
matrix(c(X[1],X[2],X[3],X[4],X[5],X[6],X[7],X[8],X[9],X[10],X[11],X[12],X[13],X[14],X[15],X[16],X[17],X[18],X[19],X[20],X[21],X[22],X[23],X[24],X[25],X[26],X[27],X[28],X[29],X[30]),c(30,1))
t(B %*% p-y) %*% (B %*% p-y)
}
optim(c(rep(1,DI)),fr,method="L-BFGS-B",lower=c(488,716,327,77,40,85,1,4,21,4,462,256,366,4697,654,373,664,100,601,1641,700,516,769,617,5372,8079,432,62,4155,2954),
upper=c(1540,859,382,95,50,95,10,5,26,6,538,309,443,5310,757,453,757,424,741,1971,1425,600,1191,720,5373,9329,570,75,5559,6351))
InDATA<- read.table ("C:/Data/March 2004/DATA2.txt",header=T)
WO=dim(InDATA)[1]
DI=dim(InDATA)[2]-1
B <- matrix(rep(0,WO*DI), c(WO,DI))
j=1
while (j <DI+1) {B[,j]=InDATA[,j]
j=j+1
next}
print(B)
y <- matrix(c(InDATA[,DI+1]),c(WO,1))
fr <- function(X) {
for (j in 1:DI) { j <- X[j]}
p <- matrix(cbind(InDATA[1,1:DI]))
t(B %*% p-y) %*% (B %*% p-y)
}
optim(c(rep(1,DI)),fr,method="L-BFGS-B",Lower,Upper)
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html