state工具命令

查看文件

dir auto.dta

打开数据auto训练数据

use auto

查看数据结构

describe

#查看数据
edit

If语句

edit make price rep78 headroom if foreign==1 & price>1000

清除

clear

in

edit in 10/5
edit in 5/10

edit in 5/10 if price>1000

查看分布

summarize price trunk weight if foreign==1
summarize price trunk weight if foreign

产生数据

generate weight_price=weight + price

generate weight_price=weight+price if foreign==1 #出错:weight_price already defined
#出错原因:weight_price 已经用过了
#解决方法:换个名字或者删去之前的数据或者replace weight_price=weight+price

替换

replace weight_price=weight+price

计算平方根

generate sqrt_price=sqrt(price)

edit sqrt_price

更改

replace sqrt_price=sqrt_price^(1/2) if foreign==0

label

label variable sex “性别”
在这里插入图片描述

save

保存修改过的
save,replace

input

input sex
在这里插入图片描述

dir

dir *.dta
查找dta结尾的文件
在这里插入图片描述

doedit

doedit hyq.do
在这里插入图片描述

# 编辑do文件
Doedit hyq1


*===April 28
cd
dir
use auto
describe
generate sqrt_price=sqrt(price)
label variable sqrt_price "price变量平方根"
label dir
label list origin
*===end

Run hyq1
*====2021-4-21===
 cd//check directory
 dir//路径
 clear//清除
 use///换行加注释,三个反斜杠
 page27_5_2/*hhh*/
 describe
 edit
 generate sqrt_salary=/*hhh
        h*/sqrt(salary)
 


viewsource hyq.do
set more off
capture log close
log using hyq.log,append
clear
*===April 28
cd
dir
use auto
describe
generate sqrt_price=sqrt(price)
label variable sqrt_price "price变量平方根"
label dir
label list origin
*===end
log close

===2021-5-7==
capture log close
log using hyq.log,replace
cd
dir 
//input data
input id salary education origin_wage experience
1 57000 15 27000 14
2 40200 16 18750 36
3 21450 12 12000 381
4 21900 8 13200 190
5 45000 15 21000 138
6 28340 8 12000 26

end
mkmat salary education origin_wage experience ,mat(X)
matrix list X
//computarion
matrix I6=I(6)
matrix list I6
matrix unit=vecdiag(I6)'
matrix list unit

matrix X_bar=X'*unit/6
matrix list X_bar

matrix cross_product=X'*(I6-1/6*unit*unit')*X
matrix list cross_product

matrix covariance=1/5*cross_product
matrix list covariance

log close


===2021-5-7==
capture log close
log using hyq.log,replace
cd
dir 
//input data
input id salary education origin_wage experience
1 57000 15 27000 14
2 40200 16 18750 36
3 21450 12 12000 381
4 21900 8 13200 190
5 45000 15 21000 138
6 28340 8 12000 26

end
mkmat salary education origin_wage experience ,mat(X)
matrix list X
//computarion
matrix I6=I(6)
matrix list I6
matrix unit=vecdiag(I6)'
matrix list unit

matrix X_bar=X'*unit/6
matrix list X_bar

matrix cross_product=X'*(I6-1/6*unit*unit')*X
matrix list cross_product

matrix covariance=1/5*cross_product
matrix list covariance

log close
=========================================
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值