当前位置:文档之家› Performance Analysis for Bit Error Rate of DS- CDMA SensorNetwork Systems with Source Coding

Performance Analysis for Bit Error Rate of DS- CDMA SensorNetwork Systems with Source Coding

Performance Analysis for Bit Error Rate of DS- CDMA SensorNetwork Systems with Source Coding
Performance Analysis for Bit Error Rate of DS- CDMA SensorNetwork Systems with Source Coding

TELKOMNIKA , Vol.10, No.1, March 2012, pp. 165~170

ISSN: 1693-6930

accredited by DGHE (DIKTI), Decree No: 51/Dikti/Kep/2010 165

Received December 1, 2011; Revised January 22, 2012; Accepted February 15, 2012

Performance Analysis for Bit-Error-Rate of DS-CDMA

Sensor Network Systems with Source Coding

Ali M. Fadhil 1, Haider M. AlSabbagh*2

1Department of Computer Engineering, College of Engineering, University of Basra, Basra, Iraq 2Department of Electrical Engineering, College of Engineering, University of Basra, Basra, Iraq

e-mail: ali_muayed@https://www.doczj.com/doc/f28501014.html,, haidermaw@https://www.doczj.com/doc/f28501014.html,

Abstrak

Salah satu teknik terkenal yg digunakan dengan jaringan sensor nirkabel untuk mengakses jaringan adalah memanfaatkan akses jamak pembagian sandi runtun langsung. Jumlah energi yang dikonsumsi dan antar pengguna masih dianggap sebagai masalah utama dengan menggunakan jaringan tersebut. Energi yang dikonsumsi dan interferensi meningkat ketika jumlah pengguna (penerima) meningkat. Penelitian ini dilakukan untuk menyelidiki pengaruh faktor mitigasi melalui analisis penyandian energi minimum yang mengeksploitasi bit redundan untuk menghemat listrik, dengan menggunakan link radio frekuensi dan modulasi on-off-keying. Faktor-faktor ini dianalisis dan dibahas untuk beberapa level galat yang diharapkan dengan memanfaatkan saluran, melalui laju galat bit dan rasio sinyal dan derau pada beberapa pengguna yang berbeda.

Kata kunci : DS-CDMA, laju galat bit, sensor nirkabel

Abstract

One of the distinguished techniques used with wireless sensor networks to access the network is utilizing direct sequence-code division multiple access. However, amount of consumed energy and multiple access interference are still considered as the main problems with employing such networks. The consumed energy and interference are rising when number of users (receivers) increases. Therefore, this paper is conducted to investigate mitigating influence these factors through analyzing the minimum energy coding which exploits redundant bits for saving power with employing radio frequency link and on-off-keying modulation. These factors are analyzed and discussed for several levels of expected errors in the utilizing channel, through the bit error rates and amount of signal to noise ratio for different number of users.

.

Keywords : bit error rate, DS-CDMA, wireless sensors

1. Introduction

Recently, wireless sensor network applications are gaining much interest in academia and industry areas. The wireless sensor network technologies have been chosen as one of the most important technologies in the 21th century [1]. Sensor networks consist of hundreds to thousands of tiny sensor nodes that can sense data, process, and communicate with each other nods or data sink [2]. Designing the wireless sensor network is challenging due to high node density, frequent topology changes, limited battery and computing power and requirement of very low cost nodes [3]. Nodes of the sensor networks communicate with each other through wireless media. The multiple access is a serious problem due to high node density, so, the code division multiple access (CDMA) is a promising multiple access scheme for sensor and ad hoc network to its interference averaging properties’ [4]. The minimum energy (ME) coding combined with direct sequenceCDMA (DS-CDMA) is proposed to address both power saving and multiple access interference (MAI) problems [5, 6]. ME coding reduces the number of high bit (1 bit) by inserting redundant bits, which results increase in codeword length (bandwidth) with less high bit. Power saving can be achieved by using On-Off-Keying (OOK) because only the high bit is transmitted through the channel. As most of bits in a codeword are zeros the multiple access interference (MAI) is also significantly reduced. Thus, it allows nearby users to co-exist and substantially enhances the bit error rate (BER) performance and specify the (SNR) to number of the receivers (users).

ISSN: 1693-6930

TELKOMNIKA Vol. 10, No. 1, March 2012 : 165 – 170

166In this paper, influence of the bit error rate on the signal to noise ratio for number of receivers is analyzed. Also, amount of energy for receiving bits is investigated for the SNR and BERs. Then, effect number of users on the probability of received bits is studied. The achieved results indicate that the SNR is dependent on the amount ratio of energy per bit to node density in the used field.

The rest of the paper is outlined as follows. Section 2 includes the model for the system and the achieved results are presented in section 3. Then, the conclusions are drawn to section 4.

2. The System Model

The model for the transmission signal is evolved in this part in order to analyze the system characteristics, represents the general DS-CDMA systems with number of receivers (N). Let the transmitted signal is given by [7, 8]:

??(?)=∑??m ???????.??(????)cos (??????)???? (1)

Where P k is the power of the transmitted signal, ?? is the common carrier angular frequency, θk is the phase shift offset, m ?(?) and ??(?) are the data and spreading signals for the k th received signal, respectively, and ?? is a random transmission delay calculated with respect to reference transmitted signal. It is accounting for the lack of synchronization among the users. The data signal and the spreading signal are given as:

m ????=∑m ??∏(???,(?+1)??)∞??∞ (1-a) ?????=∑C ??∏(???,(?+1)??)∞??∞ (1-b)

where ∏(??,??) is a unit rectangular pulse on [t 1,t 2).

To keep generality on this interesting case, consider ??∈[0,?) and ??∈[??,?] since the analyses are conducted in the time delays module, T, and phase delays module, 2π. Thus the de-spread demodulated signal S d (t) can be given as:

S d (t)= ∑M k=2 m k (t-?k )c 1(t) c k (t-?k ) cos(w c t+θk ) cosw c t + m 1(t)cos 2w c t + n(t) c 1(t)cosw c t (2)

