版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 Matlab程序命令(三):使用Matlab进行回归%A矩阵为36×217的矩阵,即用1978-2013年31个省(直辖市、自治区)国内生产总值、人口、财政收入、财政支出、固定资产投资、全社会消费品零售总额、进出口数据组成的矩阵。y=A(:,1); %提取A矩阵中的第1列x1=A(:,2); %提取A矩阵中的第2列x2=A(:,4); %提取A矩阵中的第4列x=horzcat(x1,x2); %把x1,x2横排vnames=strvcat('y','x1','x2'); %命名变量result=ols(y,x); %用ols回归prt
2、(result,vnames) %对回归结果进行格式化并命名Ordinary Least-squares Estimates Dependent Variable = y R-squared = 0.9929 Rbar-squared = 0.9927 sigma2 = 226704.9623 Durbin-Watson = 0.2427 Nobs, Nvars = 36, 2 *Variable Coefficient t-statistic t-probability x1 0.512321 5.737780 0.000002 x2 4.703050 53.340145 0.000000p
3、lt(result) %显示回归结果拟合值与实际值,残差的图形关于ols回归函数,可以使用help ols命令查看function results=ols(y,x)% PURPOSE: least-squares regression%-% USAGE: results = ols(y,x)% where: y = dependent variable vector (nobs x 1)% x = independent variables matrix (nobs x nvar)%-% RETURNS: a structure% results.meth = 'ols'% r
4、esults.beta = bhat% results.tstat = t-stats% results.yhat = yhat% results.resid = residuals% results.sige = e'*e/(n-k)% results.rsqr = rsquared% results.rbar = rbar-squared% results.dw = Durbin-Watson Statistic% results.nobs = nobs% results.nvar = nvars% results.y = y data vector% -% SEE ALSO: p
5、rt(results), plt(results)%-help olsContents of ols:FDELW2 - wswdel,wwsdel,wmatdel=fdelw2(xcoord,ycoord)FOLS2 - bmax, srds, prhigher, emax, maxlik=fols2(x, y)fmess_car2 - bmax, srds, prhighers, emax, logliks=fmess_car2(x, y, d)mprint - PURPOSE: print an (nobs x nvar) matrix in formatted formx_ols2_ga
6、1 - This example script estimates some election data via ols and MESS-AR. ols is both a directory and a function. PURPOSE: least-squares regression - USAGE: results = ols(y,x) where: y = dependent variable vector (nobs x 1) x = independent variables matrix (nobs x nvar) - RETURNS: a structure result
7、s.meth = 'ols' results.beta = bhat (nvar x 1) results.tstat = t-stats (nvar x 1) results.bstd = std deviations for bhat (nvar x 1) results.yhat = yhat (nobs x 1) results.resid = residuals (nobs x 1) results.sige = e'*e/(n-k) scalar results.rsqr = rsquared scalar results.rbar = rbar-squar
8、ed scalar results.dw = Durbin-Watson Statistic results.nobs = nobs results.nvar = nvars results.y = y data vector (nobs x 1) results.bint = (nvar x2 ) vector with 95% confidence intervals on beta - SEE ALSO: prt(results), plt(results) -result = ols(y,x); %最小二乘法bhat = result.beta; % 估计结果disp(The R-sq
9、uared is:'); %显示拟合优度R2result.rsqr %拟合优度R2disp(The 2nd t-statistic is:'); %显示第二个t统计量result.tstat(2,1) %第二个t统计量result.tstat(1,1) %第一个t统计量result.resid %显示残差result.y %显示y变量result.x %显示x变量prt(result) %对回归结果进行格式化Ordinary Least-squares Estimates R-squared = 0.9929 Rbar-squared = 0.9927 sigma2 = 226
10、704.9623 Durbin-Watson = 0.2427 Nobs, Nvars = 36, 2 *Variable Coefficient t-statistic t-probability variable 1 0.512321 5.737780 0.000002 variable 2 4.703050 53.340145 0.000000result = ols(y,x); %使用最小二乘法回归prt(result) %对回归结果进行格式化;bill_clinton = ols(y,x); %关于左边字母的使用,可以使用其他字母result2 = ols(y,x); %关于左边字母
11、的使用,可以使用其他字母restricted = ols(y,x); %关于左边字母的使用,可以使用其他字母unrestricted = ols(y,x); %关于左边字母的使用,可以使用其他字母The regression function library is in a subdirectory regress.(回归函数库在子目录中)regression function library(回归函数库)ar_g %Gibbs sampling Bayesian autoregressive model(pjlv7中有此函数)查看ar_g函数。help ar_g PURPOSE: MCMC
12、estimates Bayesian heteroscedastic AR(k) model imposing stability restrictions using Gibbs sampling y = b0 + y(t-1) b1 + y(t-2) b2 +,.,y(t-k) bk + E, E = N(0,sige*V), sige = gamma(nu,d0), b = N(c,T), V = diag(v1,v2,.vn), r/vi = ID chi(r)/r, r = Gamma(m,k) - USAGE: results = ar_g(y,nlag,ndraw,nomit,p
13、rior,start) where: y = dependent variable vector nlag = # of lagged values ndraw = # of draws nomit = # of initial draws omitted for burn-in prior = a structure for prior information input: prior.beta, prior means for beta, c above priov.bcov, prior beta covariance , T above prior.rval, r prior hype
14、rparameter, default=4 prior.m, informative Gamma(m,k) prior on r prior.k, informative Gamma(m,k) prior on r prior.const, a switch for constant term, default = 1 (a constant included) prior.nu, a prior parameter for sige prior.d0, a prior parameter for sige (default = diffuse prior for sige) start =
15、(optional) structure containing starting values: defaults: OLS beta,sige, V= ones(n,1) start.b = beta starting values (nvar x 1) start.sig = sige starting value (scalar) start.V = V starting values (n x 1) - RETURNS: a structure: results.meth = 'ar_g' results.bdraw = bhat draws (ndraw-nomit
16、x nvar) results.sdraw = sige draws (ndraw-nomit x 1) results.vmean = mean of vi draws (nobs x 1) (if rval input) results.yhat = mean of posterior y-predicted values results.rdraw = r-value draws (ndraw-nomit x 1) results.pmean = b prior means, prior.beta from input results.pstd = b prior std deviati
17、ons sqrt(diag(T) results.r = value of hyperparameter r (if input) results.nobs = # of observations results.nadj = # of observations adjusted for feeding lags results.nvar = # of variables (including constant term) results.ndraw = # of draws results.nomit = # of initial draws omitted results.y = actu
18、al observations (nobs x 1) results.x = x-matrix of lagged values of y (nobs-nlag,nlag+const) results.nu = nu prior parameter results.d0 = d0 prior parameter results.m = m prior parameter (if input) results.k = k prior parameter (if input) results.time = time taken for sampling results.accept= accept
19、ance rate results.pflag = 'plevel' (default) or 'tstat' for bogus t-statistics - NOTES: a constant term is automatically included in the model unless you set prior.const = 0; - SEE ALSO: prt, prt_gibbs(results), coda - % REFERENCES: Chib (1993) Bayes regression with autoregressive er
20、rors: A gibbs sampling approach,' Journal of Econometrics, pp. 275-294. -boxcox %Box-Cox regression with 1 parameter(pjlv7中有此函数)help boxcox PURPOSE: box-cox regression using a single scalar transformation parameter for both y and (optionally) x - USAGE: results = boxcox1(y,x,lam_lo,lam_up,model,
21、foptions) where: y = dependent variable vector x = explanatory variables matrix (intercept vector in 1st column - if desired) lam_lo = scalar, lower limit for simplex search lam_up = scalar, upper limit for simplex search model = 0 for y-transform only = 1 for both y, and x-transform foptions = (opt
22、ional) structure OPTIONS, created with the OPTIMSET function. See OPTIMSET for details. - RETURNS: a structure: results.meth = 'boxcox' results.beta = bhat estimates results.lam = lamda estimate results.tstat = t-stats for bhat results.yhat = yhat (box-cox transformed) results.resid = residu
23、als results.sige = e'*e/(n-k) results.rsqr = rsquared results.rbar = rbar-squared results.nobs = nobs results.nvar = nvars results.y = y data vector (box-cox transformed) results.iter = # of iterations results.like = -log likelihood function value - NOTE: uses MATLAB simplex optimization functio
24、n fmin - SEE ALSO: prt(results), plt(results), boxcox2() - Overloaded methods: fints/boxcoxhwhite %Halbert White's heteroscedastic consistent estimates(pjlv7中有此函数)lad % least-absolute deviations regression(pjlv7中有此函数)logit %logit regression(pjlv7中有此函数)mlogit % multinomial logit regression(pjlv7中
25、有此函数)nwest % Newey-West hetero/serial consistent estimates(pjlv7中有此函数)ols %ordinary least-squares(pjlv7中有此函数)ols_g % Gibbs sampling Bayesian linear model(pjlv7中有此函数)olsar1 %Maximum Likelihood for AR(1) errors ols model(pjlv7中有此函数)olsc % Cochrane-Orcutt AR(1) errors ols model(pjlv7中有此函数)olst %regress
26、ion with t-distributed errors(pjlv7中有此函数)probit % probit regression(pjlv7中有此函数)probit_g % Gibbs sampling Bayesian probit model(pjlv7中有此函数)ridge % ridge regression(pjlv7中有此函数)robust % iteratively reweighted least-squares(pjlv7中有此函数)rtrace %ridge estimates vs parameters (plot) (pjlv7中有此函数)sur %seeming
27、ly unrelated regressions(pjlv7中有此函数)switch_em %switching regime regression using EM-algorithm(pjlv7中有此函数)theil %Theil-Goldberger mixed estimation(pjlv7中有此函数)thsls % three-stage least-squares(pjlv7中有此函数)tobit % tobit regression(pjlv7中有此函数)tobit_g % Gibbs sampling Bayesian tobit model(pjlv7中有此函数)tsls %two-stage least-squares(pjlv7中有此函数)waldf %Wald F-test(p
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 《传感器与检测技术》练习题集
- 【初中物理】光的折射单元测试(培优卷)2024-2025学年苏科版物理八年级上册
- 2023年标准员之基础知识练习题(二)及答案
- 唐山-PEP-2024年11版小学三年级英语第1单元真题
- 2024年07版小学5年级上册英语第二单元期末试卷
- 收纳箱生产企业的账务处理-记账实操
- 中建信息化管理手册
- 强化研究-团结协作-共创佳绩
- 经济数学 课件 ch01 函数、极限及其应用
- 2024年高考语文二轮复习:语言的表达效果类新题型(练习)(解析版)
- 陕煤集团笔试题库及答案
- 33 《鱼我所欲也》对比阅读-2024-2025中考语文文言文阅读专项训练(含答案)
- 《中华民族共同体概论》考试复习题库(含答案)
- 2022-2023学年武汉市江岸区七年级英语上学期期中质量检测卷附答案
- 制程品质保证权责及工作重点
- 结构工程工作危害分析(JHA)
- 运用思维导图优化初中数学课堂的实践与探究
- 中考物理专题21 欧姆定律的动态电路计算(原卷版)
- 2022年2022年北京市各区中考英语一模试卷分类汇编完形填空专题
- 办公室办文工作流程图
- (完整word版)酒店流水单
评论
0/150
提交评论