I want to code up a non-linear model and perform a first-order log-linearization.

I understand that I need to invoke exp() on the variables I would like to log-linearize. There are also some variables (R and pi) that are already in percentages that I would like to only linearize, in which case I do not need to transform them with exp(). For example, for an Euler equation I have used:

```
exp(M) = betta*exp(M(+1))*(1+R)/(1+pi(+1));
```

where M is marginal consumption and I have left R and pi without the exp transformation.

The difficulty is that i would also like to include an already log-linearized equation for the Taylor Rule. My understanding is that this is fine as long as I correctly specify the relationship between the hatted variables and the raw variables.

For the Taylor Rule I have used:

```
R_hat = mp_rlag*R_hat(-1)+(1-mp_rlag)*(mp_infl*pi_hat+mp_u*ubar*u_hat+m_hat;
pi_hat = pi - pibar;
R_hat = R - Rbar;
u_hat = log(u) - log(ubar);
```

My question is have I correctly defined the hat variables correctly for the linear variables, pi_hat and R_hat?