stata怎么做stata 求分位数数统计p25 p50 p75

当前位置: >>
Stata常用指令
Stata 常用指令set more off set virtual on di exp(3.567)解= displayBrowse the datatabmiss x1 x2 browse var1 var2 (if ….) (findit tabmiss) @示 MV 的 fr
eq c比例 Look like editor window, but cannot edit listblck in 1/10, repeat(1) (findit listblck) list, 但婷婢s repeat(1/n) =& 前 1(n)重}出 F after row 2 (findit univar) univar chinese math science, boxplot , by(gender) onehdr univar math, by(gender) onehdr boxplot onescal univar (=sum) 但增加 q25, midian, q75 的呈F get a table with one header onescale 才能相比^Summary Statistics & Tablessum we can use if : eg. (if crime==1) tab x1, sort miss (sort=按照 distribution 排列; miss=列出 MV distribution as well) ta x1 x2, chi2 miss , nof column (no frequency / column percentage) , row (row percentage) , all (all available statistics) , exact (Fisher’s exact test) ta maage_group, plot tab1 x1 x2 x3 x4 tab2 x1 x2 x3 x4 ta paedu, sum(crime) = tab x1 / tab x2……. tab all possible two-way.. By levels of paedu, summarize crime tabstat score, stats(mean sd n max min…) by (subject) median, p10, p25, iqr, q… Chi2=Pearson chi-square test of independence Summarize all variables (mean, SD, freqency) tab=tabulate iqr=interquaritile range=p75-p25 q=quartiles= if we specify p25 p50 p75 table x1 x2, contents(mean y1 median y2) Also min, max….etc…..Data Managementgen id=_n sort id browse var1 var2 (if ….) (then do something else) If want to come back to the earlier order….. Look like editor window, but cannot edit edit var1 var2 var3 (if…) label variable bw “birth weight” drop if id==id[_n-1] & birthday==birthday[_n-1] Or just replace delete=1, 就不 用真的 delete format id %9.0f encode region, gen(region2) tab region2 tab region2, nolabel mvdecode mvencode (looks the same but…) (now we see the numeric value) numeric value =& mv mv =& numeric value 字元太多不蝻@Fr…. It generate labeled- numeric var from a string variable.egen zscore=std(x) egen avg=rmean(Chinese, English, math) egen sum=rsum(x,y,z) list population region, nolabel (only for lebeled numeric variables, not string var) [分M 分M] 分M sort var gen varnew=group(5) egen iseicat=cut(isei), at(10, 40, 70, 90) table iseicat, contents(min isei max isei) =& z查史 (mean=0, V=1) Row mean, ignore MV Row sum, MV=0 Display numeric var instead of the labels分成相同 cases 五M分成 10, 40, 70 三M 不包括上限 (eg.90) 不被包括者 =& MVegen iseicat=cut(isei), at(10, 40, 70, 90) icodes egen iseicat=cut(isei), at(10, 40, 70, 90) label=& 成 0, 1, 2 三M =& 跟 icodes 一 但加了 label , (10- 40- 70- ) local x &st2 st3 st4 st5....& [for later use: type `x']定xL字串Importing data from other programsinfile str30 place population sex score using test.raw String var 之前要加 str#, as many as #characters (clean Excel data following stata data format) (save Excel as .csv file ) insheet using “c:/data/test.csv” infix reshape? collapse? Excel =& stata dataCompare groupsttest college, by(male)Regressionby region3, sort:reg score paedu sort region3 by region3:reg score paedu reg y x1 x2 x3, beta sw reg Y x1 x2 x3 x4 x5….., pr(.05) pr=p to retain (backward elimination) sw reg Y x1 x2 x3 x4 x5….., pe(.05) standardized regression Stepwise reg: 它自己 remove 不@著 Xs pe=p to enterAfter regression…predict yhat predict e, risid sort e list v1 v2 v3… in 1/10 lstat ? Listcoef, help (要 search & install: Long’s spostdo) (or in -10/l) (l=last, not one) Residual We can examine where the model fits poorly… correct classification rate 列出 X(&Y)的驶S After logistic regressionest store full quietly logistic y x (nested model) lrtest full logit y x predict phat graph twoway connected phat x, sort predict q, xb predict phat graph twoway mspline phat x2 adjust, by(var1) exp adjust, by(var1) pr 後者=前者*exp(b) p/(1-p)=odds (when var1=n) =& odds when var1=1,2,3.. =& p(y) when var1=1,2,3.. exp(B1) * exp(B2) =& xb = lg odd = ln(p/(1-p)) =& Phat=predicted p =exp(a+bx)/[1+exp(a+bx)] Likelihood-ratio test :Interaction term 的: B1(Main)+B2(dummy) For the group (dummy=1): the odds ratio of Main is logistic y var1 var2 inter lincom var1+inter lincom [2]lbw+[2]inter10, or (for mlogit) ([2]=model)Get point estimation & CI of coefficient combination用方便的方式得到 predicted probabilityprchange prchange, fromto help prtab prtab, x(paedu=1 maedu=1) rest(min) prgen isei, f(30) t(60) gen(ff) x(male=0) prgen isei, f(30) t(60) gen(mm) x(male=1) twoway (connected ffp1 ffx) (connected mmp1 mmx) xi3: logit y i.x1*male postgr3 male, by(x1) table postgr3 isei, by(area) (very useful for obtain p) (Bm也可以) (findit spost) (help: add f明) Changes in predicted probability Predicted probability in n*n table Bm y=1 的影(於 茸尤 n[default=11]c 算 p) 有 interaction term r…… =& male effect 因 x1 e而不 同mlogitmlogit y x1 x2, rrr nolog base(2) (ref group=& y=2) rrr=relative risk ratio (=OR) Output outreg using test.doc, nolabel replace outreg using test.doc, nolabel append (findit outreg) & install Then convert text into table Υr要 click no 另存新n append = model 2 add on M1 outreg var1 var2 using test.xls, replace 10pct coefastr se (se=st. error instead of t statistics) log using myfile.smcl, replace (don’t use t) 可指定列出哪些S (+ p&.1) (* add on coef) (先 findit log2html) =& 可以把Y果存成 html最後:log2html myfile.smcl, replaceGraphgraph dir graph use gender_gap graph save filename erase filename.gph i.e., filename.gph is saved List all the graph files其他sgmediation var_y, mv(varx1) iv(varx2) [Sobel-Goodman tests: use findit first] test whether a mediator carries the influence of an IV to a DV.省rprogram define shortcut command 1 end shortcut (自己跑一遍 command 1, 2..) =&shortcut 本身成 command … command 2 Shortcut=program name we set超常用 list, gen, recode, replace, rename, sort, drop, keep, order…… merge, append _merge=1 (from master data), 2=from using data…苹果/安卓/wp
积分 1289, 距离下一级还需 86 积分
权限: 自定义头衔, 签名中使用图片, 隐身
道具: 彩虹炫, 涂鸦板, 雷达卡, 热点灯, 金钱卡, 显身卡, 匿名卡, 抢沙发下一级可获得
权限: 设置帖子权限道具: 提升卡
购买后可立即获得
权限: 隐身
道具: 金钱卡, 彩虹炫, 雷达卡, 热点灯, 涂鸦板
苦逼签到天数: 824 天连续签到: 2 天[LV.10]以坛为家III
stata中如何求中位数的命令是什么
载入中......
本帖被以下文库推荐
& |主题: 21, 订阅: 2
tabstat variable, stats (sd median range)
热心帮助其他会员
总评分:&论坛币 + 5&
热心指数 + 1&
文库:微观数据研讨
sum variable,d
热心帮助其他会员
总评分:&论坛币 + 10&
学术水平 + 2&
热心指数 + 4&
信用等级 + 3&
shetianlang 发表于
tabstat variable, stats (sd median range)用tabstat variable, stats (sd median range)能看出中位数,若我要把中位数提取出来,怎么办?就好像r(N)代表样本容量,r(sd)代表标准误,中位数用什么表示?
谢谢各位帮忙,我知道了,用sum 变量,d命令后,再用return list 命令就可了,用r(p50)表示。
直接用centile price也可以,如果要设定范围,比如从第二行到第五行,则命令格式是centile price in2/5;同样 tabstat variable in 2/5, stats (sd median range),P50就是中位数。注意,如果是偶数位的话,stata只提供中间两值的均数,这点和我们手工计算不一样。qq:.相互学习
热心帮助其他会员
总评分:&论坛币 + 5&
热心指数 + 1&
centile variable
the median value is saved in r(c_1)
egen x_p50 = pctile(x), p(50)
总评分:&学术水平 + 1&
热心指数 + 1&
如果只是要中位数:egen x_med = median(x)复制代码然而,&晴天风之扬&的方法较一般,可求得其他分位数!
初级学术勋章
初级学术勋章
初级热心勋章
初级热心勋章
无限扩大经管职场人脉圈!每天抽选10位免费名额,现在就扫& 论坛VIP& 贵宾会员& 可免费加入
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
如有投资本站或合作意向,请联系(010-);
邮箱:service@pinggu.org
投诉或不良信息处理:(010-)
京ICP证090565号
论坛法律顾问:王进律师 上传我的文档
 下载
 收藏
多年人力资源管理经验,擅长人事和行政相关
 下载此文档
正在努力加载中...
Eviews+stata分析面板数据的理论与操作一个文件全搞定
下载积分:0
内容提示:Eviews+stata分析面板数据的理论与操作一个文件全搞定
文档格式:PDF|
浏览次数:72|
上传日期: 14:52:22|
文档星级:
全文阅读已结束,如果下载本文需要使用
 0 积分
下载此文档
该用户还上传了这些文档
Eviews+stata分析面板数据的理论与操作一个文件全搞定
官方公共微信您所在位置: &
&nbsp&&nbsp&nbsp&&nbsp
现代医学统计方法与stata应用第二版.pdf289页
本文档一共被下载:
次 ,您可全文免费在线阅读后下载本文档。
文档加载中...广告还剩秒
需要金币:218 &&
现代医学统计方法与stata应用第二版.pdf
你可能关注的文档:
··········
··········
现代医学统计方法与Stata应用 第二版 目 录
………………………………………………………………………………………… §1.1 Stata的功能、特点和背景 ………………………………………………………………………… §1.2 Stata的使用入门 …………………………………………………………………………………… §1.3 Stata的数据输入与储存 …………………………………………………………………………… §1.4 Stata的结果文件 …………………………………………………………………………………… §1.5 Stata的帮助功能 ……………………………………………………………………………………
Stata的函数和变量
……………………………………………………………………………… §2.1 Stata 的函数 ………………………………………………………………………………………… §2.2 Stata 的格式文件、变量和系统变量 ……………………………………………………………… §2.3 Stata 的算术运算和关系运算 ………………………………………………………………………
Stata的数据管理
………………………………………………………………………………… §3.1 Stata数据库的建立 ………………………………………………………………………………… §3.2 数据库、变量、数值的说明 ……………………………………………………………………… §3.3 数据库的维护 ……………………………………………………………………………………… §3.4 变量赋值 …………………………………………………………………………………………… §3.5 数据库结果的转换 …………………………
正在加载中,请稍后...干货 福利 常用的27个Stata命令-提供留学,移民,理财,培训,美容,整形,高考,外汇,印刷,健康,建材等信息_突袭网
当前位置&:&&&&干货 福利 常用的27个Stata命令
热门标签:&
干货 福利 常用的27个Stata命令
来源: 由用户
编辑:王亮
注意:红色字体表示使用时需要结合实际进行修改的内容【1】直接导入csv格式数据insheet using name.csv, clear【2】修改变量长度format var %20.2g【3】删除重复值sort&var1 var2duplicatesdrop var1 var2, force【4】数据合并use data1, clearmerge m:m var1var2 using data2drop if _merge==2drop if _merge==1drop _merge&【5】生成一期滞后项tsset stkcd accpergen newvarname=L.varname&【6】将文字转化为数字变量genBigN=0replaceBigN=1 if strmatch(dadtunit,'普华永道*')&【7】删除有缺失值的记录egen mis=rowmiss(_all)drop if misdrop mis&【8】行业划分clonevarsic2=indorder stkcd accper sic2replace sic2=substr(sic2,1,1) if substr(sic2,1,1)!=”C”replace sic2=substr(sic2,1,2) if substr(sic2,1,1)==”C”tabulate sic2 accper&【9】日期只保留年份drop if substr( reptdt ,6,2)!='12'replace reptdt=substr(reptdt,1,4)gen accper=real(reptdt)&【10】数据分列split date ,parse(-) destring ignor('-')&【11】求两个日期之间的间隔天数g td=date(trading_date,'YMD')g ed=date(eventdate,'YMD')form td ed %tdg d=ed-td&【12】生成行业、年份哑变量tab year, gen(year)tab industry, gen(industry)&【13】对数据进行Winsorize处理findit winsor2winsor2 varname, replace cut(1 99)&【14】描述性统计tabstat var1var2, stat(n min mean median p25 p75 max sd), &if groupvar==0 or 1logout, save(name) word replace: tabstat var, stat(n min mean p50 max sd) col(stat)f(%9.2g)&【15】两变量列联表tabulate var1 var2, row chi2 taub gamma&【16】两样本间的均值T检验ttest var, by(groupvar)&【17】两样本中位数Z检验ranksum var, by(groupvar)&【18】Pearson/Spearman系数spearmanx*n matax=st_data(.,'x*')c=correlation(x)n=rows(c)b=strofreal(lowertriangle(c)+uppertriangle(st_matrix('r(Rho)')),'%9.3f')p=st_matrix('r(P)')for (i=2; i<=n; i++) {for (j=1; j<=i-1; j++) {p[i,j]=2*ttail(rows(x)-2,abs(c[i,j]/sqrt((1-c[i,j]^2)/(rows(x)-2))))b[i,j]=b[i,j]+(p[i,j]<0.01?'***':(p[i,j]<0.05?'**':(p[i,j]<0.1?'*':'')))b[j,i]=b[j,i]+(p[j,i]<0.01?'***':(p[j,i]<0.05?'**':(p[j,i]<0.1?'*':'')))}}c=editvalue(b, '2.000', '1')cend直接导出结果logout, save(pw) word replace:pwcorr_avars, star1(0.01) star5(0.05) star10(0.1)&【19】按年度按中位数分组方法一bysort year: egen g=xtile(var), n(2)方法二bys accper: cumul icindex, g(g) eqlevelsof accper, local(id) display '`r(levels)''local cut1 = 1/2foreach x of local id {recode g (min/`cut1'=0)(`cut1'/max=1) if accper==`x'}& 分三组bys accper:cumul icindex, g(g) eqlevelsof accper, local(id) display '`r(levels)''local cut1 = 1/3local cut2 = 2/3foreach x of local id {recode g (min/`cut1'=1)(`cut1'/`cut2'=2)(`cut2'/max=3)if accper==`x'}【20】输出回归结果安装& ssc install estout, replace单个回归reg esttab using name.rtf, compress nogap r2 ar2 star(* 0.1 ** 0.05 *** 0.01)&多个回归一起reg est store m1reg est store m2esttab m1 m2 using name.rtf, compress nogap r2 ar2 star(* 0.1 ** 0.05 *** 0.01)&连续运行tobit模型结果导出:esttab m1 m2, b(%9.4f) t scalars(N ll Fchi2 type), using name.rtf, compress nogap连续运行OLS模型结果导出:esttab m1m2, b(%9.4f) tscalars(N r2 F p), using name.rtf, compress nogap&【21】异方差检验及处理检验:怀特检验ssc install whitetstregestat imtest, white处理:“OLS+稳健标准差”reg y x1 x2 x3, robust&【22】DW检验(序列相关性一阶)gen id=_ntsset idestat dwatson&【23】多重共线性reg y x1 x2 x3vif&【24】是否遗漏高次项例如,检验y对x的线性回归有没有遗漏高次项reg y xestat ovtest或者estat ovtest, rhs&【25】逐步回归stepwise, pe(0.1): reg y x&&【26】Maddala(1983)两阶段处理效应模型treatreg yx1-xn, tr(z=w1-wm)two&【27】Justified Jones Modelstatsby&_b, by(ind accper)saving(*.dta,replace):reg yx, noconstantmerge m:m indaccper using *.dtagen yhat=y-_b*x&
更多精彩 >>>

我要回帖

更多关于 p25 p50 p75 的文章

 

随机推荐