jackolney / CascadeDashboard

Shiny app for interactive HIV care cascade model https://jackolney.shinyapps.io/CascadeDashboard
https://jackolney.github.io/CascadeDashboard/
0 stars 0 forks source link

Calibration Error Normalisation #4

Closed jackolney closed 7 years ago

jackolney commented 7 years ago

Previously:

value <- ((abs(iData - iModel) / iData) * w) / N

Where N was equal to the total number of data-points for a particular indicator.

However, for a spectrum estimate of numbers on ART for years 2010 to 2015, we have six points, that means that each error here is divided by SIX. Therefore, these green values only carry a SIXTH of the weight.

What N actually needs to account for is the TOTAL number of data-points in a given calibration. So that the simulation error produced does not wildly differ between a calibration with say 100 data-points vs. a calibration with only 10 data-points.

jackolney commented 7 years ago

My interpretation of the equation was incorrect...

# in server/calibration/error.R

# From:

        # Calculate number of values in dataset for particular indicator (N)
        N <- 0
        for (j in 1:length(uniqueYears)) {
            iD <- data[data$year == uniqueYears[j] & data$source == "data","value"]
            if (isEmpty(iD)) {
                next
            } else if (!is.na(iD)) {
                N <- N + 1
            }
        }

# To:

        # Calculate total number of data values in dataset
        N <- dim(df[df$source == "data",])[1]

So the equation in LaTeX changes too:


% from

\begin{equation}
    E = \sum_{ij} \frac{|d_{ij} - m_{ij}|w_{ij}}{d_{ij} N_i}
    \label{Eq:Error}
\end{equation}

% to

\begin{equation}
    E = \sum_{ij} \frac{|d_{ij} - m_{ij}|w_{ij}}{d_{ij} N}
    \label{Eq:Error}
\end{equation}

The change is that N_i becomes N. As we don't want to penalise individual indicators however we want to penalise the WHOLE dataset for a particular calibration.