On Saturday, 25 October 2014 19:51:05 UTC+2, siumt...@gmail.com wrote:
> Thank You for spending some time to help me. ..
>
> Sorry If I post the same question again and again. I just need a solution for my problem.
>
>
> I have attempted to use multiple linear regression to solve the problem . However, when I plot the original data with fitted value , I did not find good result.
>
> I think it is better I put sampedata which I understand instead of using random numbers
[Note that I did not use completely random numbers in my example, just arbitrary coefficients in the model.]
You claim you understand your sample data. But you should really explore your data model a bit more. You are basically modelling your data as periodic, with only the frequencies 1-4/yr. The following spectral analysis shows that your signal in fact does not contain much energy at these frequencies (exact maybe the seasonal signal at 1/yr). Vertical green lines correspond to your model frequencies, and the red ones are the major ones found by a simple spectral analysis.
Bottom line: your model is very wrong, so no wonder estimating the model coefficients using linear regression/least squares does not work well.
8<-----------------------------
;; read test data
datafile = 'sampledata.txt'
np = file_lines(datafile)
data = strarr(np)
openr, unit, datafile, /get_lun
readf, unit, data
free_lun, unit
data = double(data[*])
;; Subtract mean
data -= mean(data)
;; Time and freq axes
dt = 1/12d0 ; [years]
t = dindgen(np)*dt
df = 1/(np*dt)
faxis = (1+dindgen(np/2))*df
;; one-sided periodogram
pow = (abs(fft(data*hanning(np)))^2)[1:np/2]
plot, faxis, pow, xtitle='Frequency [1/years]', ytitle='Power spectrum', /xlog
;; Dominant modes (eyeball fit)
oplot, df*[1,1]*1.1, !y.crange, color='ff'x
oplot, df*[1,1]*4, !y.crange, color='ff'x
oplot, df*[1,1]*8, !y.crange, color='ff'x
oplot, df*[1,1]*12, !y.crange, color='ff'x
oplot, df*[1,1]*15, !y.crange, color='ff'x
oplot, df*[1,1]*19.5, !y.crange, color='ff'x
oplot, df*[1,1]*25, !y.crange, color='ff'x
oplot, df*[1,1]*28, !y.crange, color='ff'x
oplot, df*[1,1]*33, !y.crange, color='ff'x
oplot, df*[1,1]*41, !y.crange, color='ff'x
oplot, df*[1,1]*55, !y.crange, color='ff'x
oplot, df*[1,1]*81, !y.crange, color='ff'x
oplot, df*[1,1]*124, !y.crange, color='ff'x
oplot, df*[1,1]*164, !y.crange, color='ff'x
oplot, df*[1,1]*192, !y.crange, color='ff'x
;; Your assumed modes
for n=1,4 do $
oplot, [1,1]*n, !y.crange, color='ff00'x
end
8<------------------
--
Yngvar
|