[R] Linear Regression with Constraints

2009-05-26 Thread Stu @ AGS
Hi! I am a bit new to R. I am looking for the right function to use for a multiple regression problem of the form: y = c1 + x1 + (c2 * x2) - (c3 * x3) Where c1, c2, and c3 are the desired regression coefficients that are subject to the following constraints: 0.0 c2 1.0, and 0.0 c3 1.0 y,

[R] Trouble with optim on a specific problem

2009-06-15 Thread Stu @ AGS
Hello! I am getting the following errors when running optim() [I tried optim() with 3 different methods as you can see]: Error in optim(c(0.66, 0.999, 0.064), pe, NULL, method = L-BFGS-B) : objective function in optim evaluates to length 6 not 1 out - optim( c(0.66, 0.999, 0.064),

Re: [R] Trouble with optim on a specific problem

2009-06-16 Thread Stu @ AGS
, 0.0596026490066225, 0.61578947368421) Thank you again, Stu -Original Message- From: Liviu Andronic [mailto:landronim...@gmail.com] Sent: Tuesday, June 16, 2009 2:35 AM To: Stu @ AGS Cc: r-help@r-project.org Subject: Re: [R] Trouble with optim on a specific problem Hello, On 6/16

[R] The most straightfoward way to write a function that sums over the rows of a matrix

2009-06-16 Thread Stu @ AGS
Hello! I am trying to write a function with vector and data.frame parameters that uses the sum() function and values from the rows of the data.frame. I need to pass this function as a parameter to optim(). My starting point is: observs - data.frame(y, x1, x2, x3) Fn - function(par,

Re: [R] Trouble with optim on a specific problem

2009-06-16 Thread Stu @ AGS
Hello, On 6/16/09, Stu @ AGS s...@agstechnet.com wrote: Thanks for your response! No, my basic equation does not use matrices at all. It takes scalar values and returns a scalar. Not quite. Taking the example above, if you run the following: with(observs , {1*x1*x2^2*x3^3}) [1] 0.000e

[R] The R-Inferno

2009-06-16 Thread Stu @ AGS
] Sent: Tuesday, June 16, 2009 11:31 AM To: Stu @ AGS Subject: Re: [R] The most straightfoward way to write a function that sums over the rows of a matrix 'The R Inferno' may be of use to you. Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home

[R] ui and ci explanatory documentation

2009-06-16 Thread Stu @ AGS
Hi Livia and everyone, Did you ever get a response on this question from last year (Jan 2008)? I am also looking for more explanatory documentation on the ui and ci parameters for the function constrOptim(). The examples provided in the R help and the full

[R] Constrained Optimization, a full example

2009-06-16 Thread Stu @ AGS
After a few days of work, I think I nearly have it. Unfortunately, theta is unchanged after I run this (as a script from a file). I thought that theta would contain the fitted parameters. The goal here is to find the least squares fit according to the function defined as rss subject to the

[R] Specifying ui and ci such that ui %*% theta - ci = 0

2009-06-17 Thread Stu @ AGS
Hi, I am a bit stuck on specifying ui and ci. I have read Lange's book ((1999) Numerical Analysis for Statisticians) to his approach and unfortunately his descriptions were not helpful for me. Here is what I have: ui - rbind(c(0, -1, 0), c(0, 0, -1)) ci - c(0, -1, -1))

[R] Curve fit a nonlinear equation with box constraints: success, many thanks!

2009-06-17 Thread Stu @ AGS
Dear R Helper Community! Thank you for all your help and suggestions. For your reference and any future person searching the archives, here is the solution that did what I wanted it to do. As background, my goal was to find the coefficients for the following equation form: y ~ c1 * x1