With using the ME coding, for coding a data and ??(?)∈{?1,1} with ??(?)=????(?) getting

?????(?)=0????(?????=1) for all j, k and for some minimum period of the spreading sequence, M.

With taking into account influence of noise in the utilizing channel, we can rewrite Eq. 1 to be as:

??′???=?????+?(?) (3)

where ?(?) is a white Gaussian noise with ?, spectral density.

The output of the matched filter, with assuming the received signal is matched to transmitter number 1 at ?= ?? is:

?=???/2????(?)+???

???(?)???,??,???+???????(?)?????????

?? (4)

where, ??=(???(?),??(?)) (4-a)

and, ??(?)=cos ????.{??????.??????.??????????+?????.??????.???????????????} (4-b)

TELKOMNIKA

ISSN: 1693-6930 Performance Analysis for Bit-Error-Rate of DS-CDMA Sensor Network …. (Ali M. Fadhil) 167

The output of the correlation receiver for user 1, at t = T b is =??+??+?, where ??is the desired received signal for user number 1, ??is the interference from other users and ? is the AWGN term with variance of ???/2. In other words, the three terms are:

?? =?????(?)

??= ∑???/2????.{??????.Γ?,?????+Γ???(??)}?????

?=???????(?)???????????

The Γ?,????? and Γ???(??) are the continuous – time partial cross correlation function defined as followes:

Γ?,?????=??????????(?)???

?

Γ???????=??????????(?)????

?

