---
title: "Complete_Parameter_Reference_Guide"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Complete_Parameter_Reference_Guide}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---


```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = FALSE
)

library(cowfootR)
library(knitr)
```

# Complete Parameter Reference Guide

This vignette provides a comprehensive reference for all parameters across cowfootR functions, including units, valid options, typical ranges, and data sources. Use this as a technical reference when setting up calculations or troubleshooting data issues.

## Function Overview

cowfootR includes these main calculation functions:
- `calc_emissions_enteric()` - Enteric fermentation methane
- `calc_emissions_manure()` - Manure management CH4 and N2O  
- `calc_emissions_soil()` - Soil N2O emissions
- `calc_emissions_energy()` - Energy-related CO2 emissions
- `calc_emissions_inputs()` - Purchased input emissions
- `calc_total_emissions()` - Aggregation function
- `calc_intensity_litre()` - Milk intensity calculations
- `calc_intensity_area()` - Area intensity calculations
- `calc_batch()` - Batch processing function

---

## 1. calc_emissions_enteric() Parameters

### Required Parameters

| Parameter | Type | Unit | Description | Valid Range | Example |
|-----------|------|------|-------------|-------------|---------|
| `n_animals` | Numeric | head | Number of animals | > 0 | 100 |

### Animal Characteristics

| Parameter | Type | Unit | Description | Valid Range | Default | Example |
|-----------|------|------|-------------|-------------|---------|---------|
| `cattle_category` | Character | - | Type of cattle | "dairy_cows", "heifers", "calves", "bulls" | "dairy_cows" | "dairy_cows" |
| `avg_body_weight` | Numeric | kg | Average live weight | 100-800 | 550 (cows) | 580 |
| `avg_milk_yield` | Numeric | kg/year | Annual milk yield per cow | 1000-15000 | 6000 | 7200 |

### Production System

| Parameter | Type | Unit | Description | Valid Options | Default | Notes |
|-----------|------|------|-------------|---------------|---------|-------|
| `production_system` | Character | - | System intensity | "intensive", "extensive", "mixed" | "mixed" | Affects Tier 1 factors |
| `dry_matter_intake` | Numeric | kg/day | Daily DM intake per animal | 8-25 (cows) | NULL | Required for accurate Tier 2 |

### Feed Parameters

| Parameter | Type | Unit | Description | Valid Range | Default | Notes |
|-----------|------|------|-------------|-------------|---------|-------|
| `feed_inputs` | Named list | kg DM/year | Annual feed consumption | > 0 | NULL | Names: grain_dry, grain_wet, ration, byproducts, proteins |
| `ym_percent` | Numeric | % | Methane conversion factor | 4.0-8.0 | 6.5 | Higher = more CH4 per unit energy |

### Methodology Control

| Parameter | Type | Unit | Description | Valid Options | Default | Impact |
|-----------|------|------|-------------|---------------|---------|--------|
| `tier` | Numeric | - | IPCC methodology tier | 1, 2 | 1 | Tier 2 more accurate with detailed data |
| `emission_factor_ch4` | Numeric | kg CH4/head/year | Custom CH4 factor | 40-150 | NULL | Overrides tier calculations |
| `gwp_ch4` | Numeric | kg CO2eq/kg CH4 | Global Warming Potential | 25-30 | 27.2 | IPCC AR6 value |

---

## 2. calc_emissions_manure() Parameters

### Required Parameters

| Parameter | Type | Unit | Description | Valid Range | Default | Example |
|-----------|------|------|-------------|-------------|---------|---------|
| `n_cows` | Numeric | head | Total number of animals | > 0 | - | 150 |

### Manure System

| Parameter | Type | Unit | Description | Valid Options | Default | CH4 Impact |
|-----------|------|------|-------------|---------------|---------|------------|
| `manure_system` | Character | - | Management system type | "pasture", "solid_storage", "liquid_storage", "anaerobic_digester" | "pasture" | High variation |
| `climate` | Character | - | Climate region | "cold", "temperate", "warm" | "temperate" | Affects MCF |

### Tier 2 Specific

