I have a sample regression as below.
yit = λi + δt + α1TR + ∑ t ∈ {2,,,T} βtTR*δt
That is, I have time-varying coefficients, βt. With the regression result, I would like to plot coefficients with confidence intervals (X-axis is time and Y-axis is the coefficient values).
Here is the sample data
y = rnorm(1000,1)
weekid = as.factor(sample.int(52,size = 1000,replace = T))
id = as.factor(sample.int(100,size = 1000,replace = T))
tr = as.factor(sample(c(0,1),size = 1000, prob = c(1,2),replace = T))
sample_lm = lm(y ~ weekid + id + tr*weekid)
summary(sample_lm)
How can I plot coefficients for tr*weekid
with the confidence intervals?
set.seed()
so we can get the same values as you to replicate the data. - MrFlick