如何在Stata/Python/R中简单快速读地取伍德里奇《计量经济学导论》中的数据集? |
您所在的位置:网站首页 › 计量经济学stata命令汇总 › 如何在Stata/Python/R中简单快速读地取伍德里奇《计量经济学导论》中的数据集? |
首先,伍德里奇的《计量经济学导论》,是目前国内外最流行的计量经济学教材(没有之一),非常适合新手入门学习。 目前该书在国内出到了第六版,其中文版为: 英文版: 配套习题答案: 在美国,此书出版到了第七版: 该书通常会随身携带有配到的数据集,格式为Stata/Excel/CSV/SPSS等。但是因为需要下载到本地,所以用起来不是很方便。 好在,由于此书被使用地如此广泛,以至于有人专门开发了引用的包或命令,方便大家随时调取各个数据集: Stata:安装bcuse命令后,可以直接调取数据集;Python:安装wooldridge包后,可以直接调取某个数据集;R:和Python一样,也叫wooldridge包。一、Stata:bcuse 命令介绍bcuse中的bc,是Boston College的意思。此命令是由Boston College开发,用于计量经济学课程的日常教学。 (1)安装bcuse命令。 ssc install bcuse使用说明: help bcuse说明网址: Wooldridge datasets 举例应用: . bcuse apple.dta, clear //导入apple数据集 Contains data from http://fmwww.bc.edu/ec-p/data/wooldridge/apple.dta obs: 660 vars: 17 20 Jan 2000 15:35 ------------------------------------------------------------------------------------ storage display value variable name type format label variable label ------------------------------------------------------------------------------------ id int %8.0g respondent identifier educ byte %8.0g years schooling date str6 %9s date: month/day/year state str2 %9s home state regprc float %9.0g price of regular apples ecoprc float %9.0g price of ecolabeled apples inseason byte %9.0g =1 if interviewed in Nov. hhsize byte %9.0g household size male byte %9.0g =1 if male faminc int %9.0g family income, thousands age byte %9.0g in years reglbs float %9.0g quantity regular apples, pounds ecolbs float %9.0g quantity ecolabeled apples, lbs numlt5 byte %9.0g # in household younger than 5 num5_17 byte %9.0g # in household 5 to 17 num18_64 byte %9.0g # in household 18 to 64 numgt64 byte %9.0g # in household older than 64 ------------------------------------------------------------------------------------ Sorted by: 二、Python:wooldridge 包使用介绍首先,安装woodridge包: pip3 install wooldridge导入包: import wooldridge导入数据: df_apple = wooldridge.data('apple')在Spyder中查看数据: 三、R语言 wooldridge 包使用介绍首先,安装 wooldridge包: > install.packages('wooldridge') WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding: https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/Biaoyue/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/wooldridge_1.4-1.zip' Content type 'application/zip' length 4291440 bytes (4.1 MB) downloaded 4.1 MB package ‘wooldridge’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\Bryce\AppData\Local\Temp\RtmpuAK6Oy\downloaded_packages然后,导入该包: > library(wooldridge) Warning message: package ‘wooldridge’ was built under R version 4.0.5导入数据: df_apple |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |