我正在Card等医疗保险数据上实现RDDtools包。我已经能够建立一个简单的参数回归。我现在想做的是在ageyrs
中包含线性趋势。我输入ageyrs
作为协变量,但返回错误:
library(rddtools)
load(file ="C:/Users/perdue/Desktop/Adv.MicroEconometrics/HA 9/medicare.Rdata")
rd.medic<-rdd_data(y=er,x=ageyrs, covar=ageyrs, cutpoint=65, data = medicare)
rd.reg <- rdd_reg_lm(rdd_object=rd.medic, covariates = rd.medic$ageyrs, slope =("same"), covar.opt = ("include"))
Error: $ operator is invalid for atomic vectors
4.
match.arg(covar.opt$strategy, choices = c("include", "residual"))
3.
model.matrix.rdd_data(rdd_object, covariates = covariates, order = order, bw = bw, slope = slope, covar.opt = covar.opt)
2.
model.matrix(rdd_object, covariates = covariates, order = order, bw = bw, slope = slope, covar.opt = covar.opt)
1.
rdd_reg_lm(rdd_object = rd.medic, covariates = rd.medic$ageyrs, slope = ("same"), covar.opt = ("include"))
在文档中,它说我应该输入协变量作为公式。有人知道这个公式是什么吗?
问题可能是covar.opt
必须是一个列表。这不会产生任何错误:
rd.reg <- rdd_reg_lm(rdd_object=rd.medic, covariates = 'ageyrs', slope =
("same"), covar.opt = list("include"))