Re: [R] Stuck using constrOptim

2009-04-24 Thread dre968
I'm very interested. If you wouldn't mind I would love to see it. Thank you for the help. dre968 wrote: > > Trying to use constrOptim to minimize the sum of squared deviations. I > put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to > get v

Re: [R] Stuck using constrOptim

2009-04-23 Thread dre968
so i set gr=Null: > constrOptim(p0,minsquare,Y=Y,Z=Z,NULL,gr=NULL,ui=A,ci=B,method="BFGS") and i recieved the following error: Error in optim(theta.old, fun, gradient, control = control, method = method, : objective function in optim evaluates to length 0 not 1 -- View this message in context

Re: [R] Stuck using constrOptim

2009-04-23 Thread dre968
what a gradient is. any suggestions? dre968 wrote: > > Trying to use constrOptim to minimize the sum of squared deviations. I > put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to > get values for x to minimize the sum of the squared deviations between the > pr

Re: [R] Stuck using constrOptim

2009-04-23 Thread dre968
Sorry for the not enough info. the code seems to work for 10 or so variables but stops optimizing if i give it anymore than that. #Load data Data <- read.table..csv',head=TRUE,sep=",",stringsAsFactors = FALSE) #Load goal variables. this is what i'm trying to minimize to Z<-read.tablecsv

Re: [R] Stuck using constrOptim

2009-04-23 Thread dre968
Sorry i Mean 900x1 not 3x900 below dre968 wrote: > > Trying to use constrOptim to minimize the sum of squared deviations. I > put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to > get values for x to minimize the sum of the squared deviations between the &

[R] Stuck using constrOptim

2009-04-23 Thread dre968
Trying to use constrOptim to minimize the sum of squared deviations. I put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to get values for x to minimize the sum of the squared deviations between the product of x and Y and Z. Anyways i have no problem using this when x is a 3

Re: [R] simple for loop question - how do you exit?

2009-04-23 Thread dre968
Nevermind i got it dre968 wrote: > > I have a loop and an if statement in the loop. once the if statement is > true for 1 value in the loop i'd like to exit the loop. is there a > command to do this? i know its going to be something like exit and i feel > stupid

[R] simple for loop question - how do you exit?

2009-04-23 Thread dre968
I have a loop and an if statement in the loop. once the if statement is true for 1 value in the loop i'd like to exit the loop. is there a command to do this? i know its going to be something like exit and i feel stupid asking this question -- View this message in context: http://www.nabble.c

[R] How do I loop through strings?

2009-04-22 Thread dre968
I read in a CSV file with Data <- read.csv(file="FileName.csv",head=TRUE,sep=",") the file containts strings in the 2nd and 3rd columns and each has about 1000 rows. I need to either loop through the strings there looking for strings that would trigger other logic or remove those rows and put th

[R] Help using spg optimization in BB package

2009-04-22 Thread dre968
i'm trying to use the BB package to minimize the sum of the squared deviations for 2 vectors. The only thing am having trouble with is defining the project constraint. I got the upper and lower bounds to work but i am not sure how to create a constraint that the sum of x must be 1. Any help wou