title: Understanding degrees of freedom in lavaan
body: <p><code>lavaan</code> offers the opportunity to constrain parameters across groups. Assume I have two groups in my data. Assume the following model:</p>
  
  <pre><code>library(RCurl)
  library(lavaan)
  x &lt;- getURL("https://gist.githubusercontent.com/aronlindberg/dfa0115f1d80b84ebd48b3ed52f9c5ac/raw/3abf0f280a948d6273a61a75415796cc103f20e7/growth_data.csv")
  growth_data &lt;- read.csv(text = x)
  
  model_regressions &lt;- ' i =~ 1*t1 + 1*t2 + 1*t3 + 1*t4 + 1*t5 + 1*t6 + 1*t7 + 1*t8 + 1*t9 + 1*t10 + 1*t11 + 1*t12 + 1*t13+ 1*t14 + 1*t15 + 1*t16 + 1*t17 + 1*t18 + 1*t19 + 1*t20
  s =~ 0*t1 + 1*t2 + 2*t3 + 3*t4 + 4*t5 + 5*t6 + 6*t7 + 7*t8 + 8*t9 + 9*t10 + 10*t11 + 11*t12 + 12*t13 + 13*t14 + 14*t15 + 15*t16 + 16*t17 + 17*t18 + 18*t19 + 19*t20
  
  # fixing error-variances
  t8 ~~ 0.01*t8
  t17 ~~ 0.01*t17
  t18 ~~ 0.01*t18
  # regressions
  s ~ h_index
  i ~ h_index'
  
  fit_UNconstrained &lt;- growth(model_regressions, data=growth_data, group = "type")
  </code></pre>
  
  <p>Then using the following I can constrain the intercepts across the two groups:</p>
  
  <pre><code>fit_constrained_intercepts &lt;- growth(model_regressions, data=growth_data, group = "type", group.equal = c("intercepts"))
  </code></pre>
  
  <p>However, when I compare this model to an unconstrained model, the difference in degrees of freedom and Chi2 is zero (0). How is this possible?</p>
  
  <p>Further, when I constrain other parameters, such as variance, e.g.:</p>
  
  <pre><code>fit_constrained_variances &lt;- growth(model_regressions, data=growth_data, group = "type", group.equal = c("lv.variances"))
  </code></pre>
  
  <p>...and compare the constrained model to the unconstrained model, the difference in degrees of freedom is 2, not 1 as I would expect from constraining a single parameter:</p>
  
  <pre><code>fitMeasures(fit_UNconstrained, "df")
  fitMeasures(fit_constrained_intercepts, "df")
  fitMeasures(fit_constrained_variances, "df")
  </code></pre>
  
  <p>Hence, my question: how does constraining the various parameters (especially intercepts and variances) affect the degrees of freedom in lavaan?</p>