I have difficulty implementing the following optimization problem which I know the solution as presented in excel and now I am trying to implement it in R.

The data are :

```Kurt=4
Skew =-0.2
```

as k and t respectively as shown in the picture.

Finding the lower and upper omega is simple in R:

For the lower omega:

```w1 = c(-Kurt-6,0,3,2,1)
f = polyroot(w1)
w11=max(Re(f));w11
[1] 1.206575
```
```w2 = c(-4-(Skew)^2 ,0,3,1)
g = polyroot(w2);g
w22=max(Re(g));w22
wl = max(w11,w22) ;wl
1] 1.206575
```

For the upper omega:

```wu = (-1+(2*(Kurt+2))^(0.5))^(0.5)
wu
[1] 1.569746
```

For the upper and lower omega R agrees with Excel.

Now the problem is that the excel Solver finds the omega value to be 1.56425 but I don't know how to verify it in R.

I tried as well the optimize function for the upper and lower:

```m = function(x){ (4+2*( x^2 - ((Kurt +6) /(x^2+2*x+3) )   ))^(0.5) }
om = function(x){(x-1-m(x) )*(x+2+(m(x) /2))^2 - Skew}
optimize(om,interval = c(wl,wu), maximum = TRUE)
```

but I don't know how to find the result 1.56425 between the upper and lower omega as described in the photo. It makes a Solver in Excel but I don't know to perform it in R.

Excuse me for the photo but stack overflow does not have latex in order to present it properly.

Any help? How can I do it in R?

The excel sheet is the below picture:

Nov 20, 2022 in Others 748 views

## 1 answer to this question.

More details and explanations are required so that people can accurately follow your example. (For example, what is m and why does it depend on x? Instead of seeking a zero, why do you optimize in the final step?).

In any event, you may test Excel's answer by entering it into the equation and seeing if it holds.

Additionally, you can plot your function to determine why the optimization might not succeed:

Also, you can also plot your function in order to see why the optimization might fail:

```plot(x = seq(wl, wu, length.out = 50),
y = om(seq(wl, wu, length.out = 50)))```
• 63,720 points

## Excel VBA : HOW TO PRINT THE TEXT IN A CELL (like Wrap Text)

Use a LineFeed character to create a ...READ MORE

## How can I copy from specific sheet in excel

You should use wb.Sheets("Name of sheet").Copy - ...READ MORE

## Excel - How can I get the average of cells where the value in one column is X and the value in another column is Y?

Use AVERAGEIFS ... =AVERAGEIFS(C2:C13,A2:A13,"Yellow Typ ...READ MORE

Try something along the lines of: for (i ...READ MORE

## Excel, How to split cells by comma delimiter into new cells

The Excel manual method: choose Text to Column ...READ MORE

## Conversion of PDF file to Excel in R

I looked at the pdf, and it ...READ MORE