经典的面板数据集(R语言包plm)

(注意:本博客关于数据的描述全部来自于R语言内置帮助文件,仅供自己学习使用)

1 Cigarette Consumption

data(Cigar)

Description

a panel of 46 observations from 1963 to 1992

Format

A data frame containing :

state
state abbreviation

year
the year

price
price per pack of cigarettes

pop
population

pop16
population above the age of 16岁以上人口总数

cpi
consumer price index (1983=100) 消费者价格指数

ndi
per capita disposable income 人均可支配收入

sales
cigarette sales in packs per capita 人均卷烟销售量(包)

pimin
minimum price in adjoining states per pack of cigarettes 相邻州每包香烟的最低价格

Details

total number of observations : 1380

observation : regional

country : United States

Source

Online complements to Baltagi (2001):

https://www.wiley.com/legacy/wileychi/baltagi/

Online complements to Baltagi (2013):

https://bcs.wiley.com/he-bcs/Books?action=resource&bcsId=4338&itemId=1118672321&resourceId=13452

References

Baltagi BH (2001). Econometric Analysis of Panel Data, 3rd edition. John Wiley and Sons ltd.

Baltagi BH (2013). Econometric Analysis of Panel Data, 5th edition. John Wiley and Sons ltd.

Baltagi B, Levin D (1992). “Cigarette taxation: Raising revenues and reducing consumption.” Structural Change and Economic Dynamics, 3(2), 321-335. https://EconPapers.repec.org/RePEc:eee:streco✌️3:y:1992:i:2:p:321-335.

Baltagi BH, Griffin JM, Xiong W (2000). “To Pool or Not to Pool: Homogeneous Versus Heterogeneous Estimators Applied to Cigarette Demand.” The Review of Economics and Statistics, 82(1), 117-126. doi: 10.1162/003465300558551, https://doi.org/10.1162/003465300558551.

2 Crime in North Carolina

data(Crime)

Description
a panel of 90 observational units (counties) from 1981 to 1987

Format

A data frame containing :

county
county identifier

year
year from 1981 to 1987

crmrte
crimes committed per person

prbarr
‘probability’ of arrest

prbconv
‘probability’ of conviction

prbpris
‘probability’ of prison sentence

avgsen
average sentence, days

polpc
police per capita

density
people per square mile

taxpc
tax revenue per capita

region
factor. One of ‘other’, ‘west’ or ‘central’.

smsa
factor. (Also called “urban”.) Does the individual reside in a SMSA (standard metropolitan statistical area)?

pctmin
percentage minority in 1980

wcon
weekly wage in construction

wtuc
weekly wage in transportation, utilities, communications

wtrd
weekly wage in wholesale and retail trade

wfir
weekly wage in finance, insurance and real estate

wser
weekly wage in service industry

wmfg
weekly wage in manufacturing

wfed
weekly wage in federal government

wsta
weekly wage in state government

wloc
weekly wage in local government

mix
offence mix: face-to-face/other

pctymle
percentage of young males (between ages 15 to 24)

lcrmrte
log of crimes committed per person

lprbarr
log of ‘probability’ of arrest

lprbconv
log of ‘probability’ of conviction

lprbpris
log of ‘probability’ of prison sentence

lavgsen
log of average sentence, days

lpolpc
log of police per capita

ldensity
log of people per square mile

ltaxpc
log of tax revenue per capita

lpctmin
log of percentage minority in 1980

lwcon
log of weekly wage in construction

lwtuc
log of weekly wage in transportation, utilities, communications

lwtrd
log of weekly wage in wholesale and retail trade

lwfir
log of weekly wage in finance, insurance and real estate

lwser
log of weekly wage in service industry

lwmfg
log of weekly wage in manufacturing

lwfed
log of weekly wage in federal government

lwsta
log of weekly wage in state government

lwloc
log of weekly wage in local government

lmix
log of offence mix: face-to-face/other

lpctymle
log of percentage of young males (between

### 如何用R语言实现空间面板数据模型 在处理空间面板数据时,可以利用`spdep`、`plm`以及`splm`等软件包来构建和估计空间面板数据模型。下面提供了一个具体的实例说明如何操作。 #### 安装必要的库 为了执行空间面板回归分析,首先需要安装几个重要的R包: ```r install.packages("splm") # 提供了用于拟合空间计量经济学模型的功能 install.packages("spdep") # 支持创建空间权重矩阵和其他空间统计方法 install.packages("foreign") # 有助于加载不同类型的外部数据集 ``` #### 加载所需库并准备数据 接着,在实际应用之前先加载上述提到的各个库,并准备好待使用的样本数据。 ```r library(splm) library(spdep) data(Produc, package="plm") # 导入示例数据集 Produc (来自 plm),它包含了美国各州生产率的相关信息 data(usaww) # 获取预定义的空间邻接关系 usaww (同样来自于 splm), 表达的是地理上的相邻状态间的关系. ``` #### 构建空间权重矩阵W 对于空间效应的研究来说,建立合适的空间权重矩阵是非常关键的一环。这里采用二元邻接标准作为衡量准则之一;即如果两个地区彼此接壤,则赋予它们之间一定的关联强度值(通常是1),反之则设为0。 ```r nb2listw(usaww, style="W", zero.policy=TRUE)-> lw # 将邻居列表转换成标准化后的空间权重对象lw summary(lw) # 查看所得到的空间权重表概览 ``` #### 进行空间自相关检验Moran's I Test 通过莫兰指数测试可以帮助判断是否存在显著性的全局空间依赖现象存在于因变量之中。 ```r lmSLX <- lm(log(gsp) ~ log(pcap)+log(pc)+log(emp)+unemp , data = Produc) morantest(lmSLX,lw)$I.statistic # 计算 Moran’s I 统计量以评估残差间的空间聚集程度 ``` #### 建立SAR模型(Spatial Autoregressive Model) 当确认存在正向的空间溢出影响之后,就可以尝试着去构建一个具有解释力较强且能捕捉到这种特性的SAR型态下的固定效应回归方程式了。 ```r sarfe.produc <- spml(formula=log(gsp)~log(pcap)+log(pc)+log(emp)+ unemp,data=Produc,index=c("state","year"), listw=lw,model="within",effect="individual", lag=F, spatial.error="b") summary(sarfe.produc) # 输出 SARFE 模型的结果汇总报告 ``` 以上就是使用R语言来进行简单形式下带有个体固定效果项的空间滞后误差修正模型的一个基本流程展示[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大浪淘沙_scc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值