Estimating Dependency Structure as a Hidden Variable