Fixed-length dynamic array: rolling computation

marcobm

New Member
Joined
Mar 15, 2013
Messages
2
Hello to everyone,
I am kinda new to VBA, and I cannot figure out how to implement a rolling computation. Here's an example of my data:

A C D E F G H
A%theorypracticeerror
0.00520.05-0.0193-0.01982.96E-07a0.0000
0.00390.10-0.0135-0.01369.59E-09b119.5765
-0.01800.15-0.0101-0.01035.76E-08c103.2256
0.01750.20-0.0077-0.00869.61E-07
0.00640.25-0.0058-0.00617.24E-08SSE3.04E-05
0.00630.30-0.0043-0.00441.66E-08
0.00280.35-0.0030-0.00284.99E-08
-0.00220.40-0.0019-0.00151.57E-07
-0.00380.45-0.0009-0.00051.70E-07
0.01460.500.00000.00063.67E-07
0.00490.550.00100.00262.42E-06
0.00580.600.00220.00413.93E-06
0.00880.650.00350.00585.34E-06
-0.02160.700.00490.00735.31E-06
0.02600.750.00670.00884.39E-06
0.00250.800.00890.01062.82E-06
0.00020.850.01170.01342.86E-06
0.00390.900.01560.01661.06E-06
-0.00390.950.02230.02201.13E-07

<tbody>
</tbody>

In column A, I have some numbers. In columns C, some percentiles. In column D, some values, computed according to the parameters a,b,c. In columns E, I take the x percentile of the data in column A, where the x percentile is contained in column C. In column F, I compute the squared difference between the values in columns D and E, and the sum of such squared differences is reported as SSE. Everything is done because, with the solver, I need to minimize SSE changing a,b,c.

The problem arises because the data in column A are around 500, and I need to compute the possible values for a,b,c 250 times by taking a sample of 250 data at a time.

To better explain, the first simulation should do the following:
- in column E, take the range A1:A250 and compute the values corresponding to the percentiles contained in column C;
- then, activate the solver (minimize SSE, changing a,b,c, constraitns: b>0,c>0), which will change the values for a,b,c;
- copy the values of a,b,c somewhere on the right.

The second simulation should, considering the range A2:A251 instead, perform the same tasks.

I call it fixed-length dynamic array because the array is always 250-data long, but the reference data shift by one element dynamically. In the end, my aim is to have a series of 250 simulations of the values of a,b,c, each computed on a different sample.

I have tried implementing this procedure with a macro, but I could not make the "rolling window" work.

Any help for implementing this procedure in VBA?

Thank you very, very much!!

Cross-posted to:

http://stackoverflow.com/questions/15444359/fixed-length-dynamic-array

http://www.excelforum.com/excel-pro...olling-computation.html?p=3160829#post3160829

http://www.ozgrid.com/forum/showthread.php?t=176356&p=654298#post654298

http://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/a9e6804b-daa7-479c-aedd-b5a98d9db603
 
Last edited:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,215,958
Messages
6,127,937
Members
449,412
Latest member
sdescharme

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top