| Parameter | Type | Unit | Description | Valid Range | Default | Required For |
|-----------|------|------|-------------|-------------|---------|--------------|
| `avg_body_weight` | Numeric | kg | Average live weight | 400-700 | 600 | Tier 2 VS calculation |
| `diet_digestibility` | Numeric | fraction | Diet apparent digestibility | 0.5-0.8 | 0.65 | Tier 2 VS calculation |
| `retention_days` | Numeric | days | Days manure in system | 10-200 | NULL | System optimization |
| `system_temperature` | Numeric | °C | Average system temperature | 5-40 | NULL | MCF adjustment |

### Nitrogen Management

| Parameter | Type | Unit | Description | Valid Range | Default | Impact |
|-----------|------|------|-------------|-------------|---------|--------|
| `n_excreted` | Numeric | kg N/cow/year | N excretion per cow | 80-150 | 100 | N2O emissions |
| `ef_n2o_direct` | Numeric | kg N2O-N/kg N | Direct N2O emission factor | 0.005-0.03 | 0.02 | IPCC 2019 |
| `include_indirect` | Logical | - | Include indirect N2O? | TRUE/FALSE | FALSE | +20-30% N2O |
| `protein_intake_kg` | Numeric | kg/day | Daily protein intake | 1.5-4.0 | NULL | Refines N excretion |

---

## 3. calc_emissions_soil() Parameters

### Nitrogen Inputs

| Parameter | Type | Unit | Description | Valid Range | Typical Values | Source |
|-----------|------|------|-------------|-------------|---------------|--------|
| `n_fertilizer_synthetic` | Numeric | kg N/year | Synthetic fertilizer N | 0-5000 | 50-300 kg N/ha | Purchase records |
| `n_fertilizer_organic` | Numeric | kg N/year | Organic fertilizer N | 0-3000 | 0-100 kg N/ha | Application records |
| `n_excreta_pasture` | Numeric | kg N/year | N deposited while grazing | 0-20000 | 80-120 kg N/cow/year | Calculated estimate |
| `n_crop_residues` | Numeric | kg N/year | N in returned crop residues | 0-2000 | 10-50 kg N/ha | Crop management |

### Site Conditions

| Parameter | Type | Unit | Description | Valid Options | Default | N2O Impact |
|-----------|------|------|-------------|---------------|---------|------------|
| `soil_type` | Character | - | Soil drainage | "well_drained", "poorly_drained" | "well_drained" | 50% difference |
| `climate` | Character | - | Climate classification | "temperate", "tropical" | "temperate" | 20% difference |
| `area_ha` | Numeric | hectares | Total farm area | > 0 | NULL | For per-hectare metrics |

### Emission Factors

| Parameter | Type | Unit | Description | Valid Range | Default | Source |
|-----------|------|------|-------------|-------------|---------|--------|
| `ef_direct` | Numeric | kg N2O-N/kg N | Direct emission factor | 0.005-0.025 | NULL | IPCC 2019 by soil/climate |
| `include_indirect` | Logical | - | Include volatilization/leaching | TRUE/FALSE | TRUE | +30-50% total N2O |
| `gwp_n2o` | Numeric | kg CO2eq/kg N2O | N2O warming potential | 265-300 | 273 | IPCC AR6 |

---

## 4. calc_emissions_energy() Parameters

### Fuel Consumption

| Parameter | Type | Unit | Description | Typical Range | Default | EF (kg CO2/unit) |
|-----------|------|------|-------------|---------------|---------|------------------|
| `diesel_l` | Numeric | litres/year | Diesel consumption | 2000-15000 | 0 | 2.67 |
| `petrol_l` | Numeric | litres/year | Petrol/gasoline consumption | 500-3000 | 0 | 2.31 |
| `lpg_kg` | Numeric | kg/year | LPG consumption | 100-1000 | 0 | 3.0 |
| `natural_gas_m3` | Numeric | m³/year | Natural gas consumption | 0-5000 | 0 | 2.0 |
| `electricity_kwh` | Numeric | kWh/year | Electricity consumption | 10000-100000 | 0 | Variable by country |

### Location and Factors

