Code: Select all
calendar(q) 1947 1
allocate 50 2015:2
compute use_logs = 1
open data nipa.csv
data(format=cdf, org=columns, dateform="m/d/y") 1947:1 2015:2 gdp cons gce gov nx unemp
close data
declare hash[series] vars
set vars("unemp") = unemp
dofor s = gdp cons gce gov
compute [label] lbl = "L" + %l(s)
set %s(lbl) = log(s{0})
* If use_logs == 1, assign vars("gdp") = lgdp
* Otherwise, assign vars("gdp") = gdp
if use_logs == 1 {
set vars(%l(s)) = %s(lbl)
labels vars(%l(s))
# lbl
}
else {
set vars(%l(s)) = s
labels vars(%l(s))
# %l(s)
}
end dofor s
declare string str
dofor str = "gdp" "cons" "gce" "gov"
linreg(print) vars(&str)
# unemp{1 to 2}
end dofor str
linreg(print) lgov
# %rladdlaglist(%rlempty(),unemp,||1,2,3,4||)
linreg(print) lgov
# %rladdlaglist(%rlempty(),vars("unemp"),||1,2,3,4||)
Code: Select all
linreg(print) lgov
# %rladdlaglist(%rlempty(),vars("unemp"),||1,2,3,4||)
Code: Select all
Linear Regression - Estimation by Least Squares
Dependent Variable LGOV
Quarterly Data From 1947:01 To 2015:02
Usable Observations 274
Degrees of Freedom 273
Centered R^2 -0.0000000
R-Bar^2 -0.0000000
Uncentered R^2 0.9959224
Mean of Dependent Variable 7.3969521777
Std Error of Dependent Variable 0.4741704417
Standard Error of Estimate 0.4741704417
Sum of Squared Residuals 61.380666936
Log Likelihood -183.8326
Durbin-Watson Statistic 1.4445e-003
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. Constant{1} 7.3969521777 0.0286456840 258.22222 0.00000000
2. Constant{2} 0.0000000000 0.0000000000 0.00000 0.00000000
3. Constant{3} 0.0000000000 0.0000000000 0.00000 0.00000000
4. Constant{4} 0.0000000000 0.0000000000 0.00000 0.00000000
Code: Select all
linreg(print) lgov
# vars("unemp"){1 to 4}