def calc_correlation(data, refparam, lags=[0, 10], exclude=None):
    """
    Calculates the correlations between parameters and a reference
    parameter given as columns in a DataFrame.

    Parameters
    ----------
    data : pandas.DataFrame
        DataFrame containing data in columns.
    refparam : str
        Reference parameter.
    lags : list of int, optional
        Time periods to shift parameter against refparam,
        defaults to [0, 10].
    exclude : string, optional
        Variable which should not be used for calculation of the correlation.

    Returns
    -------
    correlation : dict
        Dictionary containing correlations and max time lags.
    """

    correlation = {}

    for param in data.keys():
        if exclude is not None and exclude in param:
            continue
        correlation[param] = {'corr': None, 'lag': None}
        for i in range(lags[0], lags[1]):
            i += abs(lags[0]) + 1
            corr = data[param].corr(data[refparam].shift(periods=i),
                                    method='pearson')
            if correlation[param]['corr'] is None:
                correlation[param]['corr'] = abs(corr)
                correlation[param]['lag'] = i
            if abs(corr) > abs(correlation[param]['corr']):
                correlation[param]['corr'] = abs(corr)
                correlation[param]['lag'] = i
            if abs(corr) == abs(correlation[param]['corr']):
                if abs(i) < abs(correlation[param]['lag']):
                    correlation[param]['corr'] = abs(corr)
                    correlation[param]['lag'] = i

    return correlation