| Parameter | Type | Unit | Description | Valid Options | Default | Notes |
|-----------|------|------|-------------|---------------|---------|-------|
| `country` | Character | - | Country for grid factors | "UY", "AR", "BR", "NZ", "US", "AU", "DE", etc. | "UY" | Major impact on electricity EF |
| `ef_electricity` | Numeric | kg CO2/kWh | Custom electricity factor | 0.05-1.0 | NULL | Overrides country default |
| `include_upstream` | Logical | - | Include fuel production | TRUE/FALSE | FALSE | +10-15% total |

### Grid Emission Factors (Built-in)

| Country | Code | EF (kg CO2/kWh) | Source |
|---------|------|----------------|--------|
| Uruguay | UY | 0.08 | Clean grid (hydro) |
| Argentina | AR | 0.35 | Mixed grid |
| Brazil | BR | 0.12 | Hydro + renewables |
| New Zealand | NZ | 0.15 | Renewable majority |
| United States | US | 0.45 | Fossil majority |
| Australia | AU | 0.75 | Coal dominant |

---

## 5. calc_emissions_inputs() Parameters

### Feed Inputs

| Parameter | Type | Unit | Description | Typical Range | Default | EF Range (kg CO2eq/kg) |
|-----------|------|------|-------------|---------------|---------|------------------------|
| `conc_kg` | Numeric | kg/year | Concentrate feed | 50000-500000 | 0 | 0.5-1.2 |
| `feed_grain_dry_kg` | Numeric | kg DM/year | Dry grain feeds | 20000-200000 | 0 | 0.3-0.6 |
| `feed_grain_wet_kg` | Numeric | kg DM/year | Wet grain/silage | 10000-100000 | 0 | 0.25-0.45 |
| `feed_ration_kg` | Numeric | kg DM/year | Complete rations | 30000-300000 | 0 | 0.4-0.8 |
| `feed_byproducts_kg` | Numeric | kg DM/year | Feed byproducts | 5000-80000 | 0 | 0.1-0.25 |
| `feed_proteins_kg` | Numeric | kg DM/year | Protein supplements | 5000-50000 | 0 | 1.2-2.8 |
| `feed_corn_kg` | Numeric | kg DM/year | Corn grain specific | 10000-150000 | 0 | 0.35-0.65 |
| `feed_soy_kg` | Numeric | kg DM/year | Soybean meal | 5000-40000 | 0 | 1.5-3.2 |
| `feed_wheat_kg` | Numeric | kg DM/year | Wheat grain | 5000-100000 | 0 | 0.4-0.7 |

### Other Inputs

| Parameter | Type | Unit | Description | Typical Range | Default | EF (kg CO2eq/kg) |
|-----------|------|------|-------------|---------------|---------|------------------|
| `fert_n_kg` | Numeric | kg N/year | Nitrogen fertilizer | 500-5000 | 0 | 5.5-8.5 |
| `plastic_kg` | Numeric | kg/year | Agricultural plastics | 100-1000 | 0 | 1.8-3.8 |
| `transport_km` | Numeric | km | Average transport distance | 50-500 | NULL | 1e-4 kg CO2/kg·km |

### Regional Factors

| Parameter | Type | Unit | Description | Valid Options | Default | Impact |
|-----------|------|------|-------------|---------------|---------|--------|
| `region` | Character | - | Regional emission factors | "global", "EU", "US", "Brazil", "Argentina", "Australia" | "global" | ±20% variation |
| `fert_type` | Character | - | Fertilizer type | "urea", "ammonium_nitrate", "mixed", "organic" | "mixed" | ±15% variation |
| `plastic_type` | Character | - | Plastic type | "LDPE", "HDPE", "PP", "mixed" | "mixed" | ±20% variation |

### Advanced Options

| Parameter | Type | Unit | Description | Valid Range | Default | Purpose |
|-----------|------|------|-------------|-------------|---------|---------|
| `include_uncertainty` | Logical | - | Run Monte Carlo analysis | TRUE/FALSE | FALSE | Uncertainty quantification |
| `ef_conc` | Numeric | kg CO2eq/kg | Override concentrate EF | 0.3-1.5 | NULL | Custom factors |
| `ef_fert` | Numeric | kg CO2eq/kg N | Override fertilizer EF | 3.0-10.0 | NULL | Local studies |
| `ef_plastic` | Numeric | kg CO2eq/kg | Override plastic EF | 1.0-5.0 | NULL | Specific materials |

