How to run a regression of lognrnd?

1 次查看(过去 30 天)
I have a vector with random data log-norm distributed and I need to run a regression of this.
  5 个评论
Fernanda Suarez Jaimes
Yes, correct. The thing is that I transformed the time_series1 into a new "weekly" time series with 6,000 elements as well. So I can fit the two distributions together. Like this
%Converting the 'daily' ts to a to a 'weekly' one
arrayts1 = padarray (time_series1, [ceil(numel (time_series1) / 7) * 7 - numel(time_series1) 0], 0, 'post' );
time_series3 = mean (reshape (arrayts1, 7, []), 1);
Then in the Y axis are the random valued and in the X axis are the time values.
I need to get a regression of X over Y.
This is what I have so far:
scatter(time_series2,time_series3,'.') % plot the data points
hAx=gca; hAx.XScale='log'; % on semilog x axis
b=polyfit(log(time_series2),Y,1); % fit response to log(independent) Y is the meanleast square value given by the fit for the above specific dataset
yHat=polyval(b,log([min(time_series2) max(time_series2)])) % remember, it's log in X
hold on
plot([min(time_series2) max(time_series2)],yHat,'r-')
Fernanda Suarez Jaimes
This is another option I have. The issue is that we need to do a regression of a time series. Therefore, the result of the model is not significant as it is near 0,05.
logarithms_ts2=log(time_series2); %calculating logarithm of the values in order to use GLM fuction
[regression2,dev,stats] = glmfit(xtime2,logarithms_ts2,'normal');
regression2=fitglm(xtime2,time_series2) %regression of time series 2

请先登录,再进行评论。

回答(1 个)

Steven Lord
Steven Lord 2020-3-12
It sounds like you want the lognfit function.
  1 个评论
Fernanda Suarez Jaimes
You mean something as this?
rng ( 'default' ); % So that numbers can be repeated
time_series2 = lognrnd (0,0.25,6000,1); % generating time series with mu set to zero and sigma 0.25
[pHat,pCI] = lognfit(time_series2,0.01)
The result I get is this:
pHat =
0.0017 0.2494
pCI =
-0.0066 0.2437
0.0100 0.2554

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by