Estimating State Space Model in R with MARSS package and shared parameters between Q and R I am trying to estimate the following unobserved components model using the MARSS package 
$y_t = \mu_t + \varepsilon_t $
$\mu_t = \mu_{t-1} + \beta_{t-1}$
$\beta_t = \beta_{t-1} + \zeta_{t}$
with a restriction on the variance of the errors: $\sigma^2_{\zeta} = \frac{1}{\lambda}\sigma^2_{\varepsilon}$ for a given $\lambda$. $y_t$ are the observed series and $\mu_t$ and $\beta_t$ are the states. Those of you familiar with these models will recognize this as the Hodrick-Prescott filter.
MARSS handles models in this form
$y_t = Z x_t + v_t , v_t \sim MVN(A,R) $
$x_t = B x_{t-1} + w_t, w_t \sim MVN(U,Q) $
$x_0 \sim MVN(x0,V0)$
So I tried this
lambda=1600
B1 = matrix(c(1,0,1,1),2,2)
U1 = matrix(0,2,1)
Q1= matrix(list(),2,2)
Q1[1,1]=0
Q1[1,2]=0
Q1[2,1]=0
Q1[2,2]="q11*1/lambda"
Z1 = matrix(c(1,0),1,2)
A1 = as.matrix(0)
R1 = as.matrix("q11")
pi1 = matrix(0,2,1)
V1 = diag(1,2)
model.list = list(B = B1, U = U1, Q = Q1, Z = Z1, A = A1, R = R1, x0 = pi1, V0 = V1)
fit = MARSS(data, model = model.list, control = list(kf.x0 = "x00"))

But the specification for Q[2,2] is wrong and MARSS reads it as a new parameter to estimate. I know I can restrict parameters to be the same within the Q matrix and R matrix, but I don't know how to impose the variance restriction that affects parameters of both matrices. Does anyone know a way around this? Maybe using substitute() ?
I know there are packages to implement the HP filter as well as other state space estimation packages but I want to use MARSS since it uses the EM algorithm to estimate the parameters and I want to extend this model to others where convergence is harder to achieve.
Thank you.
 A: You cannot share parameters between Q and R, as you have specified in the model. 
See http://journal.r-project.org/archive/2012-1/RJournal_2012-1_Holmes~et~al.pdf pg 13 "Elements with the same character name are constrained to be equal (no sharing across parameter matrices, only within)."
I don't know if this helps much, since you already discovered it didn't work for you, but at least you know there is no official support for this type of parameter sharing.  I don't know the solution, or if there is a solution, but you might try asking the authors of the package. I have found them to be very gracious with their time and expertise. 
A: I think that there is a way around this. Write a function with MARSS inside it where sigma_epsilon is given (and not estimated), which in turn determines sigma_nu using the restriction. (To get an initial value for this run with no restrictions on the variance terms to start with; alternatively use the filter package, which does HP filtering). You can then optimise across sigma_epsilon values to minimise the AIC. This can be done by using a grid search approach or one of the optimisation packages.
To get out confidenced intervals you can write a simple function to jack-knife the confidence intervals.
