negative values kernel density estimation

I have obtained the monthly temperature distribution using kernel density estimate. And using SVD(Singular Value Decomposition) and regression model, I forecast the monthly temperature distribution. But I found that some estimated kernel density values are negative. How to deal with these negative values?

10 Comments

It might be easier to have opinions if you could share a figure illustrating this.
Code snippets are helpful, too, so we can see exactly what you're doing.
ZHIMIN YAN
ZHIMIN YAN on 21 Dec 2022
Edited: Adam Danz on 21 Dec 2022
[U,S,V] = svd(z);
U1 = U(:,1);
Mdl = arima('Constant',0,'ARLags',1,'SARLags',12,'D',1,...
'Seasonality',12,'MALags',1,'SMALags',12);
EstMdl = estimate(Mdl,U1);
numperiods = 11;
[Forecast,ForecastMSE] = forecast(EstMdl,numperiods,U(:,1));
Tempdiff_forecast = Forecast*S(1,1)*V(:,1)';
z is kernel density value, and Tempdiff_forecast is kernel density forecast value. And some values are negative. How to deal with these negative values?
Could you provide the z values?
This is z values. Thank you very much!!
zmat = load("z.mat");
z = zmat.z;
[U,S,V] = svd(z);
U1 = U(:,1);
Mdl = arima('Constant',0,'ARLags',1,'SARLags',12,'D',1,...
'Seasonality',12,'MALags',1,'SMALags',12);
EstMdl = estimate(Mdl,U1);
ARIMA(1,1,1) Model Seasonally Integrated with Seasonal AR(12) and MA(12) (Gaussian Distribution): Value StandardError TStatistic PValue ________ _____________ __________ ___________ Constant 0 0 NaN NaN AR{1} 0.04126 0.054551 0.75636 0.44944 SAR{12} -0.1694 0.049563 -3.4179 0.00063099 MA{1} -0.81241 0.036031 -22.548 1.4186e-112 SMA{12} -0.78822 0.035602 -22.14 1.3097e-108 Variance 0.003309 0.00019167 17.264 8.771e-67
numperiods = 11;
[Forecast,ForecastMSE] = forecast(EstMdl,numperiods,U(:,1));
Tempdiff_forecast = Forecast*S(1,1)*V(:,1)';
You start with negative z values.
data = load('z.mat')
data = struct with fields:
z: [372×401 double]
[zmin, zmax] = bounds(data.z, 'all') % show range of z values
zmin = -0.0924
zmax = 0.0993
And you're training your model using negative values,
[U,S,V] = svd(data.z);
U1 = U(:,1)
U1 = 372×1
-0.0222 -0.0145 -0.0579 0.0195 -0.0293 0.0161 -0.0491 -0.1093 -0.0165 -0.0512
Your new model EstMdl contains estimated parameters based on the training data U1. So, when you forecast that fitted model, the forecast also has negative values.
So you mean that I should delete the negative values in z, ensure that the predicted results are all positive?
Can I delete the negative values from the predicted kernel density values and rescale the kernel density values so that the bandwidth to be 1?
> So you mean that I should delete the negative values in z
No, I would take a step back and investigate. Do you expect there to be negative values in z? If not, then how did they get there? Perhaps something went wrong with your calculations of z or perhaps your expectations of what z should be aren't correct expectations. If you do expect there to be negative values in z or that negative values are possible, then I would re-think whether it is a problem that the forecast produces negative values.
If z isn't meaningful data and you're using z to poke around at the model, then it's completely fine to replace the negative values or use an entirely different set of data. But if z is meaningful data, you can't just delete some values because they are causing problems.
I don't know enough about what the data are or about the forecasting you're using to suggest the next steps.
z in my data is the difference between actual temperature kernel density distribution and average temperature kernel density distribution. So negative values in z are also meaningful data. And my purpose is to predict the temperature kernel distribution. Thank you very much!

Sign in to comment.

Answers (0)

Asked:

on 20 Dec 2022

Commented:

on 23 Dec 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!