def calc_dof(model):
    """
    Calculate degrees of freedom.

    Parameters
    ----------
    model : Model
        Model.

    Returns
    -------
    int
        DoF.

    """
    p = len(model.vars['observed'])
    return p * (p + 1) // 2 - len(model.param_vals)