# Use regression as coefficient in another regression

I am interested in conducting a time series regression, such that:

$$RV_{t+1} = \alpha + (\beta_0 + \beta_1 RET + \beta_2 RV_t)RV_t + \beta_3 RW + \beta_4 RM$$.

Is such a regression possible in Python or R? I have seen it in a few papers, and it is apparently estimated through simple OLS, so I feel like I am missing something.

Two papers where this is seen: Conditional Volatility Persistence - Wang and Yang (2018); Exploiting the errors: A simple approach for improved volatility forecasting - Bollerslev, Patton and Quaedvlieg (2015).

This just looks like a way to write interaction terms and polynomials (and is also not specifically related to time series regression). Multiplying out the brackets gives $$RV_{t+1} = \alpha + \beta_0RV_t + \beta_1 RET\cdot RV_t + \beta_2 RV_t^2 + \beta_3 RW + \beta_4 RM$$

Try something like

n <- 10
x1 <- rnorm(n)
x2 <- rnorm(n)
y <- rnorm(n)

lm(y~x1*x2+I(x1^2))


Output:

> lm(y~x1*x2+I(x1^2))

Call:
lm(formula = y ~ x1 * x2 + I(x1^2))

Coefficients:
(Intercept)           x1           x2      I(x1^2)        x1:x2
0.08859      0.93306     -0.03421     -0.66431     -0.18097