楼主: Louis_F_Lu
1984 3

求教:Writing Spreadsheets 2 [推广有奖]

  • 0关注
  • 0粉丝

已卖:76份资源

大专生

18%

还不是VIP/贵宾

-

威望
0
论坛币
292 个
通用积分
0
学术水平
0 点
热心指数
1 点
信用等级
0 点
经验
1316 点
帖子
36
精华
0
在线时间
42 小时
注册时间
2010-5-17
最后登录
2010-7-7

楼主
Louis_F_Lu 发表于 2010-6-4 18:00:47 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
初学者问题:主要是想将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) 不知道怎么写了,请指教!
先谢了!
二维码

扫码加我 拉你入群

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

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

关键词:Spreadsheets Spreadsheet writing Spreads sheets writing Spreadsheets

沙发
xuehe 发表于 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);

藤椅
xuehe 发表于 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 的啊。
已有 1 人评分热心指数 收起 理由
Louis_F_Lu + 1 好的意见

总评分: 热心指数 + 1   查看全部评分

板凳
Louis_F_Lu 发表于 2010-6-7 19:49:11
3# xuehe
呵,多谢xuehe!

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-26 05:39