Welcome to the Cannabis Data Science Meetup Group.
Happy to have you here.
So got a lot to talk about.
So last week we were at MJ Biz, so we didn't have too much material to actually sit down
and work on, so we're going to make it up today.
And even launched a new event, Saturday Statistics.
So you're welcome to join us on Saturdays and then we'll get a little bit more in-depth
about the actual statistics behind what we're doing.
And so we'll do a statistics lesson, supplement that with some cannabis data, and we'll have
a nice fun time of it.
So here's just the standard group for today.
And then you're welcome to find the Saturday morning statistics, which will be a fun time.
So essentially each Saturday I'll make sure that we walk away at the end of the day having
created a beautiful visualization.
And so I heard somewhere that the one in control of the data and the visualization is often
the one in control of the decision.
So if you're able to create some beautiful charts at your organization, then it'll take
you a long way.
So I'll try to make that worthwhile for you.
All right.
So for today, I thought we could dust off a little work we've done in the past and apply
it to the Massachusetts market because that's a market that still have interesting.
So it's still an up and coming market despite there being some established players since
the industry has been around since 2018.
However, it is one of the more strictly regulated markets.
So it is taking certain players longer than expected to get up and running.
So one thing we're going to look at are prices, right?
So in the past, we looked at prices in Oregon and we tried to estimate the output and prices
in Oregon.
And so remember, we were looking at inflation and we can simply define inflation as the
change in prices from the day to yesterday divided by yesterday's prices.
So we'll be interested in inflation as well as output.
So before we dived, well, I guess just a bit of the cannabis information.
So prices dropping precipitously here in Oregon has been a challenge for the producers and
perhaps retailers in Oregon.
Because it's incredibly competitive.
It's really hard to make a profit.
So many people that may have been profitable at a $40 per gram price point may no longer
be profitable.
So I think we may have.
Welcome.
Happy to have you.
So right now we're talking about prices in Oregon.
So let's see.
And we'll maybe do introductions here at the end since we have already dived in or perhaps
we'll take a break in the middle.
So let's just try to.
Hi, Cheyenne.
It's good to have you here.
So I'll try to stay unfocused since I'm already presenting here.
Okay, let's try this one more time.
Pardon the interruptions.
So long story short, we've got historical data in Oregon.
We saw the price point fall.
This made it difficult for producers.
Some producers are still making a good go of it.
We're interested in what may happen in Massachusetts.
So we're going to use some economic models.
As we found out last time with our theoretical models, we were having a hard time getting
them to fit in Massachusetts due to the sporadic nature of the data and the small number of
observations and perhaps the flimsy theory.
So we're going to go with an a theoretical approach this time.
And we're going to introduce a variable, the interest rate.
So we talked about the dynamic here when we talked about Oregon, how the central bank
will try to set interest rates to ultimately keep inflation under control and try to maximize
output.
So you can actually model these economic variables in a system of equations.
And so these are simultaneous equations.
So these are all happening at the same time.
So you've got output y.
And so output today is dependent on output from the past, any given historical periods,
t minus j.
So t minus 1, t minus 2, t minus 3, what have you.
Output today is dependent on inflation in the past.
And then output today is also dependent on the interest rates in the past.
Because investors needed to, well, the producers needed to invest in capital equipment.
And the investors needed to supply a certain amount of capital.
So that's a whole market of its own, the capital market.
Inflation, so what's happening with prices, but governs what's going to happen with output.
So we know that from our economic theory.
And now we've introduced a third player, the central bank.
And so the central bank, they're going to be making their decisions based on past output.
Past inflation, as well as past interest rates.
So you have these simultaneous equations that are happening.
Luckily, we can estimate these because these are nice linear equations.
And we have each of these data points.
So why are we picking this model?
Well, for starters, it's a theoretical model.
It's theoretical.
So we're not imposing any production function assumptions or any assumptions of that sort,
like we have done in previous weeks.
So if you look at the recordings from the prior weeks, we attempted to estimate production
functions in Massachusetts.
As Heather can attest, we were having trouble estimating those models well.
So can we use those models for predicting the future?
You know, perhaps, but they may not be the best predictors.
So what's cool about the VARS is they're flexible.
They can really fit many different data points, as I'll show you here in a bit.
They can fit any frequency.
So we were seeing that, oh, you know, we may have daily, we may have weekly, we may have
monthly, we may even have quarterly data.
So the frequency of the data matters.
Bitfall of the VAR.
If you look here, we have many different variables.
As we were talking about, every variable introduces possibilities for measurement error or what
have you.
And so the top of those concerns, you also have each variable, each way at your degrees
of freedom.
So on that each variable rate to each parameter, right?
So we're going to be estimating all of these parameters.
So our degrees of freedom is going to go down rapidly.
So you have to be careful, because if you're limited to your number of observations, which
we are, it can be difficult to fit a VAR model.
And so you may overfit, which once again can lead to bad forecasts.
So we're going to hedge this.
This is how you can write the VAR.
So this is just a simplified manner.
Let's get to the forecasting.
That's the more interesting part.
So it's easy to forecast with a VAR, right?
And so the first equation is the model we'll be estimating, right?
Where output, inflation, and the interest rate, those all depend on yesterday's values.
Well, given yesterday's values, you can, and you've estimated your parameters, then you
can simply play that one period forward.
So you can just plug in today's values with the parameters you estimated, and you can
get the next period's values.
You can then plug in next period's values with your parameters and get the period after.
So you can do this subsequently, and you can get forecasts for end periods into the future.
So we can predict output, inflation, and interest rate however long we want into the future.
Keep in mind the confidence of our forecasts is going to be increasing the further we go
into the future, but we can still do powerful things, right?
So this is how people can say, oh, what may sales be in 2030, right?
We could play that out.
It could be wildly inaccurate, but we can play that out.
What will sales be like in 2022?
We can play that out.
It will be slightly more accurate than 2030.
Or what would sales be like next month, right?
And then that's going to have the least, the smallest confidence interval.
So we can be a bit more certain about that one, but there's still going to be uncertainty.
And so I want to hit on what a professor boiled down to me as the 10 Commandments of Forecasting.
Right?
And so we'll just go over these real quick since we're about to be doing forecasting.
And I want to have these in everyone's mind, and then we'll go over them at the end just
to make sure that we hit each point.
So we first and foremost need to know what we're forecasting.
That's going to be sales in Massachusetts, right?
Because we want to have an estimate for what sales may be in 2021.
And then we may like to know what sales may be like next year in 2022.
So we can maybe say, making prediction about how much sales may increase or perhaps decrease
next year.
Right?
And then we could perhaps make forecasts all the way to 2025 or 2030 or what have you,
because you're seeing some large analytics firms making predictions that far into the
future.
And like I'd said in the past, I'm not a big fan of the black box approach, because we've
seen how many assumptions are made along the way.
So we're going to make a clear box for forecasting.
Right?
So you can at least look into it and see what gears are turning.
What are the inputs and what are the outputs?
And it's not a black box.
So we're making a nice transparent box right now where you can see the forecasting model.
You can see where you get your data from.
You can see how things are operated and you can see how forecasts are made.
And you can get in there and tinker yourself if you're not satisfied with how we made forecasts
and improve upon what we've done to make even better forecasts.
So that's what we're doing here.
So that's step one.
And really step two, right, the purpose of this is to have a nice transparent mechanism
for forecasting that people can use to have better insights for the future so they can
understand the market better.
The cost of forecasting.
This is where we need to emphasize that there's measurement error and our predictions could
be inaccurate, right, because we don't want people putting too much stake in our forecasts,
right?
Because if you're a producer and you think the market is going to grow by X percent and
the market doesn't grow by X percent, well, you need to have accounted for that in your
business model, right?
Because if you put too much stake into the forecast, sales don't grow as much as you
expect.
You may wind up in the red.
So sometimes it's better to, you know, be a bit more, you know.
Sometimes it's a bit prudent to plan based on the lower ends of the forecast and often
than other times, maybe when you're predicting risk, it may be more prudent to operate in
the upper bounds of the forecast.
So you have to know, you know, is your risk asymmetric or symmetric?
So three is a tricky point and we'll we'll dance around this as we we go through our
estimation.
Four, we've hit on this, so this is the rationalize the forecast horizon.
So what's useful to forecast?
So at the moment, I figured we may as well forecast to the end of the year.
So that way we can go ahead and get an early estimate of the year total.
So slightly valuable.
And then I figured we may as well estimate sales next year.
So that way we can start to to predict to what extent sales may rise or fall.
So I think that would be useful.
And then it perhaps would be useful to forecast through 2025, 2030, just for the fun of things,
just to see how much things may grow.
But I think the utility diminishes in that horizon.
Understand our variables.
Right.
So these are we're going to dive into the deeper here in a second.
But these are the variables that are available to us that match our economic theory and that
fit into our model.
Which forecasting model are we going to use?
We talked about this where we were trying the theoretical approach, not working very
well for us.
We're going to try the a theoretical VAR approach.
Of course, we need to present our results.
Right.
A nice time series visualization would be wonderful.
You need to know how to decipher the results.
Right.
So that's when we're talking about, OK, if sales are going to increase, right, it would
be nice to know about what percentage they're going to increase.
And then these are the two most important points, in my opinion.
One use recursive methods.
So this is essentially what I mean by I boil this down to revisiting the model.
Right.
So we're going to forecast this period and then we can then forecast next period when
the data comes in.
So, you know, just keep iterating.
And then we as we iterate, we may we may find flaws in the model.
And it's OK for us to improve our model over time.
So that's the main thing is we want to revisit our forecasts.
So we want to forecast and then next month we want to come back, check our forecasts
with the actual and use the actual and try to forecast the next month even better.
So just so that's the recursion where each month you come back, you see.
You measure your forecasting error.
And then you use the new actual data to try to create a better a better model and reduce
your forecast error for the next time.
So I think let's get our hands on the data at this point.
So all right.
So just going to use a handful of standard packages here as well as two utility functions
I've written that just help help us clean and clean the data.
Using Python, but you're welcome to use your favorite programming language.
OK.
First things.
Hold on.
We may have a new attendee.
All right.
Awesome to have you, Eric.
Just just wanted to point out that it was a little much for me to get everything ready
for last Saturday for Saturday's statistics.
So I apologize if you were looking for that.
However, I have created the event.
And so this coming Saturday will finally kick off with Saturday's statistics.
And the goal of Saturday's statistics is to walk away with one beautiful visualization
at the end of the day.
Because that's sort of what we're going to emphasize here is how much you can persuade
informed and even entertain people with a nice visualization.
So for today, we're just going to get our hands dirty trying to actually do some forecasting.
So we may make some visualizations.
They may not be beautiful.
But that's why you can tune in on Saturday.
But without further ado, let's get the data.
So I may go over the getting the data quickly, because we've done this a bit more in depth
in prior weeks.
But long story short, at least for Massachusetts, you can get quite rich data through the first
week.
So we're going to start with the Socrata API.
So here we're going to be grabbing the average prices.
This is a monthly series.
And we're also going to be grabbing sales totals.
And this is a daily series that we'll be aggregating into a monthly series.
Data from the Federal Reserve.
So we're going to grab the federal funds rate, which is essentially what economists refer
to when they are talking about the interest rate.
So this is the interest rate the banks pay, and thus it affects all the other interest
rates.
So we're going to get these data points and clean them to a certain extent.
So for example, we need to calculate sales.
So sales total is a cumulative series.
So we need to take the difference of that.
There are also these outliers that aren't rational.
So these are negative sales and sales greater than, I believe this is 10 million in one
day.
And so these appear to be outliers to me.
And so coding them is zero.
And so this is where we're starting to get into how the sausage is made, right?
Because if you're using a black box approach, you wouldn't see these adjustments, or they
may be in a tiny little footnote.
And here we're being quite transparent that, yes, we're dealing with these outliers.
My coding them is zero.
If you have a better approach, then by all means, either fix it or send me an email or
what have you.
Then we'll get it fixed.
And long story short, we can get the sales data here.
And this was throwing us a curveball in prior weeks.
And I finally got an answer at MJBizCon.
And it was real funny because I think I was one of the only people to actually know this
answer.
So there was one of the seminars was this cannabis data game show.
And you had some of the top data scientists from the top analytics companies.
And they were just asking them trivia questions.
And one of the questions was how much cannabis was sold in Massachusetts in April of 2020?
And I had a sneaking suspicion that I knew the answer.
And I guessed it was zero.
And now we know for a fact it is in fact zero.
So these data points here aren't missing.
They in fact suspended sales of cannabis in Massachusetts from I want to say, what was
it like March 24th or so through May 24th or so.
I won't take up too much time with it now.
You can drill down here and get the specific dates.
But long story short, they did actually suspend sales during that period, which I think is
real interesting.
So now it's real interesting for a couple of factors.
One, it's unfortunate because, well, it's unfortunate to maybe the producers or what
have you because it may be fortunate for the people of Massachusetts, who knows.
You saw a spike in most states, right?
So most people went into a buying frenzy.
But then again, economic theory suggests that people may just smooth out their consumption.
So just because they went into a buying frenzy on one date, they may just reduce their consumption
at a later date.
But what have you, Massachusetts suspended sales.
So we're kind of given essentially what you would call a shock, right?
So here you're given this industry and this would be a production shock, right?
Because you're going along, going along, and then we're just going to put a large negative
production shock, the pandemic.
And in this case, Massachusetts, it knocked sales to zero for this set period.
So that's essentially a production shock and we can measure, okay, what effect did that
have on prices?
And also the interest rate, but the interest rate, we may go ahead and make the assumption
that the interest rate's not really determined by output and prices of cannabis in Massachusetts,
which it probably really isn't.
I mean, maybe to a minor, minor degree, but that really depends on much larger scale factors.
But that matters more for identification.
And so long story short, if you're particularly interested in the theory behind VARs, so vector
autoregressions, which we'll get to here in a minute, I'll recommend that you check out
my website.
So this is just keeganskeet.com.
If you go to the PDFs and macroeconomics, I've got a real good section here about these vector
autoregressions.
And so here you'll get all the sources and more in depth about how we're actually estimating
these.
And if you really want to get into the weeds behind the statistics about what assumptions
need to be made in a statistical sense, then I'll let you read into that, get into the
weeds if you wish.
But long story short, we'll estimate the model.
We're not going to get into the weeds yet, perhaps on Saturday.
But for today, we're just going to run through this.
So long story short, we're interested in this production shock and how that's going to
affect prices.
So we can go ahead and create our monthly series here.
And so here we're just aggregating sales.
As you see, in April of 2020, sales dropped to zero.
And then they carry along their way.
And so it's going to be interesting to see if we can't disentangle what effect this shock
may have had.
And then the whole grand scheme is what's cool about these VARs is you can simulate
production shocks, or you can simulate price shocks or interest rate shocks to figure out
what would happen in the future.
So you basically just add a large positive or negative shock to yt.
And then you sort of let that play out in your forecasts.
And you compare that to your forecasts without the shock.
And so you can kind of estimate the effect of the shock.
So I think this is interesting.
And so that's going to require a bit more explanation with statistics.
So this is either something we'll do on Saturday or perhaps next week.
I kind of may say this for next week, because I think the shocks are something that a lot
of people would benefit from understanding.
Because that's sort of seeing things through their logical conclusions.
And I think that's really what's cool about the VARs is you estimate the model.
You use the model to predict the future.
And then you say, OK, what would happen if something changed in the present?
How would that change things in the future?
So that's really quite sophisticated analysis.
And that's sort of what we're moving towards.
And I've gotten near to doing it in the wild, estimating production shocks.
Not quite, but close.
So I think it is something that people can do for companies once you have a nice handle
on all the other statistics.
But first things first, forecasting.
So we've got our sales going along.
Now we can get prices, right?
What do the prices look like?
Well, isn't that interesting?
Of course, prices go to zero if sales.
Well, actually, look, prices didn't necessarily go to zero.
So I think I may want to think about this data point here for a second.
Great, because if there was no sales, you would expect prices to go to.
So these are supposed to be off.
So you'd expect prices to go to zero.
Long story short.
What I would expect is, OK, you've got the production shock.
And so one would expect that in all the periods following April of 2020, that that shock would
have sort of a ripple effect on prices throughout time.
And it seems that here it's an immediate effect.
If we look at our model, right?
So inflation, which is prices, right?
Inflation rate change in price.
So that's dependent on output from yesterday.
So we would expect rate that if output all of a sudden takes a hit, then that's going
to affect prices into the future.
Thus, it's going to affect inflation into the future.
And if inflation is going to be changing, well, that's going to have the the that's
why it's a system of equations, right, because if prices change, then that's going to change
inflation, which is then rate outputs dependent on inflation.
And then rate, the interest rate is dependent rates.
So these are all sort of interdependent on each other.
So that's why we're about to estimate these as a system of equations here.
So we've got our prices.
We're going to go ahead and grab the federal funds rate, which we're going to assume.
You know, we're basically really essentially going to make the assumption rate that inflation
depends on the interest rate and output depends on the interest rate.
But the interest rate doesn't necessarily.
So this is more of an abstract assumption in order to identify your VAR.
But long story short, I'll let you get into the weeds of this.
But check it out, page 96 of Keeganskee.com, macroeconomics.
So it's worth your read because sort of assumptions like this are important because, well, if
you don't correctly identify your VAR with these assumptions, then your output, then
your parameters are biased because these variables, you know, they are dependent on the errors,
right?
Each equation, because it's dependent on the others, it's not independent of the error.
Long story short, you do have to make assumptions in order not to have biased estimators.
But what we're going to see is the VARs are interestingly effective at prediction.
So we may have biased parameters, but we're going to do the Ten Commandments of Forecasting,
right?
So we may have biased parameters, but we're going to compare our forecasts with the actuals
on a month by month basis.
So we can at least judge our bias, right?
So if we can maybe look at our forecasts, right, and we may be consistently over forecasting
or we may be consistently under forecasting.
So that's why it's going to be really important to use these recursive measures, right, because
we'll want to measure our forecasting error from month to month to month.
So that way if we make a forecast and we know, okay, in the past our forecasts have been
under or over, you know, you can kind of take that into consideration.
So it's an imperfect science, but like we say, having a measure is better than no measure,
but definitely hedge the measure with all the assumptions and biases that are built
in.
So that's the best I can tell you.
But we're going to go through the process anyway, so that way you can see the imperfect
nature of forecasting.
If anyone ever asks you to do it, and then you can actually do it for them, and then,
you know, please hedge to them what they need to take into consideration.
So without further ado, hopefully it scared you off enough that you know, you're not going
to replace your life's fortune in these forecasts here.
Okay, so first things first, we actually need to calculate inflation.
And so we were given the prices, so we can actually calculate inflation here.
Okay, just a heads up, in most industries, you would not expect a negative inflation,
so that would be deflation.
Okay, you would expect an increasing or decreasing rate of inflation, but the market wouldn't
be stable unless there is a little bit of inflation.
We talked about this in the past, where as soon as you experience deflation, it's essentially
a race to the bottom, because everybody's just going to be waiting until the future
to make their purchases, right?
And if everybody's waiting for the future to make their purchases, well, outputs just
going to keep coming down and down.
So you don't want to get caught in a deflationary spiral.
You don't want inflation to be out of control either.
So what policymakers are looking for is a steady rate of change of inflation.
So we can maybe rate, so what would the rate of change of inflation be?
Well, just the change of inflation would just be inflation diff.
So right, so anyways, you'd want that to be fairly constant.
As you can see, we've got a big change in inflation happening in August of 2020.
And even actually not even so much, see, it's more the subsequent months, right?
And this is where we were talking about how things are going to play out after various
months, right?
Because it's more, right?
You've got a, yes, you've got a dip in August of 2020, but then the way inflation is calculated,
the change in prices, right?
You've got a big change in May, and then all of a sudden you've got a big change in June,
July.
So it's still white, right?
So this is why you have sort of this ripple effect.
So it's not just like the shock is isolated to one month.
So now we're just going to just look at all of our variables over the same time period
here, right?
So we're basically given inflation rate from December of 2018 through September of 2021.
So we'll just look at all our variables through this time period here.
Awesome.
Oh yeah, that's right.
We're just looking at inflation, not prices.
So now we're going to estimate the system of equations.
So we've got output, inflation, and the interest rate.
And we need to estimate these simultaneously.
And you can actually simply just do this through ordinary least squares.
So this is why we wrote our model here as in matrix form.
So we're just going to estimate our model through ordinary least squares.
So this is where we get into the art of forecasting, right?
So we're given that rate or VOR depends on variables from prior days.
But how many prior periods, not days, periods, right?
Because we're doing monthly here.
So does it depend on just last month?
Does it depend on last month and two months ago?
Does it depend on the whole quarter?
So this is where we try to fit the best VOR from our in-sample data.
So we'll basically try to fit a series of VORs.
So we'll fit, in this case, a VOR 1 through 6.
So we'll say, OK, sales today depend on sales from the prior month, the prior two months,
three, four, five, six months.
We're going to keep doing this.
Keep in mind, we'll run into overfitting, right?
Because say we're trying to say that each equation depends on observations from up to
six periods ago.
Well, then that's going to be six parameters times three for just one equation times three
seconds.
So that would be, what's that, like 40-some parameters?
So if you have a lot of observations, that will be wonderful.
But we're only given 34 observations here because we only have 34 months of data.
So we're not going to be able to estimate a VOR of six.
So we're basically going to try to fit the best fitting VOR that we can with the data
that we have here.
And it actually, right?
So we use stats model to fit all those and select the best order.
So you use a Bayesian information criterion that penalizes you for adding parameters.
So basically, what we're told is the best model is a VOR one.
I suspect that we weren't even able to fit much above a VOR one given the number of observations
we have.
But so this is where, once again, you kind of have to hedge, right?
Because it's like, OK, is the VOR one the best, most accurate model?
Probably not.
But it's the only one that we're really able to fit given our observations.
So once again, we're just going to have to move forward with that, knowing that it's
the best of all of our imperfect options.
So keep that in mind.
And this is where we can get into the recursive nature, right?
Because say in a few months from now, right, or even a year from now or two years from
now, we're going to have more data.
So the more data we get, the more likely we are to be able to fit a higher order VOR model,
which may be a better predictor.
So that's why it's a recursive model.
So each month, we'll see what's the best order VOR that we can fit.
And if we can fit multiple ones, we may want to compare which one actually makes the best
out of sample forecasts.
Because just because you can forecast well in sample, it's out of sample forecasts that
matter, right?
So let's do just that.
So right, we said, OK, we want to go ahead and get forecasts for the rest of this year
plus next year.
So great.
So our data, right, we go through the end of September.
So we want to get observations for October, November, and December, and then the 12 months
next year.
So our horizon is 15 periods and our lag order is 1.
So right, so right, it's real cool, right, because this is how you forecast with the
VOR, right?
So we've just estimated our parameters.
So I wonder if we can just do this.
OK, well, here are our parameters.
So right, we estimated three equations.
For each equation, we've got a constant and three parameters.
So this is alpha y, beta j, gamma j, delta j, right?
And then here, we've got alpha pi, theta j, theta j, lambda j.
And I don't want to keep going through the Greek alphabet, so I'll leave you with the
idea there.
So we've estimated all our parameters.
And so now, the cool thing is we can just plug and play.
So we've got our parameters, a of l.
And now, we can just plug in the observations from September, right?
We can just plug in September output, September inflation, September interest rates, and we
get October's estimates.
Well, we can then take October's estimates, plug them in, use the same parameters, and
we get November's estimates, right?
And so you see how this plays out.
Plug in November's estimates, use your parameters, December's estimates, so on and so forth.
You can code this up yourself.
I've done so.
Or we can just use stats models here and forecast forward.
Get the same result.
And here are our forecasts.
So we have output, right?
So it dips down to zero, going up, dip down, going up.
And here are our forecasts.
As you can see, and Heather can attest that this has been the case in other weeks, our
confidence is really wide.
We've got, right, we don't have a narrow confidence interval here, right?
So sales could take a dip or they could rise.
So this is where if you were doing your business planning, you would need to acknowledge your
cost of forecasting, right?
So it may not be symmetric, right?
It may be asymmetrically worse for you if sales are lower than expected and higher than
expected.
So you may want to over prepare for this lower period, these lower potential sales, right?
So you may want to do some worst case scenario planning and just say, okay, what if sales
dip way down to this threshold?
We'll actually quantify this here in a second because we have these numbers.
And then you can say, okay, so you need to plan for the rainy day scenario here.
We at least have our estimates here.
This is where we get into our wish for a higher order VAR model.
So as you can see, there's not too much dynamism, if that's a word.
There's not too much dynamics with our forecasts here, right?
And that's because of our plug and play nature here, right?
So if you're just going to plug in today's values to get November's values, right, depending
on your parameters, if you just keep plugging in your forecasts, you may lose the dynamic.
You're going to lose some of the variability and you're just going to get sort of these
steady forecasts, which is not really what we would expect.
And so what I've found is if you're able to estimate and fit a higher order VAR model,
you're going to get a bit more dynamics in your estimates, which tend to reduce your
forecasting error.
So that way, your forecasts tend to fluctuate better with the actuals in my experience.
However, we have to start somewhere.
So we now have a crude forecast of output.
We have a crude forecast of inflation.
And then we even have a crude forecast of the federal funds rate.
We're predicting it's going beneath zero, which we may expect.
As we know, interest rates can't go below zero.
And this is where the Federal Reserve is already undoubtedly doing quantitative easing, right,
to effectively push the interest rate below zero.
So interesting dynamics going on there.
Before we conclude, let's go ahead and save our forecasts here.
Because right, that was the whole point of forecasting, right, is we need to get the
forecasts, so that way we can get a crude forecast for 2021, as well as 2022.
Then we need to compare these to actuals.
And just for the sake of brevity here, I'm just going to do this by hand, and then we
can maybe do it programmatically later.
But remember, the dates here, right.
So this is for October 2021.
Let's see if we can't.
Okay, through December 22.
Let's insert some of these past values.
Because basically I'm just curious what these...
What was it?
Monthly...
What was this?
Sorry, bear with me, because I just want to leave today with the last few estimates here.
That way we can at least leave today with our forecast for 2021 and 2022 real quick.
So let's just put this into Excel real quick.
Okay, so like I said, we're just doing this real quick in bare bones just to have some
tangible forecasts by the end of the day.
But basically 2021 sales forecast, then 2022 sales forecast, and then forecasted change
in sales.
So just bear with me if you can stay an extra five minutes so we can actually walk away
with these two numbers.
But basically we're predicting, right.
And like I said, I would prefer to do this programmatically than just hacking it away
real quick in Excel.
Right, we're just hacking away real quick in Excel just so we can get a number.
So let's put this into millions.
Okay.
So we're estimating above 1 billion in sales.
And let's see what the percent change we're forecasting is going to be.
Okay, so this is interesting here.
So real quick, right.
We've, you know, as you can see, they're not the most dynamic forecasts in the world, but
we wanted to get a number.
And we've got an a number here.
We've gotten a couple.
So we're going to go ahead and estimate that sales in 2021 in Massachusetts are going to
be about 1.1 billion in 2021.
And we're also estimating that they're just going to be a little higher than 1.1 billion
in 2022.
So we're only predicting, you know, a 1.2% increase in sales.
I just from my personal experience, working with other states, I foresee that sales are
going to increase by a lot more than 1.2%.
They may not.
So this is where we're going to want to come back and visit this on a month by month basis.
Because is it the case that this giant hit to production in 2020 is still filtering through
the production?
And is this big hit to inflation?
Is this having lasting effects that may just completely lower overall production?
Because there could have been a whole shift in the production function.
So this is where we'll want to come and on a month by month basis, we all want to come
and look at the actual sales.
And so we already know the actual sales through September 2021.
And now what's cool is, you know, the cannabis data science meetup group, we've now made
forecasts all the way through 2022.
So we can start filling in the actuals month by month.
And we may need to add a whole new series of forecasts.
So next month, we may forecast with a different model if this one has wildly inaccurate forecasts.
And so we can just gradually adapt our model, gradually improve it, and see if we can't
hone in our forecasts.
And so this is what's cool.
So you've now attended the meetup group.
We've gotten real cannabis data through the API.
We've talked about the economic theory, as well as an a theoretical statistical model
that we can use for forecasting.
We've now fit the model, created some visualizations, but help to understand the data.
And we've saved these new data points so that way we can continue to make ongoing analysis.
So that's what's real cool about this.
And it's completely transparent, completely open source.
So right after this meetup, I'll go ahead and commit this to the GitHub repository.
So it is MIT licensed.
So you're welcome to use the code for any reason you see fit.
It would just be awesome if you mentioned the authors, tossing the cannabis data science
group if you wish.
And then you're free to use the code however you see fit.
So you're free to expand upon this.
And just to point you in some avenues for further work.
You can also estimate output with two additional VAR models.
So you could estimate output using unemployment.
You could also estimate output using hours worked.
So perhaps on Saturday, I may show you these models.
And so that way you could prepare two additional forecasts.
And this is what it's all about.
So you could have one forecast with one model.
And then we could add on two more forecasts.
And then we can compare the forecast error from all three models.
And then we can see which model predicts the best.
And then we can have a bit more faith in that model going forward.
So that's the beauty to it.
So until next time, you're welcome to use the code.
Try to make some forecasts of your own.
Feel free to email me if you have any questions.
And then definitely check out Saturday Statistics because we may do even more forecasting.
And we're going to walk away at the end of the day with an even, I wouldn't even call
this a beautiful visualization.
So we're going to walk away at the end of the day with a stunning, stunningly beautiful
visualization.
So that's the objective.
And we'll iron down the forecasting a bit more and build up confidence in that.
So we ran a little long today, but hopefully it was worthwhile for you.
Any questions, comments, thoughts, ideas before we conclude today?
Oh, yes.
OK, here, Shayan has some in the chat here.
So yes, so the confidence interval is a 95% confidence interval right out of the gate.
But for actual applications, that's quite a high confidence level.
I found that if you say you're presenting this to your manager or what have you, I think
it's perfectly OK to reduce your confidence to maybe 80% or so.
It's going to reduce your confidence bars, your confidence interval to make your estimates
appear to be a bit more precise.
Once again, you've got to hedge that you're using only an 80% confidence interval.
Also, this bar does not address seasonality.
So once again, Shayan is a whiz here and knows a lot more about this.
So there's a lot you can add on to these bars.
So we use what's called an ARIMA model.
Shayan notes that you can improve upon this in a manner of ways.
So the ARIMA X model is if you want to add on another explanatory variable.
So I'll explain this real quick.
So we've got our output, our inflation, our interest rate.
Well, let's say we want to add on another variable.
Some variables I love to add on are month effects, because you always know what month
it is.
That's the hard thing about adding on explanatory variables is you also have to predict them.
So say you wanted to add on gas prices, well, that's not really that feasible, because you
don't really know what gas prices are going to be a year from now.
What's cool about the month is you do know what the month is going to be a year from
now.
It'll be October.
So that's a cool way you can add on effects.
You can also add on seasonality effects.
And so this is going to be what's called like your moving averages.
So you can kind of take.
So this is, I don't know the seasonality as well, but you can take into account seasonality.
So long story short is, you know, Shayan pointed out some good additional models that you can
extend upon this analysis with.
And that's exactly what I encourage you to do, because this is the whole idea about the
transparent box is, and this is when you like when you see other people's forecasts, you
know, who knows what model they used?
Are they willing to even say what model they used?
And can it be extended upon?
In this case, we just used an ARIMA model.
It can be extended upon.
And by all means, please try.
And then, you know, you may get better forecasts than we made today.
Excellent, excellent question.
All right.
We ran quite a bit over today.
Excellent.
So definitely be in touch.
So we ran a bit over today.
So I'm going to go ahead and conclude it here.
But I think it was a fun day.
So we finally got our hands back on some data and some statistics.
Like I said, I think the visualizations can still be improved upon and we can still do some more modeling.
So let's let's do let's extend upon that on Saturday.
And then next week, I think it'll be fun to get into the exogenous shocks so we can say, OK, what happens if all of a sudden there's a price shock in Massachusetts?
Or what happens if all of a sudden there's a production shock?
And so you can brainstorm about why there may be various shocks, but why we don't have to worry about we can just do the statistics.
But by all means, bring some good stories as to why there may be some good economic shocks.
And then, like I said, we can do the analyses and then you can take these and apply them how you will.
So we originally did these in Oregon.
And so these analyses could be done in Colorado, where I am now or wherever wherever you see fit.
So please, please take what we've provided here and expand upon it.
So. All right, crew, until next time, stay productive and feel free to reach out.
Kinetics is always here to support you.