Page 1 of 1
time varying linear regression
Posted: Fri May 09, 2014 10:26 am
by pls
I would like to know if there is any problem applying DLM to estimate a time varying linear regression if the data are biweekly prior to a certain date and weekly thereafter. The independent and dependent variables are ratios or percentages, hence I think that there is no problem.
I thought I saw in one of the readings, perhaps the Koopman and Durbin textbook or the workbook on state space methods that this is not a problem, but would like this confirmed, if possible.
Re: time varying linear regression
Posted: Fri May 09, 2014 10:34 am
by TomDoan
Yes. What would happen is that whatever additive variance you put into the coefficient changes would get doubled up in the biweekly range, which is probably reasonable if the variance is a measure of week to week changes.
Re: time varying linear regression
Posted: Fri Apr 29, 2016 3:36 pm
by pls
I would like to constrain xstates(t) (1) and xstates(t) (2) to be positive, but would not like to constrain xstates (t) (3).
I think the following code is in error, since I seem to have constrained xstates (t) (3) to equal 0.
I would like to know what to change so that xstates (t) (3) is unconstrained.
The code that follows checks if the computed xstates are negative and sets the values for active0 and active1.
Thanks.
Code: Select all
DATA(FORMAT=XLSX,ORG=COLUMNS) 1 1218 hl hs sl ss hlhs slhs hshl sshl date hr spr
set x = -hlhs
set y = slhs-1
linreg x / resids
# constant y{1}
*
dec vect swx(3)
compute swx=||.01,.01,0.01||
compute sv=1.0
nonlin sv swx
dlm(c=||1.0,x,resids||,a=%identity(3),sw=%diag(swx),sv=sv,presample=diffuse,y=y,type=smooth) 2 1218 xstates
*
set b0 2 1218 = xstates(t)(1)
set b1 2 1218 = xstates(t)(2)
set b2 2 1218 = xstates(t)(3)
set active0 = %na
set active1 = %na
*
declare symmetric m
compute m = ||1,0,0|0,1,0|0,0,1||
dec frml[rect] xc
frml xc = ||1.0|x|resids||~m
dec frml[vect] xy
frml xy = ||y,0.0*active0,0*active1,0||
dec frml[symm] xsv
frml xsv = %diag(||sv,0.0,0.0,0.0||)
dlm(c=xc,a=%identity(3),sw=%diag(swx),sv=xsv,presample=diffuse,y=xy,type=smooth) 2 1218 xstates
Re: time varying linear regression
Posted: Fri Apr 29, 2016 9:30 pm
by TomDoan
compute m = ||1,0,0|0,1,0|0,0,1||
dec frml[rect] xc
frml xc = ||1.0|x|resids||~m
dec frml[vect] xy
frml xy = ||y,0.0*active0,0*active1,0||
dec frml[symm] xsv
frml xsv = %diag(||sv,0.0,0.0,0.0||)
In this, the fourth component of xy says beta3(t)=0. If you make the fourth component of xy=%na (or just cut out the 4th component entirely), then there will be no constraint of beta3(t).
Re: time varying linear regression
Posted: Sat Apr 30, 2016 2:05 am
by pls
Thanks, Tom.