Grid Control and Forecasting data
Author Message
Grid Control and Forecasting data

I am using the grid control and some text controls to forecast some data using
exponential smoothing. I am not quite sure how to do the formulas so that the
data goes into the GRID and it is flexible.

The formula is as follows:

F(t) = F(t-1) + alpha[A(t-1) - F(t-1)]

F(t)    = forecast for time period t
F(t-1) = forcast for time period (t-1)
A(t-1)  = Actual value of variable being forecast in period (t-1)
alpha = smoothing constant.

The Actual values (A) will be in columnA and the Forecast will be in ColumnB

alpha will be input by the user using a text box.

There is also another textbox that will ask for input as to how many periods
the user would like to forecast.

For example if there is 100 rows of data in columnA and the user wants to
forecast for 10 more rows, then ColumnB should have 110 rows of data in it.

Any help or attached files would be greatly appreciated  !!

Don

Thu, 21 Jan 1999 03:00:00 GMT
Grid Control and Forecasting data

Quote:
>The formula is as follows:
>F(t) = F(t-1) + alpha[A(t-1) - F(t-1)]
>F(t)    = forecast for time period t
>F(t-1) = forcast for time period (t-1)
>A(t-1)  = Actual value of variable being forecast in period (t-1)
>alpha = smoothing constant.

Is this a weather forecast? :)

Quote:
>For example if there is 100 rows of data in columnA and the user wants to
>forecast for 10 more rows, then ColumnB should have 110 rows of data in it.

Either you're confusing the words columns and rows here, or I don't see
what you want to do.

In a grid, you always have the same number of columns for each row, and the
same number of rows for each column. There's nothing you can do about that,
meaning you can't have 110 rows for column B only - column A will get them
too.

IMO, it's better design to let the data come in columns, and the data sets
come in rows. In your case, this would mean that the Actual values would go
in row nr. 1, and the Forecast values in row nr. 2. Then the data for each
data set would go in the columns from 1 to 100 (or 110). FTR, Actual values
are one data set, and Forecast values are another data set.

But this depends on how the user will interpret the data. If there is a
strict correlation between Actual values and Forecast values, and the user
would want to read them both at the same time, then you're better off
arranging the data in rows and the data sets in columns. If the Actual
values are of no interest to the user, and is only used by your app in the
computing process, it should be the way I described it.

Now for how to populate the grid. If you have the Actual values already in
an array, you'd do it like this:

Grid.Row = StartingRow
For i% = 1 To NumberOfForecasts
Forecast = LastForecast + Alpha * (Actual(i%) - LastForecast)
' This is your row/column layout
' If you haven't already added the necessary rows to the grid, do this:
Grid.Row = Grid.Row + 1
' Add actual value to column number 1
Grid.Col = 0: Grid.Text = CStr(Actual(i%))
' Add forecast value to column number 2
Grid.Col = 1: Grid.Text = CStr(Forecast)
LastForecast = Forecast
Next i%

If you have the Actual data in the grid, you'd have to get the Actual value
from the grid inside the loop.

Once, a friend of my dad did a little research on weather forecasting, and
he did it like this:

1. Is today's weather the same as yesterday's (with few changes): Yes / No
2. Was the weather forecast precise: Yes / No

He did this for half a year, and found that the answer to number 1 was Yes
68% of the time, and the answer to number 2 was Yes 70% of the time. So the
weather forecast's equipment and satelites increased your chances of
forecasting the right weather by 2%.

--
Sex isn't the answer. Sex is the question. Yes! is the answer

Thu, 21 Jan 1999 03:00:00 GMT

 Page 1 of 1 [ 2 post ]

Relevant Pages