楼主: july0710
18804 39

[实际应用] DCC模型问题 [推广有奖]

21
zhangtao 发表于 2012-12-2 13:52:08
epoh 发表于 2012-12-1 20:51
library(RODBC)
channel
> library(RODBC)
>  channel <- odbcConnectExcel("foo.xls")
>  sqlTables(channel)
[1] TABLE_CAT   TABLE_SCHEM TABLE_NAME  TABLE_TYPE  REMARKS   
<0 行> (或0-长度的row.names)
>  #                       TABLE_CAT TABLE_SCHEM TABLE_NAME   TABLE_TYPE REMARKS
>  # C:\\Users\\...\\Documents\\foo        <NA>       foo$ SYSTEM TABLE    <NA>
>  
> foo=sqlFetch(channel, "foo")
错误于odbcTableExists(channel, sqtable) :
  ‘foo’: table not found on channel
>  foo
错误: 找不到对象'foo'
>  #  year        gdp        ind      city         con
>  #1 2000 0.08431279 0.09429051 0.3622000 0.006607202
>  #2 2001 0.08300318 0.08441516 0.3766000 0.007220217
>  #3 2002 0.09082068 0.09829292 0.3908978 0.001303356
>  #4 2003 0.10025379 0.12671907 0.4053023 0.011064107
>  #5 2004 0.10085040 0.11112455 0.4176001 0.015448986
>  #6 2005 0.11310035 0.12082325 0.4299000 0.012044374
>  #7 2006 0.12676534 0.13391125 0.4434287 0.013780144
>  #8 2007 0.14162395 0.15063330 0.4588900 0.010812481
>  #9 2008 0.09634668 0.09877462 0.4698913 0.010299511
>  
> model1=lm(gdp~ind+city+con,data=foo)
错误于is.data.frame(data) : 找不到对象'foo'
>  model1
错误: 找不到对象'model1'
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
>
epoh老师,您好!
为什么在我的电脑上运行会是以上结果?
数学好就是要天天学

22
epoh 发表于 2012-12-2 13:59:33
zhangtao 发表于 2012-12-2 13:52
> library(RODBC)
>  channel   sqlTables(channel)
[1] TABLE_CAT   TABLE_SCHEM TABLE_NAME  TABLE_T ...
你有设定ODBC (Open Database Connectivity) for MS-Excel ??

23
zhangtao 发表于 2012-12-2 16:42:14
epoh 发表于 2012-12-2 13:59
你有设定ODBC (Open Database Connectivity) for MS-Excel ??
没有设定,不知如何设定?
数学好就是要天天学

24
epoh 发表于 2012-12-2 17:02:06
zhangtao 发表于 2012-12-2 16:42
没有设定,不知如何设定?
odbc_settings_excel.pdf
   odbc_settings_excel.pdf (537.3 KB)
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
zhangtao + 5 + 5 + 5 好的意见建议

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

25
zhangtao 发表于 2012-12-2 17:14:11
epoh 发表于 2012-12-2 17:02
odbc_settings_excel.pdf
m_Files_tvtp_20121113.zip (61.96 KB) 本附件包括:
  • license.txt


