[R] Most appropriate function for the following optimisation issue?
Berend Hasselman
bhh at xs4all.nl
Tue Oct 20 16:20:53 CEST 2015
> On 20 Oct 2015, at 15:35, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
>
> On 20/10/2015 6:58 AM, Andy Yuan wrote:
>> Hello
>>
>> Please could you help me to select the most appropriate/fastest function to use for the following constraint optimisation issue?
>
> Just project S into the space orthogonal to B, i.e. compute the
> residuals when you regress S on B (with no intercept). For example,
>
> X <- lsfit(B, S, intercept=FALSE)$residuals
>
And you can use an alternative like this with package nloptr using functions
library(nloptr)
f1 <- function(x) sum(crossprod(x-S))
heq <- function(x) sum(B * x)
# Check lsfit solution
f1(X)
heq(X)
slsqp(c(0,0,0),fn=f1,heq=heq)
Berend
More information about the R-help
mailing list