有没有人理解为什么我的R会话出现致命错误:尝试运行此面板线性模型时R会话中止:
date1 <- c("01.01.2000","02.01.2000","03.01.2000","06.01.2000","07.01.2000","09.01.2000","01.01.2000","02.01.2000","03.01.2000","06.01.2000","07.01.2000","09.01.2000")
ret1 <- c(-2.0,1.1,3,1.4,-0.2, 0.6, 0.1, -0.21, -1.2, 0.9, 0.3, -0.1)
company1 <- c("1","1","1","1","1","1","2","2","2","2","2","2")
df <- data.frame(date1, ret1, company1, stringsAsFactors=F)
df$DATE <- df$date1
df$date1 <- NULL
df$RET <- df$ret1
df$ret1 <- NULL
df$PERMNO <- df$company1
df$company1 <- NULL
date2 <- c("02.01.2000","03.01.2000","06.01.2000","09.01.2000","03.01.2000","07.01.2000","09.01.2000")
news2 <- c("blabla11", "blabla12","blabla13","blabla14","blabla21","blabla22","blabla23")
company2 <- c("1","1","1","1","2","2","2")
klasse <- c("-1", "1", "0", "1", "0", "1", "0")
event <- data.frame(date2, news2, company2, klasse, stringsAsFactors=F)
event$DATE <- event$date2
event$date2 <- NULL
event$ARTICLE <- event$news2
event$news2 <- NULL
event$PERMNO <- event$company2
event$company2 <- NULL
mypanel <- merge(event, df, by.x=c("DATE", "PERMNO"), by.y=c("DATE", "PERMNO"))
mypanel
# DATE PERMNO klasse ARTICLE RET
# 1 02.01.2000 1 -1 blabla11 1.1
# 2 03.01.2000 1 1 blabla12 3.0
# 3 03.01.2000 2 0 blabla21 -1.2
# 4 06.01.2000 1 0 blabla13 1.4
# 5 07.01.2000 2 1 blabla22 0.3
# 6 09.01.2000 1 1 blabla14 0.6
# 7 09.01.2000 2 0 blabla23 -0.1
当我尝试运行时:
mymodel <- plm(RET ~ klasse, data=mypanel,
index=c("DATE", "PERMNO"),
model="within",
effect="time")
我收到致命错误:R会话中止!
运行此代码时是否还有其他人遇到此错误?
答案 0 :(得分:1)
我运行了你的代码,这就是我得到的:
模型公式:RET~klasse
系数:klasse0 klasse1 0.11667 0.79167
您使用的是哪个版本的R?我正在使用R 3.0.3。