How to run a regression of lognrnd?

1 visualización (últimos 30 días)
Fernanda Suarez Jaimes
Fernanda Suarez Jaimes el 12 de Mzo. de 2020
Comentada: Fernanda Suarez Jaimes el 12 de Mzo. de 2020
I have a vector with random data log-norm distributed and I need to run a regression of this.
  5 comentarios
Fernanda Suarez Jaimes
Fernanda Suarez Jaimes el 12 de Mzo. de 2020
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
Fernanda Suarez Jaimes el 12 de Mzo. de 2020
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

Iniciar sesión para comentar.

Respuestas (1)

Steven Lord
Steven Lord el 12 de Mzo. de 2020
It sounds like you want the lognfit function.
  1 comentario
Fernanda Suarez Jaimes
Fernanda Suarez Jaimes el 12 de Mzo. de 2020
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

Iniciar sesión para comentar.

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by