olsrs_d.m
来自「时间序列分析中常用到的matlab代码」· M 代码 · 共 37 行
M
37 行
% PURPOSE: An example using olsrs(),
% prt(),
% plt(),
% restricted ols estimation
%---------------------------------------------------
% USAGE: olsrs_d
%---------------------------------------------------
clear all;
% generate data
nobs = 100;
nvar = 5;
beta = ones(nvar,1);
beta(nvar-1,1) = 0.6;
beta(nvar,1) = 0.4;
randn('state',0);
xmat = randn(nobs,nvar-1);
x = [ones(nobs,1) xmat];
evec = randn(nobs,1);
y = x*beta + evec;
% By some theoretical presumptions,
%the coefficients on the x3 and x4 explanatory variables
% must sum up to one.
% Given q = R*b, this translates into the following shape of R and q.
q = 1;
R = [0 0 0 1 1];
vnames = strvcat('y','constant','x1','x2','x3','x4');
results = olsrs(y,x,R,q);
prt_reg(results,vnames);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?