??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function failed with the following error:
Variable 'indep_nS' is used as a command function.
Error in ==> MS_Regress_Fit_tvtp at 67
    [param]=fmincon(@(param)MS_Regress_Lik_tvtp(dep,indep_nS,indep_S,px,param,k,S,advOpt,dispOut),param0, ...
Error in ==> MS_VAR_Fit_tvtp at 68
[Spec_Output]=MS_Regress_Fit_tvtp(dep,indep,px,k,S,advOpt); % Estimating the model
Error in ==> Example_MS_Regress_Fit_MSVAR_tvtp at 21
[Spec_Out]=MS_VAR_Fit_tvtp(dep,nLag,px,k,doIntercept,advOpt);
??? Error using ==> checkInputs_tvtp
So far, in the multivariate version (size(dep,2)>1), the package only handles the multivariate normal distribution. Please set advOpt.distrib='Normal'.
Error in ==> checkInputs_tvtp at 129
        error('So far, in the multivariate version (size(dep,2)>1), the package only handles the multivariate normal distribution. Please set advOpt.distrib=''Normal''.')
Error in ==> MS_Regress_Fit_tvtp at 33
checkInputs_tvtp(); % checking if inputs variables are OK
Error in ==> Example_MS_Regress_Fit_MultiVar_tvtp at 28
[Spec_Out]=MS_Regress_Fit_tvtp(dep,indep,px,k,S,advOpt); % Estimating the model
??? Variable 'indep_nS' is used as a command function.
Error in ==> MS_Regress_Fit_tvtp>@(param)MS_Regress_Lik_tvtp(dep,indep_nS,indep_S,px,param,k,S,advOpt,dispOut) at 81
        [param,fval,exitflag,output]=fminunc(@(param)MS_Regress_Lik_tvtp(dep,indep_nS,indep_S,px,param,k,S,advOpt,dispOut),param0,options);
Error in ==> fminunc at 182
   f = feval(funfcn{3},x,varargin{:});
Error in ==> MS_Regress_Fit_tvtp at 81
        [param,fval,exitflag,output]=fminunc(@(param)MS_Regress_Lik_tvtp(dep,indep_nS,indep_S,px,param,k,S,advOpt,dispOut),param0,options);
Error in ==> Example_MS_Regress_Fit_t_Dist_tvtp at 37
[Spec_Out]=MS_Regress_Fit_tvtp(dep,indep,px,k,S,advOpt); % Estimating the model
??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function failed with the following error:
Variable 'indep_nS' is used as a command function.
Error in ==> MS_Regress_Fit_tvtp at 67
    [param]=fmincon(@(param)MS_Regress_Lik_tvtp(dep,indep_nS,indep_S,px,param,k,S,advOpt,dispOut),param0, ...
Error in ==> Example_MS_Regress_Fit_tvtp at 37
[Spec_Out]=MS_Regress_Fit_tvtp(dep,indep,px,k,S,advOpt); % Estimating the model
>>
epoh老师,您好!
附件 中的程序和数据为什么运行会出现以上问题?如何解决?
数学好就是要天天学

26
epoh 发表于 2012-12-2 18:39:25
zhangtao 发表于 2012-12-2 17:14
??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function  ...
这个程序很容易运行.
除非你是用自己的数据.

>>Example_MS_Regress_Fit_tvtp

***** Numerical Optimization Converged *****

Final log Likelihood: 2494.163
Number of estimated parameters: 10
Type of Switching Model: Univariate
Distribution Assumption -> Normal
Method SE calculation -> 2

***** Final Parameters for Equation #1 *****

---> Non Switching Parameters <---

Non Switching Parameter for Equation #1, Indep column 2
     Value:                0.471093
     Std Error (p. value): 0.026581 (0.0000)
Non Switching Parameter for Equation #1, Indep column 3
     Value:                0.156775
     Std Error (p. value): 0.033011 (0.0000)

--->   Switching Parameters (Distribution Parameters)  <---

State 1
    Model's Variance:      0.000284
    Std Error (p. value):  0.000017 (0.0000)
State 2
    Model's Variance:      0.000893
    Std Error (p. value):  0.000082 (0.0000)

--->   Switching Parameters (Regressors)  <---

Switching Parameters for Equation #1 - Indep column 1

State 1
   Value:                0.000563
   Std Error (p. value): 0.000668 (0.3994)
State 2
   Value:                -0.000130
   Std Error (p. value): 0.002012 (0.9484)

---> Time Varying Transition Probabilities Matrix Estimation (std. error, p-value) <---
      
pa{1,1}
   pa{1,1}(1)
   Value:                9.246796
   Std Error (p. value): 8.332666 (0.2674)
   pa{1,1}(2)
   Value:                176.520977
   Std Error (p. value): 170.157909 (0.2998)
      
pa{1,2}
   pa{1,2}(1)
   Value:                -1.863982
   Std Error (p. value): 0.303879 (0.0000)
   pa{1,2}(2)
   Value:                11.625862
   Std Error (p. value): 14.119926 (0.4105)

---> The Latest Transition Probabilities Matrix <---

      1.0000   0.0407   
      0.0000   0.9593   

---> Expected Duration of Regimes <---

     Expected duration of Regime #1: 59.49 time periods
     Expected duration of Regime #2: 27.50 time periods
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
zhangtao + 5 + 5 + 5 好的意见建议

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

27
zhangtao 发表于 2012-12-7 10:25:19
epoh 发表于 2012-12-2 18:39
这个程序很容易运行.
除非你是用自己的数据.
  To get started, select MATLAB Help or Demos from the Help menu.

??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function failed with the following error:
Variable 'indep_nS' is used as a command function.

Error in ==> MS_Regress_Fit_tvtp at 67
    [param]=fmincon(@(param)MS_Regress_Lik_tvtp(dep,indep_nS,indep_S,px,param,k,S,advOpt,dispOut),param0, ...

Error in ==> MS_VAR_Fit_tvtp at 68
[Spec_Output]=MS_Regress_Fit_tvtp(dep,indep,px,k,S,advOpt); % Estimating the model

Error in ==> Example_MS_Regress_Fit_MSVAR_tvtp at 21
[Spec_Out]=MS_VAR_Fit_tvtp(dep,nLag,px,k,doIntercept,advOpt);

>>
epoh老师,您好!
我运行还是出现以上问题,是不是我的fmincon这个matlab 函数有问题,
您能不能把您的fmincon这个函数给我发一份?
非常感谢!
数学好就是要天天学

28
epoh 发表于 2012-12-7 15:36:45
zhangtao 发表于 2012-12-7 10:25
To get started, select MATLAB Help or Demos from the Help menu.

??? Error using ==> fmincon
fmincon_R2008a
   fmincon_R2008a.rar (7.71 KB) 本附件包括:
  • fmincon.m

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
zhangtao + 5 + 5 + 5 好的意见建议

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

29
zhangtao 发表于 2012-12-7 21:10:18
epoh 发表于 2012-12-7 15:36
fmincon_R2008a
mtvzhang.zip (67.84 KB)

To get started, select MATLAB Help or Demos from the Help menu.
??? Undefined function or variable 'advopt'.
Error in ==> MS_VAR_Fit_tvtp at 68
[Spec_Output]=MS_Regress_Fit_tvtp(dep,indep,px,k,S,advopt); % Estimating the model
Error in ==> Example_MS_Regress_Fit_MSVAR_tvtp at 21
[Spec_Out]=MS_VAR_Fit_tvtp(dep,nLag,px,k,doIntercept,advOpt);
Warning: Name is nonexistent or not a directory: m_Files.
> In path at 115
  In addpath at 95
  In Example_MS_Regress_Fit_MultiVar_tvtp at 5
Warning: Name is nonexistent or not a directory: data_Files.
> In path at 115
  In addpath at 95
  In Example_MS_Regress_Fit_MultiVar_tvtp at 6
??? Error: File: D:\MATLAB7\work\m_Files_tvtp\MS_Regress_Fit_tvtp.m Line: 67 Column: 29
Missing MATLAB operator.
Error in ==> Example_MS_Regress_Fit_MultiVar_tvtp at 28
[Spec_Out]=MS_Regress_Fit_tvtp(dep,indep,px,k,S,advOpt); % Estimating the model
??? Error: File: D:\MATLAB7\work\m_Files_tvtp\MS_Regress_Fit_tvtp.m Line: 67 Column: 29
Missing MATLAB operator.
Error in ==> Example_MS_Regress_Fit_t_Dist_tvtp at 37
[Spec_Out]=MS_Regress_Fit_tvtp(dep,indep,px,k,S,advOpt); % Estimating the model
??? Error: File: D:\MATLAB7\work\m_Files_tvtp\MS_Regress_Fit_tvtp.m Line: 67 Column: 29
Missing MATLAB operator.
Error in ==> Example_MS_Regress_Fit_tvtp at 37
[Spec_Out]=MS_Regress_Fit_tvtp(dep,indep,px,k,S,advOpt); % Estimating the model
>>
epoh老师,您好!
   旧问题解决了,又出现了新问题,您看看能不能解决?

数学好就是要天天学

30
epoh 发表于 2012-12-8 11:20:59
zhangtao 发表于 2012-12-7 21:10
To get started, select MATLAB Help or Demos from the Help menu.
??? Undefined function or va ...
m_Files_tvtp_20121113.rar (58.93 KB)

***** Numerical Optimization Converged *****

Final log Likelihood: 2381.2081
Number of estimated parameters: 30
Number of Equations in System: 1
Distribution Assumption -> Normal
Standard error calculation -> 1

***** Final Parameters for Equation #1 *****

     Intercept - Parameter Value (Standard Error, p value)
          State 1, Intercept = 0.00 (0.00,0.00)
          State 2, Intercept = 0.03 (0.00,0.00)
          State 3, Intercept = -0.02 (0.00,0.00)
     Dependent Variable #1 - Parameter Value (Standard Error, p value)
          State 1, Lag 1 = -0.11 (0.00,0.00)
          State 2, Lag 1 = -0.01 (0.00,0.00)
          State 3, Lag 1 = -0.03 (0.00,0.00)
          State 1, Lag 2 = -0.07 (0.00,0.00)
          State 2, Lag 2 = -0.02 (0.00,0.00)
          State 3, Lag 2 = -0.10 (0.00,0.00)


---> Time Varying Transition Probabilities Matrix Estimation (std. error, p-value) <---
      
pa{1,1}
   pa{1,1}(1)
   Value:                3.756518
   Std Error (p. value): 0.000000 (0.0000)
   pa{1,1}(2)
   Value:                100.390312
   Std Error (p. value): 0.000000 (0.0000)
   pa{1,1}(3)
   Value:                62.191360
   Std Error (p. value): 0.000000 (0.0000)
      
pa{1,2}
   pa{1,2}(1)
   Value:                0.711068
   Std Error (p. value): 0.000000 (0.0000)
   pa{1,2}(2)
   Value:                -99.674758
   Std Error (p. value): 0.000000 (0.0000)
   pa{1,2}(3)
   Value:                35.381428
   Std Error (p. value): 0.000000 (0.0000)
      
pa{1,3}
   pa{1,3}(1)
   Value:                -38.680849
   Std Error (p. value): 0.000000 (0.0000)
   pa{1,3}(2)
   Value:                6.752075
   Std Error (p. value): 0.000000 (0.0000)
   pa{1,3}(3)
   Value:                9.486009
   Std Error (p. value): 0.000000 (0.0000)
      
pa{2,1}
   pa{2,1}(1)
   Value:                -63.678697
   Std Error (p. value): 0.000000 (0.0000)
   pa{2,1}(2)
   Value:                6.254026
   Std Error (p. value): 0.000000 (0.0000)
   pa{2,1}(3)
   Value:                4.817729
   Std Error (p. value): 0.000000 (0.0000)
      
pa{2,2}
   pa{2,2}(1)
   Value:                7.488303
   Std Error (p. value): 0.000000 (0.0000)
   pa{2,2}(2)
   Value:                26.651397
   Std Error (p. value): 0.000000 (0.0000)
   pa{2,2}(3)
   Value:                20.439856
   Std Error (p. value): 0.000000 (0.0000)
      
pa{2,3}
   pa{2,3}(1)
   Value:                -1.240812
   Std Error (p. value): 0.000000 (0.0000)
   pa{2,3}(2)
   Value:                40.233594
   Std Error (p. value): 0.000000 (0.0000)
   pa{2,3}(3)
   Value:                26.530402
   Std Error (p. value): 0.000000 (0.0000)

---> Expected Duration of Regimes <---

     Expected duration of Regime #1: 7.10 time periods
     Expected duration of Regime #2: 1.61 time periods
     Expected duration of Regime #3: 4.09 time periods

---> Covariance Matrix <---

State 1
      0.00032 (0.00000,0.00)   
State 2
      0.00059 (0.00000,0.00)   
State 3
      0.00064 (0.00000,0.00)   

MSVAR_tvtp.jpg

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-22 01:09