Вы можете просто включить его в качестве пояснительной переменной
library(data.table)
d <- data.table(id = 1)
d <- d[, .(year=1:200), by=id]
d[, x1 := runif(200)]
# add an erros
d[, e := rnorm(200, 23, 7)]
# add the dependent variable
d[, y := 3.5*x1 + 0.5*year + e ]
m <- lm(y ~ x1 + year, d)
summary(m)
Call:
lm(formula = y ~ x1 + year, data = d)
Residuals:
Min 1Q Median 3Q Max
-19.2008 -4.4356 0.3986 5.2283 16.6819
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 20.064776 1.519766 13.203 <2e-16 ***
x1 3.114048 1.914318 1.627 0.105
year 0.523195 0.009187 56.947 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 7.469 on 197 degrees of freedom
Multiple R-squared: 0.943, Adjusted R-squared: 0.9424
F-statistic: 1628 on 2 and 197 DF, p-value: < 2.2e-16