kimanh358 / HUPH_decision_policy_nutrition

MIT License
0 stars 0 forks source link

How risk damage should be calculated? #2

Open kimanh358 opened 2 weeks ago

kimanh358 commented 2 weeks ago

resistance from the staff

can tro tu nhan vien

bad_belief_staff <- chance_event(resistance_existing_staff_belief) # nhan vien co niem tin k dung bad_practice_staff <- chance_event(resistance_existing_staff_practices) #nhan vien co thuc hanh k dung if (bad_belief_staff == 1 | bad_practice_staff==1) { #neu nhan vien co kien thuc hoac thuc hanh k dung

reduce benefit because of bad staff #thi se giam loi ich

food_safety_practices_staff <- food_safety_practices_staff * 
  (1-max(resistance_existing_staff_belief,resistance_existing_staff_practices))
meal_nutrition_practices_staff <- meal_nutrition_practices_staff * 
  (1-max(resistance_existing_staff_belief,resistance_existing_staff_practices))

} else { # hoac nguoc lai,

keep the benefit because of positive staff

food_safety_practices_staff
meal_nutrition_practices_staff

If 2 risk (dependent: belief and practice) occur at the same time. How risk damage should be calculated?

CWWhitney commented 2 weeks ago

Let's break it down step-by-step and address your question about how to calculate the risk (damage) if both risks occur simultaneously.

bad_belief_staff and bad_practice_staff are determined using the chance_event function. This function takes a probability (e.g., resistance_existing_staff_belief) and returns 1 or 0, equivalent to TRUE or 'FALSE', based on that probability.

bad_belief_staff <- chance_event(resistance_existing_staff_belief) # Probability of bad belief
bad_practice_staff <- chance_event(resistance_existing_staff_practices) # Probability of bad practice

The if statement checks if either bad_belief_staff or bad_practice_staff is TRUE.

if (bad_belief_staff == 1 | bad_practice_staff == 1) {

If either bad_belief_staff or bad_practice_staff is TRUE, the benefits are reduced by a factor determined by the maximum of the two probabilities.

food_safety_practices_staff <- food_safety_practices_staff * (1 - max(resistance_existing_staff_belief, resistance_existing_staff_practices))
meal_nutrition_practices_staff <- meal_nutrition_practices_staff * (1 - max(resistance_existing_staff_belief, resistance_existing_staff_practices))

If neither event occurs, the benefits remain unchanged.

CWWhitney commented 2 weeks ago

If both risks (bad belief and bad practice) are dependent and occur simultaneously, we can account for the combined effect.

If both events happen together, we might want to calculate the damage using a different method, such as an average or another formula that better represents their combined impact.

# Define the probability of each event
resistance_existing_staff_belief <- 0.3 # Example probability
resistance_existing_staff_practices <- 0.4 # Example probability

# Determine if each event occurs
bad_belief_staff <- chance_event(resistance_existing_staff_belief)
bad_practice_staff <- chance_event(resistance_existing_staff_practices)

# Initialize benefits
food_safety_practices_staff <- 100 # Example initial benefit
meal_nutrition_practices_staff <- 100 # Example initial benefit

# Calculate the combined effect if both risks occur
if (bad_belief_staff == 1 & bad_practice_staff == 1) {
  combined_factor <- (resistance_existing_staff_belief + resistance_existing_staff_practices) / 2
  food_safety_practices_staff <- food_safety_practices_staff * (1 - combined_factor)
  meal_nutrition_practices_staff <- meal_nutrition_practices_staff * (1 - combined_factor)
} else if (bad_belief_staff == 1 | bad_practice_staff == 1) {
  food_safety_practices_staff <- food_safety_practices_staff * (1 - max(resistance_existing_staff_belief, resistance_existing_staff_practices))
  meal_nutrition_practices_staff <- meal_nutrition_practices_staff * (1 - max(resistance_existing_staff_belief, resistance_existing_staff_practices))
}

If both risks occur, calculate a combined factor (average in this case) and adjust the benefits accordingly.

CWWhitney commented 1 week ago

Was there more to the question that I missed?