---

## 6. calc_intensity_litre() Parameters

### Required Parameters

| Parameter | Type | Unit | Description | Valid Range | Notes |
|-----------|------|------|-------------|-------------|-------|
| `total_emissions` | Numeric or cf_total | kg CO2eq/year | Total farm emissions | > 0 | From calc_total_emissions() |
| `milk_litres` | Numeric | litres/year | Annual milk production | > 0 | Farm records |

### Milk Composition

| Parameter | Type | Unit | Description | Valid Range | Default | Source |
|-----------|------|------|-------------|-------------|---------|--------|
| `fat` | Numeric | % | Average fat content | 2.5-6.0 | 4.0 | Lab analysis or processor |
| `protein` | Numeric | % | Average protein content | 2.5-4.5 | 3.3 | Lab analysis or processor |
| `milk_density` | Numeric | kg/L | Milk density | 1.025-1.035 | 1.03 | Lab measurement |

### FPCM Calculation Formula

The Fat and Protein Corrected Milk (FPCM) formula used is:
```
FPCM (kg) = milk_kg × (0.1226 × fat% + 0.0776 × protein% + 0.2534)
```

This standardizes milk to 4.0% fat and 3.3% protein for fair comparison.

---

## 7. calc_intensity_area() Parameters

### Required Parameters

| Parameter | Type | Unit | Description | Valid Range | Notes |
|-----------|------|------|-------------|-------------|-------|
| `total_emissions` | Numeric or cf_total | kg CO2eq/year | Total farm emissions | > 0 | From calc_total_emissions() |
| `area_total_ha` | Numeric | hectares | Total farm area | > 0 | Property records |

### Area Breakdown

| Parameter | Type | Unit | Description | Valid Range | Default | Notes |
|-----------|------|------|-------------|-------------|---------|-------|
| `area_productive_ha` | Numeric | hectares | Productive/utilized area | ≤ total area | total area | Agricultural use only |
| `area_breakdown` | Named list | hectares | Detailed land use | > 0 each | NULL | Must sum to total if validate=TRUE |

### Valid area_breakdown Names

```{r echo=FALSE}
area_breakdown_options <- data.frame(
  Name = c("pasture_permanent", "pasture_temporary", "crops_feed", "crops_cash", 
           "infrastructure", "woodland", "wetlands", "other"),
  Description = c("Permanent grassland", "Rotational/temporary pasture", "Feed crop production",
                  "Cash crop production", "Buildings, roads, facilities", "Forest/trees",
                  "Water bodies, wetlands", "Other non-productive areas"),
  Typical_Range = c("40-80%", "5-20%", "5-15%", "0-10%", "2-5%", "0-10%", "0-5%", "0-5%")
)

kable(area_breakdown_options, caption = "Valid area_breakdown Names and Descriptions")
```

### Validation

| Parameter | Type | Unit | Description | Valid Options | Default | Purpose |
|-----------|------|------|-------------|---------------|---------|---------|
| `validate_area_sum` | Logical | - | Check area breakdown sums | TRUE/FALSE | TRUE | Data quality control |

---

## 8. calc_batch() Parameters

### Data Input

| Parameter | Type | Unit | Description | Requirements | Example |
|-----------|------|------|-------------|--------------|---------|
| `data` | data.frame | - | Farm data with template columns | See template structure | farm_data |

### Template Column Requirements

