我们说我有这样的数据集:
library(dplyr)
library(MatchIt)
set.seed(1)
df <- data_frame(outcome = sample(c(rep("TRUE", 50), rep("FALSE", 50))),
age = rnorm(100, mean = 35, sd = 15),
gender = sample(c(rep("MALE", 50), rep("FEMALE", 50))),
var1 = rnorm(100, mean = 1, sd = 0.3),
var2 = rnorm(100, mean = 1000, sd = 125),
var3 = rnorm(100, mean = 0, sd = 300))
我想控制年龄和性别,并确定第1,第2和第3代对结果的影响。我相信我可以使用MatchIt功能来控制年龄和性别:
match_it <- matchit(formula = outcome ~ age + gender,
data = df,
method = "nearest")
但是一旦完成,我怎样才能确定var1对结果的影响?谢谢你的帮助。