How do I solve a maximization equation with constraints in R? - r

I'm having difficulties solving a maximization problem with constraints in R.
I've tried using constrOptim(), but i can't figure out what theta is or should be equal to.
Can anyone help?

Use the logarithm to get linear constraints and then use the constrOptim function.

Related

R function to solve a quadratic equation

I am trying to solve for x of the following quadratic equation:
where
a_i<-c(9,27,37,47)
b_i<-c(70,35,24,6)
a=sum(a_i)
b=sum(b_i)
d_i<-c(1,-1,-1,1)
I am not sure what kind of R function I should use. I tried uniroot but could not solve it. Would anyone guide me on this?

Mathematical constrained optimization in R

I have a mathematical optimization which I wish to solve in R consider this system/problem:
How Can I solve this problem in R?
In this model Budget, p_l for all l and mu_target are fixed constants while muis a given m-dimensional vector and R is a given n by m matrix.
I have looked into constrOptim and lp but I don't have the imagination to implement the constraints
Those functions require that I have a "constraint" matrix but my problem is that I simply don't know how to design that constraint matrix. There are not many examples with decision variables on both sides of the equations.
Have a look on the nloptr package. It has quite extensive documentation with examples. Lots of algorithms to choose from, depending what problem you are trying to resolve.
NLoptr link

SVM using quadprog in R

This set of exercises has the student use a QP solver to solve an SVM in R. The suggested solver is the quadprog package. The quadratic problem is given as:
From the remark about the linear SVM, $K=XX'$, $K$ is a singular matrix usually, at most rank $p$ where $X$ is $n\times p$. But the solver quadprog requires a positive definite matrix, not just PSD, in the place of $K$, as mentioned many places (and verified). Any ideas what the instructor had in mind?
I think the workaround would be to add a small number (such as 1e-7) to the diagonal elements of the matrix which is supposed to be positive definite. I am not certain about the math behind it, but the sources below, as well as my experience, suggest that this solution works.
source: https://stats.stackexchange.com/questions/179900/optimizing-a-support-vector-machine-with-quadratic-programming
source: https://teazrq.github.io/stat542/hw/HW6.pdf

Solve Algebraic Riccati Equation in R

I know that it's quite simple to solve the equation in Matlab. But is there a way to solve it in R as well? I need it for my Kalman filter implementations.

Find the x value based on a regression inverse function in R

I was seeking for solutions to inverse functions in R. The uniroot() indicates a possible to do this, however I don't know how.
My problem is quite simple, I guess. I have a nonlinear regression as trigonometric function:
function(d,x) d*sqrt(-0.9298239*(x-1)+0.0351246*sin(2.0737115*pi*x)+0.0037540*(1/tan(pi*x/2)))
I need to find the x value based on y value. How can I do that?
Edit: If I plot the curve using the expression (f(x)-y) I have something like the image below. Now, how could I extract the value that minimizes in zero?
minimization

Resources