```{r echo=FALSE}
template_structure <- data.frame(
  Column_Group = c(
    rep("Identification", 2),
    rep("Production", 4),
    rep("Herd_Composition", 5),
    rep("Animal_Weights", 4),
    rep("Feed_Management", 5),
    rep("Land_Use", 8),
    rep("Inputs", 3),
    rep("Energy", 6),
    rep("Management", 1)
  ),
  Column_Name = c(
    "FarmID", "Year",
    "Milk_litres", "Fat_percent", "Protein_percent", "Milk_density", 
    "Cows_milking", "Cows_dry", "Heifers_total", "Calves_total", "Bulls_total",
    "Body_weight_cows_kg", "Body_weight_heifers_kg", "Body_weight_calves_kg", "Body_weight_bulls_kg",
    "MS_intake_cows_kg_day", "MS_intake_heifers_kg_day", "MS_intake_calves_kg_day", 
    "MS_intake_bulls_kg_day", "Ym_percent",
    "Area_total_ha", "Area_productive_ha", "Pasture_permanent_ha", "Pasture_temporary_ha",
    "Crops_feed_ha", "Crops_cash_ha", "Infrastructure_ha", "Woodland_ha",
    "N_fertilizer_kg", "Concentrate_feed_kg", "Plastic_kg",
    "Diesel_litres", "Petrol_litres", "Electricity_kWh", "LPG_kg", "Natural_gas_m3", "Country",
    "Manure_system"
  ),
  Data_Type = c(
    "character", "character",
    "numeric", "numeric", "numeric", "numeric",
    "numeric", "numeric", "numeric", "numeric", "numeric", 
    "numeric", "numeric", "numeric", "numeric",
    "numeric", "numeric", "numeric", "numeric", "numeric",
    "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric",
    "numeric", "numeric", "numeric",
    "numeric", "numeric", "numeric", "numeric", "numeric", "character",
    "character"
  ),
  Required = c(
    "Yes", "No",
    "Yes", "No", "No", "No",
    "Yes", "No", "No", "No", "No",
    "No", "No", "No", "No",
    "Tier 2", "Tier 2", "Tier 2", "Tier 2", "Tier 2",
    "Yes", "No", "No", "No", "No", "No", "No", "No",
    "No", "No", "No",
    "No", "No", "No", "No", "No", "No",
    "No"
  )
)

kable(head(template_structure, 15), caption = "Template Structure (First 15 columns)")
```

### Processing Options

| Parameter | Type | Unit | Description | Valid Options | Default | Impact |
|-----------|------|------|-------------|---------------|---------|--------|
| `tier` | Numeric | - | IPCC methodology tier | 1, 2 | 2 | Accuracy vs data requirements |
| `boundaries` | boundaries object | - | System boundaries | From set_system_boundaries() | "farm_gate" | Scope of assessment |
| `benchmark_region` | Character | - | Regional comparison | "uruguay", "argentina", etc. | NULL | Performance context |
| `save_detailed_objects` | Logical | - | Store detailed results | TRUE/FALSE | FALSE | For debugging/analysis |

---

## 9. Parameter Validation and Quality Control

### Automatic Validations

```{r echo=FALSE}
validation_checks <- data.frame(
  Parameter_Type = c("Animal Numbers", "Production Metrics", "Area Data", "Input Quantities", "Ratios"),
  Validation_Rules = c(
    "Must be positive integers",
    "Milk yield 1000-15000 kg/cow/year",
    "Area breakdown must sum to total (if validate=TRUE)",
    "All quantities ≥ 0", 
    "Stocking rate 0.1-3.0 cows/ha"
  ),
  Error_Actions = c(
    "Stop execution with error message",
    "Warning with guidance on typical ranges",
    "Stop or warn based on validate_area_sum setting",
    "Stop with error message",
    "Warning about unusual values"
  ),
  User_Guidance = c(
    "Check data entry and farm records",
    "Verify annual vs daily units",
    "Review land use classification",
    "Check for data entry errors",
    "Confirm farm characteristics"
  )
)

kable(validation_checks, caption = "Built-in Validation Rules")
```

### Data Quality Indicators

```{r echo=FALSE}
quality_indicators <- data.frame(
  Indicator = c("Milk yield per cow", "Stocking rate", "Feed conversion", "Energy intensity"),
  Formula = c("Milk_litres / Cows_milking / 1000", "Cows_milking / Area_total_ha", 
              "Milk_litres / Concentrate_feed_kg", "Electricity_kWh / Milk_litres"),
  Excellent_Range = c("7000-9000", "1.2-1.8", "3.0-5.0", "0.04-0.06"),
  Good_Range = c("6000-7000", "0.8-1.2", "2.0-3.0", "0.06-0.08"),
  Poor_Range = c("<5000 or >10000", "<0.5 or >2.5", "<1.5 or >6.0", ">0.10"),
  Unit = c("kg/cow/year", "cows/ha", "L milk/kg conc", "kWh/L milk")
)

kable(quality_indicators, caption = "Data Quality Assessment Indicators")
```