To evaluate the system performance the signal to noise ratio (SNR) is analyzed. The SNR is a perfect index to evaluate the quality of the received signal. So, to find the (SNR), the signal power of the ??(?) is computed as P d1= 1/T( ?(?0??1/2 T b ??(?))2 dt = ?1?12 T b 2 if ??(?)

(?) ? {0,1} (5)

Where ?1is the percentage of high bits for m 1(t) during the transmission duration of T second. The MAI and AWGN powers can be shown to be

P n1= ??? N 0 T b / 4 + ∑(?1?? ??=2 P k / 2 ) σ

2 (6)

So, the SNR in the energy-efficient DS-CDMA system can be found as

SNR = P 1 ??? /((?1N 0T b /2) + ∑?????? P k σ 2 ) (7)

For analyzing influence error probability of a CDMA receiver several schemes have been presented in the literature over the past couple of years. The approach that first appeared in [7] is followed in this study. And, the MAI is assumed sufficiently well represented by an equivalent Gaussian random process with assuming that the power control for all the transmitters signals arrive at the receiver of transmitter high bit for each transmitter are same, i.e., ?1 = ?2 = …= ??.. For such condition Eq. (7) can be further simplified as

SNR ME =(?1{

??13?+?02??

})-1 (8)

where ?? is energy per bit and ?? is the node density.

The bit error usually occurs in moving from high bit signal into a lower bit signal or vice

versa. The average error probability of reciver1 for transmitting one bit as:

??=??.????≥?|?????=0?+??.????

where ?? is the probability of transmitting "zeros" signals and ??is the probability of transmitting "ones" signals for the first transmitter and δ is the threshold for bit detection. If ?????=0; the output of the integrator can be explained to

ISSN: 1693-6930 TELKOMNIKA Vol. 10, No. 1, March 2012 : 165 – 170

168 ??=?+∑???

???????(?)(??,??,??) (10)

If m 0(t) = 1, the output of the integrator can be explained to

??=??+???/2?? (11)

Let δ=??1/2 T b , we have

??=??(?).?????≥?????+??(?).?

????

As SNR ME approach constant, ∑(M K=2ɑK p k /2) σ2i(k) →∞ as M →∞ and P 0(t)>>P 1(t) under these condition, under these condition we can simplify P b as:

P b = (1- ɑ1) Q(?SNR ME ) (13)

where Q(x)=

1?2?

???2/2∞? du .

3. Results and Analysis

Figure 1 illustrates variation of the SNR to the number of users (receivers). The SNR increases for different values of the percentage of high bits for ??(?) during the transmission duration of T second ( ??) when the number of users increases the interference with the users are increased. Thus such behavior leads to increase amount of the MAI power and the SNR decreases.

Figure 1. SNR for DS-CDMA energy efficient to the number of users and different values of ??.

Figure 2 shows that when the ????? is increased, the SNR increases linearly at certain values, following that, the SNR become autonomous of ?????. This can be illustrated as follows, for minimum amount of ????? the noise power caused by multiple receivers is trivial. Then, for lower values of ?????, SNR is associated with ?????, so the noise power get marginal.

Figure 3 explains variation of the probability of bit error rate

to number of users. It is increasing as number of user (M) increases for different levels of ɑ1. The probability reaches to the same value in specific number of users, which leads to the save power in more than specific number of users.

TELKOMNIKA

ISSN: 1693-6930 Performance Analysis for Bit-Error-Rate of DS-CDMA Sensor Network …. (Ali M. Fadhil) 169

Figure 2. SNR for the ME DS-CDMA system with different ????? (dB) using different values of ɑ1, and N = 63.

Figure 3. probability of error per bit for different number of users (receivers) with different

values of ɑ1.

4. Conclusions

This paper investigated influence using the DS-CDMA with minimum energy (ME) coding for the wireless sensor networks. The achieved results show that the ME DS-CDMA reduce the multiple access interference, save amount of power and improving the system performance; with sending a high bit rate, 1's, the probability of multiple access interference is highly decreases with utilizing the MAI, when a certain probability of multiple channels transmitted signals and identical time are kept. This leads to enhance the total performance of the system. The ME DS-CDMA is important to be chosen for wireless sensor network due to its important role in improving the probability of bit error rate and SNR for saving power with

various number of users (receivers).

ISSN: 1693-6930

TELKOMNIKA Vol. 10, No. 1, March 2012 : 165 – 170 170References [1] C Chong, SP Kumar. Sensor networks: Evolution, opportunities, and challenges. Proceedings of the

IEEE . 2003; 91(8): 1247-1256.

[2] R. Min et al. Energy-centric enabling technologies for wireless sensor networks. lEEE Wireless

Comniunicatiotis . 2002; 9(4): 28-39.

[3] IE Akylidiz, WY Sankarasubramaniam, E Cayirci. A survey on sensor networks. IEEE

Comniunications Magazine . 2002; 40(8): 102-114.

[4] S Toumpis, AJ Goldsmith. Capacity regions for wireless ad hoc networks. IEEE Trans. Wireless

Comuncations. 2003; 2(4): 736-748.

[5] Qinghui Tang , et. al. BER performance analysis of an on-off keying based minimum energy

coding for on-off keying energy constrained wireless sensor applications . ICC2005, IEEE International Conference on communication. 2005: 2734–2738.

[6] CH Liu, HH Asada. A source coding and modulation method for power saving and interference

reduction in DS-CDMA sensor network systems . American Control Conf. 2002; 3003-3008.

[7] KB Letaief. Efficient Evaluation of the Error Probabilities of Spread-Spectrum Multiple- Access

Communications. IEEE Trans. Commun . 1997; 45(5): 239246.

[8] Y Prakash, SK Gupta. Energy efficient source coding and modulation for wireless applications . IEEE

WCNC. 2003: 212-217.

STATA最常用命令大全

stata save命令 FileSave As 例1. 表1.为某一降压药临床试验数据,试从键盘输入Stata,并保存为Stata格式文件。 STATA数据库的维护 排序 SORT 变量名1 变量名2 …… 变量更名 rename 原变量名新变量名 STATA数据库的维护 删除变量或记录 drop x1 x2 /* 删除变量x1和x2 drop x1-x5 /* 删除数据库中介于x1和x5间的所有变量(包括x1和x5) drop if x<0 /* 删去x1<0的所有记录 drop in 10/12 /* 删去第10~12个记录 drop if x==. /* 删去x为缺失值的所有记录 drop if x==.|y==. /* 删去x或y之一为缺失值的所有记录 drop if x==.&y==. /* 删去x和y同时为缺失值的所有记录 drop _all /* 删掉数据库中所有变量和数据 STATA的变量赋值 用generate产生新变量 generate 新变量=表达式 generate bh=_n /* 将数据库的内部编号赋给变量bh。 generate group=int((_n-1)/5)+1 /* 按当前数据库的顺序,依次产生5个1,5个2,5个3……。直到数据库结束。 generate block=mod(_n,6) /* 按当前数据库的顺序,依次产生1,2,3,4,5,0。generate y=log(x) if x>0 /* 产生新变量y,其值为所有x>0的对数值log(x),当x<=0时,用缺失值代替。 egen产生新变量 set obs 12 egen a=seq() /*产生1到N的自然数 egen b=seq(),b(3) /*产生一个序列,每个元素重复#次 egen c=seq(),to(4) /*产生多个序列,每个序列从1到# egen d=seq(),f(4)t(6) /*产生多个序列,每个序列从#1到#2 encode 字符变量名,gen(新数值变量名) 作用:将字符型变量转化为数值变量。 STATA数据库的维护 保留变量或记录 keep in 10/20 /* 保留第10~20个记录,其余记录删除 keep x1-x5 /* 保留数据库中介于x1和x5间的所有变量(包括x1和x5),其余变量删除keep if x>0 /* 保留x>0的所有记录,其余记录删除

Stata命令整理教学内容

Stata 命令语句格式: [by varlist:] command [varlist] [=exp] [if exp] [in range] [weight] [, options] 1、[by varlist:] *如果需要分别知道国产车和进口车的价格和重量,可以采用分类操作来求得, sort foreign //按国产车和进口车排序 . by foreign: sum price weight *更简略的方式是把两个命令用一个组合命令来写。 . by foreign, sort: sum price weight 如果不想从小到大排序,而是从大到小排序,其命令为gsort。 . sort - price //按价格从高到低排序 . sort foreign -price /*先把国产车都排在前,进口车排在后面,然后在国产车内再按价格从大小到排序,在进口车内部,也按从大到小排序*/ 2、[=exp]赋值运算 . gen nprice=price+10 //生成新变量nprice,其值为price+10 /*上面的命令generate(略写为gen) 生成一个新的变量,新变量的变量名为 nprice,新的价格在原价格的基础上均增加了10 元。 . replace nprice=nprice-10 /*命令replace 则直接改变原变量的赋值,nprice 调减后与price 变量取值相等*/ 3、[if exp]条件表达式 . list make price if foreign==0 *只查看价格超过1 万元的进口车(同时满足两个条件),则 . list make price if foreign==1 & price>10000 *查看价格超过1 万元或者进口车(两个条件任满足一个) . list make price if foreign==1 | price>10000 4、[in range]范围筛选 sum price in 1/5 注意“1/5”中,斜杠不是除号,而是从1 到 5 的意思,即1,2,3,4,5。 如果要计算前10 台车中的国产车的平均价格,则可将范围和条件筛选联合使用。 . sum price in 1/10 if foreign==0 5、[weight] 加权 sum score [weight=num] 其中,num为每个成绩所对应的人数 6、[, options]其他可选项 例如,我们不仅要计算平均成绩,还想知道成绩的中值,方差,偏度和峰度等*/ . sum score, detail . sum score, d //d 为detail 的略写,两个命令完全等价 . list price, nohead //不要表头 Stata 数据类型转换 1、字符型转化成数值型 destring, replace //全部转换为数值型,replace 表示将原来的变量(值)更新 destring date, replace ignore(“ ”) 将字符型数据转换为数值型数据:去掉字符间的空格destring price percent, gen(price2 percent2) ignore(“$ ,%”) 与date 变量类似,变量price 前面有美元符号,变量percent 后有百分号,换为数值型时需要忽略这些非数值型字符 2、数值型转化为字符型

(完整)stata命令总结,推荐文档

stata11 常用命令 注:JB统计量对应的p大于0.05 ,则表明非正态,这点跟sktest 和 swilk 检验刚好相反;dta 为数据文件;gph 为图文件;do 为程序文件;注 意stata 要区别大小写;不得用作用户变量名: _all _n _N _skip _b _coef _cons _pi _pred _rc _weight double float long int in if using with 命令:读入数据一种方式 input x y 14 2 5.5 3 6.2 47.7 58.5 end su/summarise/sum x 或su/summarise/sum x,d 对分组的描述: sort group by group:su x %%%%% tabstat economy,stats(max)%返回变量economy的最大值 %%stats括号里可以是:mean,count(非缺失观测值个数),sum(总 和),max,min,range , %% sd ,var ,cv(变易系数=标准差/ 均值),skewness,kurtosis , median,p1(1 %分位 %% 数,类似地有p10, p25, p50, p75, p95, p99),iqr(interquantile range = p75 –p25) _all %描述全部 _N 数据库中观察值的总个数。 _n 当前观察值的位置。 _pi 圆周率π 的数值。 list gen/generate % 产生数列egen wagemax=max(wage) clear use by(分组变量)

stata命令大全(全)

*********面板数据计量分析与软件实现********* 说明:以下do文件相当一部分内容来自于中山大学连玉君STATA教程,感谢他的贡献。本人做了一定的修改与筛选。 *----------面板数据模型 * 1.静态面板模型:FE 和RE * 2.模型选择:FE vs POLS, RE vs POLS, FE vs RE (pols混合最小二乘估计) * 3.异方差、序列相关和截面相关检验 * 4.动态面板模型(DID-GMM,SYS-GMM) * 5.面板随机前沿模型 * 6.面板协整分析(FMOLS,DOLS) *** 说明:1-5均用STATA软件实现, 6用GAUSS软件实现。 * 生产效率分析(尤其指TFP):数据包络分析(DEA)与随机前沿分析(SFA) *** 说明:DEA由DEAP2.1软件实现,SFA由Frontier4.1实现,尤其后者,侧重于比较C-D与Translog生产函数,一步法与两步法的区别。常应用于地区经济差异、FDI溢出效应(Spillovers Effect)、工业行业效率状况等。 * 空间计量分析:SLM模型与SEM模型 *说明:STATA与Matlab结合使用。常应用于空间溢出效应(R&D)、财政分权、地方政府公共行为等。 * --------------------------------- * --------一、常用的数据处理与作图----------- * --------------------------------- * 指定面板格式 xtset id year (id为截面名称,year为时间名称) xtdes /*数据特征*/ xtsum logy h /*数据统计特征*/ sum logy h /*数据统计特征*/ *添加标签或更改变量名 label var h "人力资本" rename h hum *排序 sort id year /*是以STATA面板数据格式出现*/ sort year id /*是以DEA格式出现*/ *删除个别年份或省份 drop if year<1992 drop if id==2 /*注意用==*/ *如何得到连续year或id编号(当完成上述操作时,year或id就不连续,为形成panel格式,需要用egen命令) egen year_new=group(year) xtset id year_new **保留变量或保留观测值 keep inv /*删除变量*/ **或 keep if year==2000 **排序 sort id year /*是以STATA面板数据格式出现 sort year id /*是以DEA格式出现 **长数据和宽数据的转换 *长>>>宽数据 reshape wide logy,i(id) j(year)

[推荐] stata基本操作汇总常用命令

[推荐] Stata基本操作汇总——常用命令 help和search都是查找帮助文件的命令,它们之间的 区别在于help用于查找精确的命令名,而search是模糊查找。 如果你知道某个命令的名字,并且想知道它的具体使用方法,只须在stata的命令行窗口中输入help空格加上这个名字。回车后结果屏幕上就会显示出这个命令的帮助文件的全部 内容。如果你想知道在stata下做某个估计或某种计算,而 不知道具体该如何实现,就需要用search命令了。使用的 方法和help类似,只须把准确的命令名改成某个关键词。回车后结果窗口会给出所有和这个关键词相关的帮助文件名 和链接列表。在列表中寻找最相关的内容,点击后在弹出的查看窗口中会给出相关的帮助文件。耐心寻找,反复实验,通常可以较快地找到你需要的内容.下面该正式处理数据了。我的处理数据经验是最好能用stata的do文件编辑器记下你做过的工作。因为很少有一项实证研究能够一次完成,所以,当你下次继续工作时。能够重复前面的工作是非常重要的。有时因为一些细小的不同,你会发现无法复制原先的结果了。这时如果有记录下以往工作的do文件将把你从地狱带到天堂。因为你不必一遍又一遍地试图重现做过的工作。在stata 窗口上部的工具栏中有个孤立的小按钮,把鼠标放上去会出

现“bring do-file editor to front”,点击它就会出现do文件编 辑器。 为了使do文件能够顺利工作,一般需要编辑do文件的“头”和“尾”。这里给出我使用的“头”和“尾”。capture clear (清空内存中的数据)capture log close (关闭所有 打开的日志文件)set more off (关闭more选项。如果打开该选项,那么结果分屏输出,即一次只输出一屏结果。你按空格键后再输出下一屏,直到全部输完。如果关闭则中间不停,一次全部输出。)set matsize 4000 (设置矩阵的最大阶数。我用的是不是太大了?)cd D: (进入数据所在的盘符和文件夹。和dos的命令行很相似。)log using (文件名).log,replace (打开日志文件,并更新。日志文件将记录下所有文件运行后给出的结果,如果你修改了文件内容,replace选项可以将其更新为最近运行的结果。)use (文件名),clear (打开数据文件。)(文件内容)log close (关闭日志文件。)exit,clear (退出并清空内存中的数据。) 实证工作中往往接触的是原始数据。这些数据没有经过整理,有一些错漏和不统一的地方。比如,对某个变量的缺失观察值,有时会用点,有时会用-9,-99等来表示。回归时如果 使用这些观察,往往得出非常错误的结果。还有,在不同的数据文件中,相同变量有时使用的变量名不同,会给合并数

常用到的stata命令

常用到的sta命令 闲话不说了。help和search都是查找帮助文件的命令,它们之间的区别在于help用于查找精确的命令名,而search是模糊查找。如果你知道某个命令的名字,并且想知道它的具体使用方法,只须在sta的命令行窗口中输入help空格加上这个名字。回车后结果屏幕上就会显示出这个命令的帮助文件的全部内容。如果你想知道在sta下做某个估计或某种计算,而不知道具体该如何实现,就需要用search命令了。使用的方法和help类似,只须把准确的命令名改成某个关键词。回车后结果窗口会给出所有和这个关键词相关的帮助文件名和链接列表。在列表中寻找最相关的内容,点击后在弹出的查看窗口中会给出相关的帮助文件。耐心寻找,反复实验,通常可以较快地找到你需要的内容。 下面该正式处理数据了。我的处理数据经验是最好能用sta的do文件编辑器记下你做过的工作。因为很少有一项实证研究能够一次完成,所以,当你下次继续工作时。能够重复前面的工作是非常重要的。有时因为一些细小的不同,你会发现无法复制原先的结果了。这时如果有记录下以往工作的do文件将把你从地狱带到天堂。因为你不必一遍又一遍地试图重现做过的工作。在sta窗口上部的工具栏中有个孤立的小按钮,把鼠标放上去会出现“bring do-file editor to front”,点击它就会出现do文件编辑器。 为了使do文件能够顺利工作,一般需要编辑do文件的“头”和“尾”。这里给出我使用的“头”和“尾”。 /*(标签。简单记下文件的使命。)*/ capture clear(清空内存中的数据) capture log close(关闭所有打开的日志文件) set mem 128m(设置用于sta使用的内存容量) set more off(关闭more选项。如果打开该选项,那么结果分屏输出,即一次只输出一屏结果。你按空格键后再输出下一屏,直到全部输完。如果关闭则中间不停,一次全部输出。) set matsize4000(设置矩阵的最大阶数。我用的是不是太大了?)

Stata常用15条命令

【命令1】:导入数据 一般做实证分析使用的是excel中的数据,其后缀名为.xls,需要将其修改为.csv insheet using name.csv, clear 【命令2】:删除重复变量 sort var1 var2 duplicatesdrop var1 var2, force 【命令3】:合并数据 use data1, clear merge m:m var1 var2 using data2 drop if _merge==2 drop if _merge==1 drop _merge 【命令4】:描述性统计分析 tabstat var1var2, stat(n min mean median p25 p75 max sd), if groupvar==0 or 1 输出到word中: logout, save(name) word replace: tabstat var, stat(n min mean p50 max sd) col(stat)f(%9.2g) 【命令5】:结果输出 安装 ssc install estout, replace 单个回归 reg y x esttab using name.rtf, compress nogap r2 ar2 star(* 0.1 ** 0.05 *** 0.01) 多个回归一起 reg y x1 est store m1 reg y x2 est store m2 esttab m1 m2 using name.rtf, compress nogap r2 ar2 star(* 0.1 ** 0.05 *** 0.01)

STATA命令应用及详细解释(汇总)

STATA命令应用及详细解释(汇总) 调整变量格式: format x1 .3f ——将x1的列宽固定为10,小数点后取三位format x1 .3g ——将x1的列宽固定为10,有效数字取三位format x1 .3e ——将x1的列宽固定为10,采用科学计数法format x1 .3fc ——将x1的列宽固定为10,小数点后取三位,加入千分位分隔符 format x1 .3gc ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符 format x1 %-10.3gc ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符,加入“-”表示左对齐 合并数据: use "C:\Documents and Settings\xks\桌面\2006.dta", clear merge using "C:\Documents and Settings\xks\桌面\1999.dta" ——将1999和2006的数据按照样本(observation)排列的自然顺序合并起来 use "C:\Documents and Settings\xks\桌面\2006.dta", clear merge id using "C:\Documents and Settings\xks\桌面 \1999.dta" ,unique sort ——将1999和2006的数据按照唯一的(unique)变量id来合并,

在合并时对id进行排序(sort) 建议采用第一种方法。 对样本进行随机筛选: sample 50 在观测案例中随机选取50%的样本,其余删除 sample 50,count 在观测案例中随机选取50个样本,其余删除 查看与编辑数据: browse x1 x2 if x3>3 (按所列变量与条件打开数据查看器)edit x1 x2 if x3>3 (按所列变量与条件打开数据编辑器) 数据合并(merge)与扩展(append) merge表示样本量不变,但增加了一些新变量;append表示样本总量增加了,但变量数目不变。 one-to-one merge: 数据源自stata tutorial中的exampw1和exampw2 第一步:将exampw1按v001~v003这三个编码排序,并建立临时数据库tempw1 clear use "t:\statatut\exampw1.dta" su ——summarize的简写 sort v001 v002 v003 save tempw1

(完整)stata命令总结,推荐文档

stata11常用命令 注:JB统计量对应的p大于0.05,则表明非正态,这点跟sktest和swilk 检验刚好相反; dta为数据文件; gph为图文件; do为程序文件; 注意stata要区别大小写; 不得用作用户变量名: _all _n _N _skip _b _coef _cons _pi _pred _rc _weight double float long int in if using with 命令: 读入数据一种方式 input x y 1 4 2 5.5 3 6.2 4 7.7 5 8.5 end su/summarise/sum x 或 su/summarise/sum x,d 对分组的描述: sort group by group:su x %%%%% tabstat economy,stats(max) %返回变量economy的最大值 %%stats括号里可以是:mean,count(非缺失观测值个数),sum(总和),max,min,range, %% sd,var,cv(变易系数=标准差/均值),skewness,kurtosis,median,p1(1%分位 %% 数,类似地有p10, p25, p50, p75, p95, p99),iqr(interquantile range = p75 – p25) _all %描述全部 _N 数据库中观察值的总个数。 _n 当前观察值的位置。 _pi 圆周率π的数值。 list gen/generate %产生数列 egen wagemax=max(wage) clear use by(分组变量)

常用到的stata命令

安装estat: ssc install estout,replace\ 2010-10-14 11:38:15来自: 杨囡囡(all a woman lack is a wife) (转自人大论坛) 调整变量格式: format x1 %10.3f ——将x1的列宽固定为10,小数点后取三位 format x1 %10.3g ——将x1的列宽固定为10,有效数字取三位 format x1 %10.3e ——将x1的列宽固定为10,采用科学计数法 format x1 %10.3fc ——将x1的列宽固定为10,小数点后取三位,加入千分位分隔符 format x1 %10.3gc ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符 format x1 %-10.3gc ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符,加入“-”表示左对齐 合并数据: use "C:\Documents and Settings\xks\桌面\2006.dta", clear merge using "C:\Documents and Settings\xks\桌面\1999.dta" ——将1999和2006的数据按照样本(observation)排列的自然顺序合并起来 use "C:\Documents and Settings\xks\桌面\2006.dta", clear merge id using "C:\Documents and Settings\xks\桌面\1999.dta" ,unique sort ——将1999和2006的数据按照唯一的(unique)变量id来合并,在合并时对id进行排序(sort) 建议采用第一种方法。 对样本进行随机筛选: sample 50 在观测案例中随机选取50%的样本,其余删除 sample 50,count 在观测案例中随机选取50个样本,其余删除 查看与编辑数据:

stata常用命令

面板数据估计 首先对面板数据进行声明: 前面是截面单元,后面是时间标识: tsset company year tsset industry year 产生新的变量:gen newvar=human*lnrd 产生滞后变量Gen fiscal(2)=L2.fiscal 产生差分变量Gen fiscal(D)=D.fiscal 描述性统计: xtdes :对Panel Data截面个数、时间跨度的整体描述 Xtsum:分组内、组间和样本整体计算各个变量的基本统计量 xttab 采用列表的方式显示某个变量的分布 Stata中用于估计面板模型的主要命令:xtreg xtreg depvar [varlist] [if exp] , model_type [level(#) ] Model type 模型 be Between-effects estimator fe Fixed-effects estimator re GLS Random-effects estimator pa GEE population-averaged estimator mle Maximum-likelihood Random-effects estimator 主要估计方法: xtreg: Fixed-, between- and random-effects, and population-averaged linear models xtregar:Fixed- and random-effects linear models with an AR(1) disturbance xtpcse :OLS or Prais-Winsten models with panel-corrected standard errors xtrchh :Hildreth-Houck random coefficients models

stata常用命令

stata常用命令 stata save命令 FileSave As 例1. 表1.为某一降压药临床试验数据,试从键盘输入Stata,并保存为Stata格式文件。STATA数据库的维护 排序 SORT 变量名1 变量名2 …… 变量更名 rename 原变量名新变量名 STATA数据库的维护 删除变量或记录 drop x1 x2 /* 删除变量x1和x2 drop x1-x5 /* 删除数据库中介于x1和x5间的所有变量(包括x1和x5) drop if x<0 /* 删去x1<0的所有记录 drop in 10/12 /* 删去第10~12个记录 drop if x==. /* 删去x为缺失值的所有记录 drop if x==.|y==. /* 删去x或y之一为缺失值的所有记录 drop if x==.&y==. /* 删去x和y同时为缺失值的所有记录 drop _all /* 删掉数据库中所有变量和数据 STATA的变量赋值 用generate产生新变量 generate 新变量=表达式 generate bh=_n /* 将数据库的内部编号赋给变量bh。 generate group=int((_n-1)/5)+1 /* 按当前数据库的顺序,依次产生5个1,5个2,5个3……。直到数据库结束。 generate block=mod(_n,6) /* 按当前数据库的顺序,依次产生1,2,3,4,5,0。generate y=log(x) if x>0 /* 产生新变量y,其值为所有x>0的对数值log(x),当x<=0时,用缺失值代替。 egen产生新变量 set obs 12 egen a=seq() /*产生1到N的自然数 egen b=seq(),b(3) /*产生一个序列,每个元素重复#次 egen c=seq(),to(4) /*产生多个序列,每个序列从1到# egen d=seq(),f(4)t(6) /*产生多个序列,每个序列从#1到#2

常用stata命令-好用

我常用到的stata命令 最重要的两个命令莫过于help和search了。即使是经常使用stata的人也很难,也没必要记住常用命令的每一个细节,更不用说那些不常用到的了。所以,在遇到困难又没有免费专家咨询时,使用stata自带的帮助文件就是最佳选择。stata的帮助文件十分详尽,面面俱到,这既是好处也是麻烦。当你看到长长的帮助文件时,是不是对迅速找到相关信息感到没有信心? 闲话不说了。help和search都是查找帮助文件的命令,它们之间的区别在于help用于查找精确的命令名,而search是模糊查找。如果你知道某个命令的名字,并且想知道它的具体使用方法,只须在stata的命令行窗口中输入help空格加上这个名字。回车后结果屏幕上就会显示出这个命令的帮助文件的全部内容。如果你想知道在stata下做某个估计或某种计算,而不知道具体该如何实现,就需要用search命令了。使用的方法和help类似,只须把准确的命令名改成某个关键词。回车后结果窗口会给出所有和这个关键词相关的帮助文件名和链接列表。在列表中寻找最相关的内容,点击后在弹出的查看窗口中会给出相关的帮助文件。耐心寻找,反复实验,通常可以较快地找到你需要的内容。 下面该正式处理数据了。我的处理数据经验是最好能用stata的do文件编辑器记下你做过的工作。因为很少有一项实证研究能够一次完成,所以,当你下次继续工作时。能够重复前面的工作是非常重要的。有时因为一些细小的不同,你会发现无法复制原先的结果了。这时如果有记录下以往工作的do文件将把你从地狱带到天堂。因为你不必一遍又一遍地试图重现做过的工作。在stata窗口上部的工具栏中有个孤立的小按钮,把鼠标放上去会出现“bring do-file editor to front”,点击它就会出现do文件编辑器。 为了使do文件能够顺利工作,一般需要编辑do文件的“头”和“尾”。这里给出我使用的“头”和“尾”。 /*(标签。简单记下文件的使命。)*/ capture clear (清空内存中的数据) capture log close (关闭所有打开的日志文件) set mem 128m (设置用于stata使用的内存容量) set more off (关闭more选项。如果打开该选项,那么结果分屏输出,即一次只输出一屏结果。你按空格键后再输出下一屏,直到全部输完。如果关闭则中间不停,一次全部输出。)set matsize 4000 (设置矩阵的最大阶数。我用的是不是太大了?) cd D: (进入数据所在的盘符和文件夹。和dos的命令行很相似。) log using (文件名).log,replace (打开日志文件,并更新。日志文件将记录下所有文件运行后给出的结果,如果你修改了文件内容,replace选项可以将其更新为最近运行的结果。) use (文件名),clear (打开数据文件。) (文件内容)

stata常用命令

调整变量格式: format x1 % ——将x1的列宽固定为10,小数点后取三位 format x1 % ——将x1的列宽固定为10,有效数字取三位 format x1 % ——将x1的列宽固定为10,采用科学计数法 format x1 % ——将x1的列宽固定为10,小数点后取三位,加入千分位分隔符 format x1 % ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符 format x1 % ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符,加入“-”表示左对齐合并数据: use "C:\Documents and Settings\xks\桌面\", clear merge using "C:\Documents and Settings\xks\桌面\" ——将1999和2006的数据按照样本(observation)排列的自然顺序合并起来 use "C:\Documents and Settings\xks\桌面\", clear merge id using "C:\Documents and Settings\xks\桌面\" ,unique sort ——将1999和2006的数据按照唯一的(unique)变量id来合并,在合并时对id进行排序(sort)建议采用第一种方法。 对样本进行随机筛选: sample 50 在观测案例中随机选取50%的样本,其余删除 sample 50,count 在观测案例中随机选取50个样本,其余删除 查看与编辑数据: browse x1 x2 if x3>3 (按所列变量与条件打开数据查看器) edit x1 x2 if x3>3 (按所列变量与条件打开数据编辑器) 数据合并(merge)与扩展(append) merge表示样本量不变,但增加了一些新变量;append表示样本总量增加了,但变量数目不变。one-to-one merge: 数据源自stata tutorial中的exampw1和exampw2 第一步:将exampw1按v001~v003这三个编码排序,并建立临时数据库tempw1 clear use "t:\statatut\" su ——summarize的简写 sort v001 v002 v003 save tempw1 第二步:对exampw2做同样的处理 clear use "t:\statatut\" su sort v001 v002 v003 save tempw2 第三步:使用tempw1数据库,将其与tempw2合并: clear use tempw1 merge v001 v002 v003 using tempw2 第四步:查看合并后的数据状况:

Stata统计分析命令

Stata统计分析常用命令汇总 一、winsorize极端值处理 范围:一般在1%和99%分位做极端值处理,对于小于1%的数用1%的值赋值,对于大于99%的数用99%的值赋值。 1、Stata中的单变量极端值处理: stata 11.0,在命令窗口输入“findit winsor”后,系统弹出一个窗口,安装winsor模块 安装好模块之后,就可以调用winsor命令,命令格式:winsor var1, gen(new var) p(0.01) 或者在命令窗口中输入:ssc install winsor安装winsor命令。winsor命令不能进行批量处理。 2、批量进行winsorize极端值处理: 打开链接:.edu/judson.caskey/data.html,找到winsorizeJ,点击右键,另存为到stata中的ado/plus/目录下即可。命令格式:winsorizeJ var1var2var3,suffix(w)即可,这样会生成三个新变量,var1w var2w var3w,而且默认的是上下1%winsorize。如果要修改分位点,则写成如下格式:winsorizeJ var 1 var2 var3,suffix(w) cuts(5 95)。 3、Excel中的极端值处理:(略) winsor2 命令使用说明 简介:winsor2 winsorize or trim (if trim option is specified) the variables in varlist at particular percentiles specified by option cuts(# #). In defult, new variables will be generated with a suffix "_w" or "_tr", which can be changed by specifying suffix() option. The replace option replaces the variables with their winsorized or trimmed ones. 相比于winsor命令的改进: (1) 可以批量处理多个变量; (2) 不仅可以winsor,也可以trimming; (3) 附加了by() 选项,可以分组winsor 或trimming; (4) 增加了replace 选项,可以不必生成新变量,直接替换原变量。 范例: *- winsor at (p1 p99), get new variable "wage_w" . sysuse nlsw88, clear . winsor2 wage *- left-trimming at 2th percentile . winsor2 wage, cuts(2 100) trim *- winsor variables by (industry south), overwrite the old variables . winsor2 wage hours, replace by(industry south) 使用方法: 1. 请将winsor 2.ado 和winsor2.sthlp 放置于stata12\ado\base\w 文件夹下; 2. 输入help winsor2 可以查看帮助文件; 二、描述性统计 1、summarize 命令格式:su、sum或者summarize [varlist] [if] [in] [weight] [,options] 如果summarize或sum后不加任何变量,则默认对数据中的所有变量进行描述统计options 选项:detail 表示产生更加详细的统计变量

常用到的STATA命令

年0606月月0101日,日,日,200820082008年第年第年第44期,总第期,总第6 6期编者按:Stata 的数据管理能力非常powerful ,而我们EpiMan 论坛上有很多优秀的帖子,我们会不定期对其进行整理,以期使得大家可以更好地掌握Stata 软件,提高工作和学习的效率和乐趣。毕竟,Stata 是一款巨有特色的统计软件包,推荐使用。 我常用到的Stata命令 by 无为而治的西瓜与西瓜老死不相往来 Special Issue Fundamental of Data Manipulation Using Stata https://www.doczj.com/doc/f28501014.html,

EpiMan Cluster特刊:我常用到的Stata命令 https://www.doczj.com/doc/f28501014.html, Special Issue 我常用到的Stata命令 文章作者:无为而治的西瓜与西瓜老死不相往来 本期主编:epiman 本期审校:epiman 本期排版:epiman 2008年06月01日 2008年第4期 总第6期 邮箱:epiman@https://www.doczj.com/doc/f28501014.html, 网址:https://www.doczj.com/doc/f28501014.html, 目录 第一讲,do文件的穿靴戴帽 第二讲,原始数据→分析数据 第三讲,批量生成虚拟变量 第四讲,改变数据结构 第五讲,复杂数据处理技巧--迂回 第六讲,本期声明和好汉招募

第一讲,help和search的区别以及do文件的穿靴戴帽第一讲,help和search的区别以及do文件的穿靴戴帽 作者:无为而治的西瓜与西瓜老死不相往来@https://www.doczj.com/doc/f28501014.html, 最重要的两个命令莫过于help和search了。即使是经常使用stata的人也很难,也没必要记住常用命令的每一个细节,更不用说那些不常用到的了。所以,在遇到困难又没有免费专家咨询时,使用stata自带的帮助文件就是最佳选择。stata的帮助文件十分详尽,面面俱到,这既是好处也是麻烦。当你看到长长的帮助文件时,是不是对迅速找到相关信息感到没有信心?闲话不说了。help和search都是查找帮助文件的命令,它们之间的区别在于help用于查找精确的命令名,而search是模糊查找。如果你知道某个命令的名字,并且想知道它的具体使用方法,只须在stata的命令行窗口中输入help空格加上这个名字。回车后结果屏幕上就会显示出这个命令的帮助文件的全部内容。如果你想知道在stata下做某个估计或某种计算,而不知道具体该如何实现,就需要用search命令了。使用的方法和help类似,只须把准确的命令名改成某个关键词。回车后结果窗口会给出所有和这个关键词相关的帮助文件名和链接列表。在列表中寻找最相关的内容,点击后在弹出的查看窗口中会给出相关的帮助文件。耐心寻找,反复实验,通常可以较快地找到你需要的内容。 下面该正式处理数据了。我的处理数据经验是最好能用stata的do文件编辑器记下你做过的工作。因为很少有一项实证研究能够一次完成,所以,当你下次继续工作时。能够重复前面的工作是非常重要的。有时因为一些细小的不同,你会发现无法复制原先的结果了。这时如果有记录下以往工作的do文件将把你从地狱带到天堂。因为你不必一遍又一遍地试图重现做过的工作。在stata窗口上部的工具栏中有个孤立的小按钮,把鼠标放上去会出现“bring do-file editor to front”,点击它就会出现do文件编辑器。 为了使do文件能够顺利工作,一般需要编辑do文件的“头”和“尾”。这里给出我使用的“头”和“尾”。 capture clear(清空内存中的数据) capture log close(关闭所有打开的日志文件) set mem128m(设置用于stata使用的内存容量) set more off(关闭more选项。如果打开该选项,那么结果分屏输出,即一次只输出一屏结果。你按空格键后再输出下一屏,直到全部输完。如果关闭则中间不停,一次全部输出。)set matsiz e4000(设置矩阵的最大阶数。我用的是不是太大了?) cd D:(进入数据所在的盘符和文件夹。和dos的命令行很相似。) log using(文件名).log,replace(打开日志文件,并更新。日志文件将记录下所有文件运行后给出的结果,如果你修改了文件内容,replace选项可以将其更新为最近运行的结果。)use(文件名),clear(打开数据文件。) (文件内容) log close(关闭日志文件。) exit,clear(退出并清空内存中的数据。) 这个do文件的“头尾”并非我的发明,而是从沈明高老师那里学到的。版权归沈明高老师。

stata常用命令

stata 常用命令 (2012-07-29 17:22:25) 转载▼ 分类:stata 标签: 杂谈 save命令 FileSave As 例1. 表1.为某一降压药临床试验数据,试从键盘输入Stata,并保存为Stata格式文件。STATA数据库的维护 排序 SORT 变量名1 变量名2 …… 变量更名 rename 原变量名新变量名 STATA数据库的维护 删除变量或记录 drop x1 x2 /* 删除变量x1和x2 drop x1-x5 /* 删除数据库中介于x1和x5间的所有变量(包括x1和x5) drop if x<0 /* 删去x1<0的所有记录 drop in 10/12 /* 删去第10~12个记录 drop if x==. /* 删去x为缺失值的所有记录 drop if x==.|y==. /* 删去x或y之一为缺失值的所有记录 drop if x==.&y==. /* 删去x和y同时为缺失值的所有记录 drop _all /* 删掉数据库中所有变量和数据 STATA的变量赋值 用generate产生新变量 generate 新变量=表达式 generate bh=_n /* 将数据库的内部编号赋给变量bh。 generate group=int((_n-1)/5)+1 /* 按当前数据库的顺序,依次产生5个1,5个2,5个 3……。直到数据库结束。 generate block=mod(_n,6) /* 按当前数据库的顺序,依次产生1,2,3,4,5,0。generate y=log(x) if x>0 /* 产生新变量y,其值为所有x>0的对数值log(x),当x<=0时,用缺失值代替。 egen产生新变量 set obs 12 egen a=seq() /*产生1到N的自然数 egen b=seq(),b(3) /*产生一个序列,每个元素重复#次 egen c=seq(),to(4) /*产生多个序列,每个序列从1到# egen d=seq(),f(4)t(6) /*产生多个序列,每个序列从#1到#2 encode 字符变量名,gen(新数值变量名) 作用:将字符型变量转化为数值变量。

相关主题
文本预览
相关文档 最新文档