Page 1 of 1

LINREG with create option zeros out all coefficients

Posted: Tue Feb 02, 2016 4:51 pm
by macro
This code

Code: Select all

calendar(q) 1969 1

compute begin_samp = 1969:1
compute end_samp   = 2006:4
compute max_lags = 4

open data "sandbox_data.xls"
    data(format = xls, org = columns)
close data

system(model = mdl)
    variables lgdpk dlp
    lags 1 to max_lags
    deterministic constant
end(system)
estimate(model = mdl)

compute prior_coeffs = %modelgetcoeffs(mdl)
compute post_coeffs = prior_coeffs

* trivial example: zero out intercept terms
do i = 1, 2
    compute post_coeffs(%rows(post_coeffs), i) = 0
end do i

compute %modelsetcoeffs(mdl, post_coeffs)
compute eq = %modeleqn(mdl, 1)
linreg(create, equation = eq)
displays this output:

Code: Select all

Linear Regression - Estimation by User
Dependent Variable LGDPK
Quarterly Data From 1970:02 To 2006:04
Usable Observations                       147
Degrees of Freedom                        138
Mean of Dependent Variable       8.7984421340
Std Error of Dependent Variable  0.3252359768
Standard Error of Estimate       9.0869764659
Sum of Squared Residuals         11395.093498
Durbin-Watson Statistic           1.6276e-006

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  LGDPK{1}                         0.000000     0.000000      0.00000  0.00000000
2.  LGDPK{2}                         0.000000     0.000000      0.00000  0.00000000
3.  LGDPK{3}                         0.000000     0.000000      0.00000  0.00000000
4.  LGDPK{4}                         0.000000     0.000000      0.00000  0.00000000
5.  DLP{1}                           0.000000     0.000000      0.00000  0.00000000
6.  DLP{2}                           0.000000     0.000000      0.00000  0.00000000
7.  DLP{3}                           0.000000     0.000000      0.00000  0.00000000
8.  DLP{4}                           0.000000     0.000000      0.00000  0.00000000
9.  Constant                         0.000000     0.000000      0.00000  0.00000000
I checked the new model that %modelsetcoeffs returns, and the coefficients are correct (in that the model includes the updated coefficients), but why doesn't LINREG set the coefficients correctly? If I run

Code: Select all

compute eq = %modeleqn(mdl, 1)
compute post_coeffs_from_eq = %eqncoeffs(eq)
display post_coeffs_from_eq
I get

Code: Select all

1.14120      -0.02528      -0.14643       0.02425      -0.46959      -0.55113       0.29368       0.27940       0.00000
which is correct, so it looks like the problem lies in my usage of LINREG(create, ...)

Re: LINREG with create option zeros out all coefficients

Posted: Tue Feb 02, 2016 8:57 pm
by TomDoan
What are you trying to do with LINREG(CREATE)? The idea behind LINREG(CREATE) is to allow you to compute the coefficients and covariance matrix in a non-standard fashion. If you're just trying to show the altered coefficients, just do

disp eq