## 10. Common Parameter Issues and Solutions

### Missing Data Handling

```{r echo=FALSE}
missing_data_guide <- data.frame(
  Missing_Parameter = c("Body weights", "DM intake", "Feed breakdown", "Area breakdown", "Ym factor"),
  Default_Used = c("Species-specific defaults", "Calculated from body weight", "Concentrate only", "Total area only", "6.5%"),
  Accuracy_Impact = c("Low", "Medium", "High", "Medium", "Medium"),
  Recommended_Action = c(
    "Use literature values for breed/region",
    "Estimate from feeding standards", 
    "Collect detailed feed records",
    "Survey farm land use patterns",
    "Use regional studies or 6.0-6.8 range"
  )
)

kable(missing_data_guide, caption = "Handling Missing Parameters")
```

### Unit Conversion Guide

```{r echo=FALSE}
conversion_guide <- data.frame(
  Parameter = c("Milk production", "Feed amounts", "Fertilizer", "Body weight", "Area"),
  Common_Units = c("L, kg", "kg fresh, kg DM, tons", "kg product, kg N", "kg, lbs", "ha, acres"),
  cowfootR_Unit = c("L/year", "kg DM/year", "kg N/year", "kg", "hectares"),
  Conversion_Factor = c("kg = L × density", "DM = fresh × (1 - moisture%)", 
                       "kg N = kg product × N%", "kg = lbs ÷ 2.205", "ha = acres × 0.405"),
  Typical_Values = c("1.03 kg/L", "35% DM corn silage", "46% N in urea", "580 kg dairy cow", "0.405 ha/acre")
)

kable(conversion_guide, caption = "Unit Conversion Reference")
```

### Regional Parameter Adjustments

```{r echo=FALSE}
regional_adjustments <- data.frame(
  Region = c("EU", "US", "Brazil", "Argentina", "Australia", "Global"),
  Soy_EF_Range = c("2.1-3.2", "1.2-2.2", "0.9-1.6", "0.8-1.5", "1.8-3.0", "1.5-2.8"),
  Fertilizer_EF = c("5.8-7.9", "5.3-7.6", "6.0-8.3", "5.8-8.1", "5.4-7.7", "5.5-7.8"),
  Key_Differences = c(
    "High soy transport costs",
    "Domestic grain production", 
    "Local soy, high N fertilizer",
    "Local grain/soy production",
    "High transport distances",
    "Average of all regions"
  ),
  Use_When = c(
    "European farms", "US/Canadian farms", "Brazilian operations", 
    "Argentinian farms", "Australian/NZ farms", "Unknown/mixed sourcing"
  )
)

kable(regional_adjustments, caption = "Regional Emission Factor Variations")
```

## 11. Parameter Sensitivity Rankings

### High Impact Parameters (>15% result change)

```{r echo=FALSE}
high_impact <- data.frame(
  Parameter = c("n_animals", "milk_litres", "conc_kg", "ym_percent", "avg_body_weight"),
  Function = c("enteric", "intensity", "inputs", "enteric", "enteric"),
  Impact_Direction = c("Linear", "Inverse", "Linear", "Linear", "Linear"),
  Typical_Variation = c("±20%", "±25%", "±30%", "±15%", "±10%"),
  Result_Sensitivity = c("±20%", "±25%", "±25%", "±15%", "±8%"),
  Data_Priority = c("High", "High", "High", "Medium", "Medium")
)

kable(high_impact, caption = "High Impact Parameters (Priority for Accurate Data)")
```

### Medium Impact Parameters (5-15% result change)

```{r echo=FALSE}
medium_impact <- data.frame(
  Parameter = c("n_fertilizer_kg", "diet_digestibility", "area_total_ha", "manure_system", "region"),
  Impact_Range = c("5-12%", "8-15%", "Area metrics only", "10-25% manure", "5-20% inputs"),
  Collection_Difficulty = c("Easy", "Medium", "Easy", "Easy", "Easy"),
  Recommendation = c("Get purchase records", "Estimate from feed quality", 
                    "Survey or property records", "Observe system", "Select best match")
)

kable(medium_impact, caption = "Medium Impact Parameters")
```

### Low Impact Parameters (<5% result change)

