全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Gauss专版
1930 3
2010-06-04
初学者问题:主要是想将regression的结果写入excel表格,代码如下(regress的proc已经写好):

{x, state1} = rndKMn(100,4,-1)*100;
output file = tempdata.asc reset;
output off;
load x[] = tempdata.asc;
x = reshape(x,100,4);
y = x[.,1];
x = x[.,2:cols(x)];
{coeff, stderror, tstat} = regress(x,y);

x = {coeff, stderrow, tstat};
fname = "test.xls";
names = {"Coefficients", "Standard Errors", "T-statistics"};
call export(x',faname,names);


结果可以在Gauss里显示,但关键是绿色部分(写入excel) 不知道怎么写了,请指教!
先谢了!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-6-4 21:53:52
proc (3) = regress (x,y);
local xxi,b,ymxb,sse,sd,t;
xxi=invpd(x'x);
b=xxi*(x'y);
ymxb=y-(x*b);
sse=ymxb'ymxb/(rows(x)-cols(x));
sd=sqrt(diag(sse*xxi));
t=b./sd;
retp(b,sd,t);
endp;
@ create a 100*4 matrix of standard-normal random numbers @
{x, state1} = rndKMn(100,4,-1)*100;
@ define a file for output. No path is defined so it will be in your
working directory @
output file = C:\gs\tempdata.asc reset; @ reset - the file is overwritten
each time a write occurs @
@ print x on the screen and to the file, in ascii form, space delimited @
print x;
@ turn off the output file @
output off;
@ Ascii load from the file, into a one-column vector @
load x[] = C:\gs\tempdata.asc;
@ turn the column vector into a 100*4 matrix @
x = reshape(x,100,4);
@ select the first column @
y = x[.,1];
@ select columns two, three, and four @
x = x[.,2:cols(x)];
@ call the "regress" function - it has three returns @
{ coeff, stderror, tstat } = regress(x,y);
@ print column labels @
print "Coefficients, Standard Errors, T-Statistics";
@ horizontally concatenate the returns from "regress" and print the result @
print coeff~stderror~tstat;

z = {coeff, stderrow, tstat};
fname = "test.xls";
names = {"Coefficients", "Standard Errors", "T-statistics"};
call export(z',faname,names);
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-6-4 21:56:48
你要把x换为z,x,y都被用过。你的参考来自BASIC GAUSS WORKSHOP
Version 4.0.1
February 25, 2002
可能是版本的问题,names = {"Coefficients", "Standard Errors", "T-statistics"};还是编译错误。
你再琢磨琢磨。
另你可以直接拷到excel 的啊。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-6-7 19:49:11
3# xuehe
呵,多谢xuehe!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群