AI-Based Earnings Forecasting Model (Simulator)
Forecast Setup
Define "AI" Factors (Influencing Variables)
Factor Impact & Weighting
Define how each factor influences earnings and its relative importance (weight).
Input Factor Values for Forecast Period
Enter the expected values for each factor for your chosen forecast period.
Forecast & Analysis
Your earnings forecast will appear here.
Factor Contributions to Forecast
Forecasted ${aibefm_model.baselineMetric}: $${forecastedValue.toFixed(2)} (${(percentageChange >=0 ? '+': '')}${percentageChange.toFixed(2)}%)
Baseline ${aibefm_model.baselineMetric}: $${aibefm_model.baselineValue.toFixed(2)}
`; contributionsList.innerHTML = ''; factorContributions.sort((a,b) => Math.abs(b.contribution) - Math.abs(a.contribution)); // Sort by magnitude factorContributions.forEach(c => { const item = document.createElement('div'); item.className = 'aibefm_factor_contribution_item'; item.innerHTML = `${c.name}: ${(c.contribution >=0 ? '+': '')}${c.contribution.toFixed(2)} pp`; contributionsList.appendChild(item); }); contributionsDiv.style.display = 'block'; document.getElementById('aibefm_downloadPdfButton').style.display = 'block'; } function aibefm_collectModelSetup() { aibefm_model.companyName = aibefm_getInputValue('aibefm_companyName'); aibefm_model.sector = aibefm_getInputValue('aibefm_sector'); aibefm_model.baselineMetric = aibefm_getInputValue('aibefm_baselineMetric'); aibefm_model.baselineValue = aibefm_getInputNumValue('aibefm_baselineValue', 0); aibefm_model.forecastPeriod = aibefm_getInputValue('aibefm_forecastPeriod'); // Factors are updated directly via their oninput events } // --- PDF Generation --- function aibefm_downloadPDF() { if (!aibefm_forecastOutput) { alert("Please generate a forecast first."); return; } if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert('PDF library (jsPDF) is not loaded.'); return; } const { jsPDF: JSPDF } = window.jspdf; const doc = new JSPDF(); let y = 15; const m = 15; const cw = doc.internal.pageSize.getWidth() - (2 * m); const data = aibefm_forecastOutput; function addLine(text, size, style = 'normal', indent = 0, spacing = 2.5) { if (y > 270) { doc.addPage(); y = m; } doc.setFontSize(size); doc.setFont(undefined, style); const lines = doc.splitTextToSize(text, cw - indent); doc.text(lines, m + indent, y); y += (lines.length * (size * 0.35)) + spacing; } addLine(`Earnings Forecast: ${data.companyName || 'N/A'}`, 18, 'bold', 0, 5); addLine(`Sector: ${data.sector}, Period: ${data.forecastPeriod}`, 10); addLine(`Baseline ${data.baselineMetric}: $${data.baselineValue.toFixed(2)}`, 10); addLine(`Forecasted ${data.baselineMetric}: $${data.forecastedValue.toFixed(2)} (${(data.percentageChange >=0 ? '+': '')}${data.percentageChange.toFixed(2)}%)`, 12, 'bold', 0, 6); addLine("Influencing Factors & Settings:", 14, 'bold', 0, 4); data.factors.forEach(f => { let factorDesc = `- ${f.name || 'Unnamed'}: Type: ${f.type}, Impact: ${f.impactDirection}, Weight (Max Contrib.): ${f.weight}%`; if(f.type === 'numerical') factorDesc += `, Range: ${f.scaleMin}-${f.scaleMax}`; if(f.type === 'categorical') factorDesc += `, Cats: ${(f.categories||[]).join('/')}`; if(f.type === 'percentage') factorDesc += `, Input as % points`; factorDesc += `, Forecast Input Value: ${f.currentValue === null || f.currentValue === undefined ? 'N/A' : f.currentValue} ${f.unit || ''}`; addLine(factorDesc, 9, 'normal', 5, 1.5); }); y += 3; addLine("Factor Contributions to Forecast Change:", 14, 'bold', 0, 4); data.factorContributions.forEach(c => { addLine(`- ${c.name}: ${(c.contribution >=0 ? '+': '')}${c.contribution.toFixed(2)} percentage points`, 10, 'normal', 5, 2); }); addLine(`Note: This is a simulated forecast based on user-defined parameters. Max total impact from factors capped at +/-${aibefm_model.maxTotalImpactFromFactors}%.`, 8, 'italic', 0, 5); doc.save(`${(data.companyName || 'forecast').replace(/\s+/g, '_')}_earnings_forecast.pdf`); }