楼主: barbarazn
8029 4

[求助]如何用sas或者stata进行数据的boxcox转换? [推广有奖]

  • 0关注
  • 0粉丝

学前班

50%

还不是VIP/贵宾

-

威望
0
论坛币
489 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
69 点
帖子
2
精华
0
在线时间
0 小时
注册时间
2006-1-16
最后登录
2014-5-6

楼主
barbarazn 发表于 2006-2-22 16:51:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
急用啊,各位xdjm,请多多帮助啊!如何用sas或者stata对数据进行boxcox正态性变换?对原始数据有何要求?数据是不是不能为零啊?

[此贴子已经被作者于2006-2-22 16:51:20编辑过]

二维码

扫码加我 拉你入群

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

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

关键词:boxcox Stata tata 如何用 Cox 数据 SAS Stata boxcox

回帖推荐

hanszhu 发表于3楼  查看完整内容

Stata help for boxcox help boxcox dialog: boxcox also see: boxcox postestimation ------------------------------------------------------------------------------- Title [R] boxcox -- Box-Cox regression models Syntax boxcox depvar [indepvars] [if] [in] [weight] [, options] ...

StatFan 发表于2楼  查看完整内容

%macro boxcox(phimin=,phimax=, steps=, model=, class=, stmts=, data=, response=); /***********************************************************/ /* This macro performs thr Box-Cox-Power Transformation */ /* Box, G. E. P. and Cox, D. R. (1964) An analysis of */ /* transformations (with discussion). */ /* J. R. Statist. Soc. B., 26, 211-246. */ /* */ /* phimin = smallest phi */ /* phimax = ...

本帖被以下文库推荐

沙发
StatFan 发表于 2006-2-23 03:25:00

%macro boxcox(phimin=,phimax=, steps=, model=, class=, stmts=, data=, response=);

/***********************************************************/

/* This macro performs thr Box-Cox-Power Transformation */

/* Box, G. E. P. and Cox, D. R. (1964) An analysis of */

/* transformations (with discussion). */

/* J. R. Statist. Soc. B., 26, 211-246. */

/* */

/* phimin = smallest phi */

/* phimax = largest phi */

/* steps = number of steps in grid search */

/* class = list of variables for class statment */

/* model = list of terms in model statement */

/* stmts = %str(other mixed statements, incl. random) */

/* data = dataset with original data */

/* response = name of response variable in dataset */

/* */

/***********************************************************/

data t;

set &data;

phi=&phimin;

size=(&phimax-&phimin)/&steps;

do i=0 to &steps;

if phi ne 0 then _y_=(&response**phi-1)/phi;

if abs(phi)<1e-10 then _y_=log(&response);

jac=(phi-1)*log(&response);

output;

phi=phi+size;

end;

proc sort data=t out=t;

by phi;

run;

ods output fitstatistics=fit;

proc mixed data=t method=ml;

class &class;

model _y_=&model;

&stmts;

by phi;

run;

data fit2;

set fit;

if descr='-2 Log Likelihood';

loglik=-value/2;

proc means data=t;

var jac;

output out=jac sum=;

by phi;

run;

data loglik;

merge jac fit2;

loglik=loglik+jac;

proc print data=loglik;

run;

symbol value=dot i=join;

proc gplot data=loglik;

plot loglik*phi;

run;

proc means data=loglik;

var loglik;

id phi;

output out=max max=max;

run;

data r;

if _n_=1 then set max;

set loglik;

if loglik=max;

title 'Optimal value of phi';

proc print data=r;

var phi loglik;

run;

title ' ';

%mend;

藤椅
hanszhu 发表于 2006-4-14 05:39:00

Stata help for boxcox

help boxcox dialog: boxcox also see: boxcox postestimation -------------------------------------------------------------------------------

Title

[R] boxcox -- Box-Cox regression models

Syntax

boxcox depvar [indepvars] [if] [in] [weight] [, options]

options description ------------------------------------------------------------------------- Model noconstant suppress constant term model(lhsonly) left-hand-side Box-Cox model; the default model(rhsonly) right-hand-side Box-Cox model model(lambda) both sides Box-Cox model with same parameter model(theta) both sides Box-Cox model with different parameters notrans(varlist) nontransformed independent variables

Reporting level(#) set confidence level; default is level(95) lrtest perform likelihood-ratio test

Max options nolog suppress full-model iteration log nologlr suppress restricted-model lrtest iteration log maximize_options control the maximization process; seldom used ------------------------------------------------------------------------- depvar and indepvars may contain time-series operators; see tsvarlist. bootstrap, by, jackknife, rolling, statsby, and xi are allowed; see prefix. fweights and iweights are allowed; see weight. See boxcox postestimation for features available after estimation.

Description

boxcox finds the maximum likelihood estimates of the parameters of the Box-Cox transform, the coefficients on the independent variables, and the standard deviation of the normally distributed errors for a model in which depvar is regressed on indepvars. The user has the option of transforming either the depvar, some of the indepvars, both the depvar and some of the indepvars with the same transformation parameter, or both the depvar and some of the indepvars with different transformation parameters. Any transformed variable must be strictly positive.

Options

+-------+ ----+ Model +------------------------------------------------------------

noconstant; see estimation options.

model(lhsonly|rhsonly|lambda|theta) specifies which of the four models to fit.

model(lhsonly) applies the Box-Cox transform to depvar only. model(lhsonly) is the default.

model(rhsonly) applies the transform to the indepvars only.

model(lambda) applies the transform to both depvar and indepvars, and they are transformed by the same parameter.

model(theta) applies the transform to both depvar and indepvars, but this time, each side is transformed by a separate parameter.

notrans(varlist) specifies that the variables in varlist be included as nontransformed independent variables.

+-----------+ ----+ Reporting +--------------------------------------------------------

level(#); see estimation options.

lrtest specifies that a likelihood-ratio test of significance be performed and reported for each independent variable.

+-------------+ ----+ Max options +------------------------------------------------------

nolog suppresses the iteration log when fitting the full model.

nologlr suppresses the iteration log when fitting the restricted models required by the lrtest option.

maximize_options: iterate(#) and from(init_specs); see maximize.

Model Initial value specification --------------------------------------- lhsonly from(#_t, copy) rhsonly from(#_l, copy) lambda from(#_l, copy) theta from(#_l #_t, copy) ---------------------------------------

Examples

. boxcox mpg weight price, notrans(foreign) model(theta) lrtest

. boxcox mpg weight price foreign, model(lhs) lrtest nolog nologlr

. boxcox mpg weight price, model(lambda) lrtest

. boxcox mpg weight price, notrans(foreign) model(rhs)

. boxcox mpg weight price, notrans(foreign) model(lhsonly) lrtest

Also see

Manual: [R] boxcox

Online: boxcox postestimation; lnskew0, regress

板凳
matlab-007 发表于 2015-7-9 15:26:52
可以在SAS帮助中键入BOXCOX搜索,会得到说明;
建议读一下陈峰的《现代医学统计学与Stata应用》,实际上,用Stata做要便捷许多,几乎是自动化完成参数寻找的。SAS很繁琐,帮助中有例子。

报纸
16710104 发表于 2015-8-5 00:31:42
matlab-007 发表于 2015-7-9 15:26
可以在SAS帮助中键入BOXCOX搜索,会得到说明;
建议读一下陈峰的《现代医学统计学与Stata应用》,实际上, ...
https://bbs.pinggu.org/forum.php?mod=viewthread&tid=3839105&extra=
大神能不能帮忙看一下,然后陈锋的书是在案例中描述的boxcox转换么?

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

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