```{r echo=FALSE}
low_impact <- data.frame(
  Parameter = c("plastic_kg", "lpg_kg", "gwp values", "milk_density", "transport_km"),
  Impact_Range = c("<2%", "<3%", "<5%", "<2%", "<5%"),
  Default_Approach = c("Estimate broadly", "Estimate or ignore", "Use package defaults", 
                      "Use 1.03", "Estimate 100-200 km"),
  Notes = c("Small contribution unless very large", "Often minimal in dairy",
           "IPCC AR6 values recommended", "Varies little", "Affects feed emissions only")
)

kable(low_impact, caption = "Low Impact Parameters (Can Use Estimates)")
```

## 12. Troubleshooting Common Issues

### Error Messages and Solutions

```{r echo=FALSE}
error_solutions <- data.frame(
  Error_Type = c("Invalid region", "Negative values", "Area sum mismatch", "Missing required data", "Unrealistic results"),
  Common_Cause = c(
    "Typo in region name",
    "Data entry error or wrong units",
    "Land use breakdown doesn't add up",
    "Empty cells in required columns",
    "Wrong units or extreme outliers"
  ),
  Solution = c(
    "Check spelling: 'EU', 'US', 'Brazil', 'Argentina', 'Australia'",
    "Verify all quantities ≥ 0 and units are correct",
    "Review area_breakdown list or set validate_area_sum = FALSE",
    "Fill required columns or use defaults",
    "Check units, outliers, and parameter ranges"
  ),
  Prevention = c(
    "Use template dropdown lists",
    "Implement data validation in Excel",
    "Use GIS or survey data for areas",
    "Document data requirements clearly",
    "Compare results with similar farms"
  )
)

kable(error_solutions, caption = "Common Error Messages and Solutions")
```

### Performance Optimization

For large batch processing:

```{r echo=FALSE}
optimization_tips <- data.frame(
  Aspect = c("Data Preparation", "Processing Speed", "Memory Management", "Error Handling", "Result Storage"),
  Recommendation = c(
    "Pre-validate data, use consistent formats, remove empty rows",
    "Process in chunks of 50-100 farms, use tier 1 for screening",
    "Set save_detailed_objects = FALSE for large batches",
    "Implement robust error logging and recovery mechanisms",
    "Export results incrementally, use database for >1000 farms"
  ),
  Performance_Gain = c("50-70%", "30-50%", "60-80%", "Prevents crashes", "Scalable"),
  Implementation_Effort = c("Low", "Medium", "Low", "High", "High")
)

kable(optimization_tips, caption = "Performance Optimization for Large Datasets")
```

## 13. Advanced Parameter Combinations

### Tier 2 Optimal Parameter Sets

```{r echo=FALSE}
optimal_combinations <- data.frame(
  System_Type = c("Intensive Dairy", "Extensive Grazing", "Mixed System", "Organic System"),
  Key_Parameters = c(
    "High DM intake, concentrate feeds, precise body weights",
    "Pasture N excretion, extensive manure system, lower Ym",
    "Balanced feed inputs, moderate intensities",
    "Organic fertilizers, lower input emissions, pasture focus"
  ),
  Critical_Measurements = c(
    "Feed composition, milk yield, system temperature",
    "Grazing management, soil conditions, climate data",
    "Feed efficiency ratios, land use breakdown",
    "Organic input quantities, certification requirements"
  ),
  Typical_Accuracy = c("±10-15%", "±15-25%", "±12-20%", "±15-30%")
)

kable(optimal_combinations, caption = "Optimal Parameter Combinations by System Type")
```

### Parameter Interaction Effects

```{r echo=FALSE}
interaction_effects <- data.frame(
  Parameter_Pair = c("Body weight + DM intake", "Ym% + Feed quality", "Climate + Soil type", 
                    "Region + Feed sources", "Manure system + Retention time"),
  Interaction_Type = c("Multiplicative", "Exponential", "Additive", "Complex", "Threshold"),
  Effect_Magnitude = c("Medium", "High", "Medium", "High", "Variable"),
  Management_Implication = c(
    "Heavier cows need proportionally more feed",
    "Poor quality diets increase methane conversion",
    "Tropical poorly-drained soils have highest N2O",
    "Local feed sourcing reduces transport emissions",
    "Short retention (<30 days) limits CH4 conversion"
  )
)

kable(interaction_effects, caption = "Important Parameter Interactions")
```

