假设您有250个观察值,并且可以根据某些条件定义治疗/控制。
constants = ['(a, b)', '(x, y, z)', 'i']
literals = [eval(k) for k in constants] # get rid of the strings
part1 = [literals[0]] # individually make each of the three parts of your list
part2 = [k for k in range(literals[1][0], literals[1][1] + 1, literals[1][2])] # or if you don't need to include y then you could just do range(literals[1])
part3 = [literals[2]]
transformed = part1 + part2 + part3
现在,您重新定义了250个观测值,就得到了
Treatment 1 - 100 observations
Control 1 - 150 observations
您估计:
Treatment 2 -- 160 observations
Control 3 -- 90 observations
其中data1和data2对应于定义治疗/控制的两种方式。
绘制回归系数:
m1 <- lm(y~x+treat, data=data1)
m2 <- lm(y~x+treat, data=data2)
我希望系数图显示(例如,通过增加点数),第二个模型中的治疗组比第一个模型大。任何线索将不胜感激。