## 14. Data Collection Protocols

### Minimum Data Requirements by Objective

```{r echo=FALSE}
data_requirements <- data.frame(
  Assessment_Goal = c("Screening Assessment", "Management Planning", "Carbon Trading", "Research Study"),
  Essential_Data = c(
    "Animal numbers, milk production, basic inputs",
    "Detailed feeds, precise areas, management practices",  
    "Verified production, third-party validated inputs",
    "Complete parameter set, uncertainty quantification"
  ),
  Time_Investment = c("2-4 hours", "1-2 days", "3-5 days", "1-2 weeks"),
  Accuracy_Target = c("±30%", "±15%", "±10%", "±5%"),
  Tier_Recommendation = c("Tier 1", "Tier 2", "Tier 2 + validation", "Tier 2 + uncertainty")
)

kable(data_requirements, caption = "Data Requirements by Assessment Objective")
```

### Data Collection Schedule

```{r echo=FALSE}
collection_schedule <- data.frame(
  Data_Category = c("Production Records", "Feed Purchases", "Energy Consumption", 
                   "Land Management", "Animal Characteristics"),
  Collection_Frequency = c("Monthly", "Each delivery", "Monthly", "Seasonal", "Annual"),
  Storage_Location = c("Farm office", "Purchase invoices", "Utility bills", 
                      "Management records", "Herd records"),
  Quality_Control = c("Cross-check with processor", "Verify units and quantities", 
                     "Monitor seasonal patterns", "Update land use changes", 
                     "Weigh representative sample")
)

kable(collection_schedule, caption = "Recommended Data Collection Schedule")
```

## 15. Quality Assurance Framework

### Validation Hierarchy

```{r echo=FALSE}
validation_hierarchy <- data.frame(
  Level = c("Level 1: Range Checks", "Level 2: Consistency Checks", 
            "Level 3: Benchmark Comparison", "Level 4: Expert Review"),
  Validation_Type = c("Automatic", "Automatic", "Semi-automatic", "Manual"),
  Examples = c(
    "Values within expected ranges, correct units",
    "Milk yield vs feed intake, stocking rate vs area",
    "Results vs regional averages, peer farm comparison",
    "Technical review by LCA specialist"
  ),
  Error_Detection = c("90%", "70%", "50%", "95%"),
  Implementation = c("Built-in cowfootR", "Built-in cowfootR", "User comparison", "External expert")
)

kable(validation_hierarchy, caption = "Quality Assurance Validation Levels")
```

### Red Flag Indicators

```{r echo=FALSE}
red_flags <- data.frame(
  Indicator = c("Milk intensity", "Feed efficiency", "Energy use", "Emission ratios", "System consistency"),
  Warning_Threshold = c(">2.5 kg CO2eq/kg FPCM", "<1.0 L milk/kg concentrate", 
                       ">0.15 kWh/L milk", "Enteric <30% of total", "Intensive system + low inputs"),
  Likely_Cause = c(
    "Poor productivity or data errors",
    "Overestimated feed use or underestimated milk",
    "Energy-intensive processes or errors",
    "Missing emission sources or calculation errors", 
    "Inconsistent system classification"
  ),
  Investigation_Priority = c("High", "High", "Medium", "High", "Medium")
)

kable(red_flags, caption = "Data Quality Red Flag Indicators")
```

## Conclusion

This parameter reference guide provides comprehensive technical specifications for all cowfootR functions. Use it as a reference when:

- Setting up new farm assessments
- Troubleshooting calculation issues  
- Validating data quality
- Understanding parameter sensitivities
- Optimizing data collection efforts

For practical applications, start with the function-specific sections, then refer to validation and troubleshooting sections as needed. The parameter sensitivity rankings help prioritize data collection efforts for maximum accuracy improvement.

Remember that parameter accuracy requirements depend on the intended use of results. Screening assessments can tolerate higher uncertainty than management planning or carbon trading applications.

---

*This reference guide covers cowfootR version `r packageVersion("cowfootR")` and follows IDF 2022 and IPCC 2019 methodological standards.*
