Economics Research Report Writer
Structure, analyze, and generate professional economic reports.
Research Topic
Data Input
Data Visualization
Descriptive Analysis
Run analysis from the previous tab to see results.
Generated Research Report
The descriptive statistics reveal that the average ${varXName} was ${xMean}, while the average ${varYName} was ${yMean}. The key finding from the correlational analysis is a Pearson's r of ${correlation}. This value indicates a ${getCorrelationDescription(correlation)}. The visual representation of this relationship is provided in the scatter plot, which illustrates the data points and the general trend.
4.0 Conclusion
The analysis suggests a ${getCorrelationDescription(correlation, true)} between ${varXName} and ${varYName}. These findings have implications for stakeholders and policymakers, providing empirical evidence on how these two aspects of the economy interact. Further research with a larger dataset is recommended to validate these results.
`; document.getElementById('fullReport').innerHTML = reportHTML; } function getCorrelationDescription(r, simple = false) { const absR = Math.abs(r); let strength = ''; if (absR >= 0.7) strength = 'strong'; else if (absR >= 0.4) strength = 'moderate'; else if (absR >= 0.1) strength = 'weak'; else strength = 'very weak or non-existent'; const direction = r > 0 ? 'positive' : 'negative'; if (simple) return `${strength} ${direction} relationship`; return `${strength} ${direction} correlation`; } // --- Tab Navigation --- function changeTab(tabIndex) { currentTab = tabIndex; document.querySelectorAll('.tab-btn').forEach((btn, i) => btn.classList.toggle('tab-active', i === tabIndex)); document.querySelectorAll('.tab-content').forEach((content, i) => content.classList.toggle('tab-content-active', i === tabIndex)); updateNavButtons(); if (tabIndex === 1) { runAnalysis(); } else if (tabIndex === 2) { generateReport(); } } function navigateTabs(direction) { if (direction === 'next' && currentTab < totalTabs - 1) { changeTab(currentTab + 1); } else if (direction === 'prev' && currentTab > 0) { changeTab(currentTab - 1); } } function updateNavButtons() { const prevBtn = document.getElementById('prev-btn'); const nextBtn = document.getElementById('next-btn'); if (!prevBtn || !nextBtn) return; prevBtn.disabled = currentTab === 0; nextBtn.style.display = currentTab === totalTabs - 1 ? 'none' : 'inline-block'; } // --- PDF Generation --- function downloadPDF() { const { jsPDF } = window.jspdf; const doc = new jsPDF({ unit: 'pt', format: 'a4' }); const reportTitle = document.getElementById('reportTitle').value; const author = document.getElementById('authorName').value || "N/A"; const reportDate = "September 18, 2025"; const { varXName, varYName, count, xMean, yMean, xStdDev, yStdDev, correlation } = analysisResults; const pageWidth = doc.internal.pageSize.getWidth(); const margin = 60; let cursorY = 0; // --- Title Page --- doc.setFont('times', 'bold'); doc.setFontSize(24); doc.text(reportTitle, pageWidth / 2, pageHeight / 2 - 60, { align: 'center', maxWidth: pageWidth - margin*2 }); doc.setFontSize(14); doc.setFont('times', 'normal'); doc.text(`Prepared by: ${author}`, pageWidth / 2, pageHeight / 2 + 20, { align: 'center' }); doc.text(`Date: ${reportDate}`, pageWidth / 2, pageHeight / 2 + 40, { align: 'center' }); doc.addPage(); cursorY = margin; // --- Main Content --- const addSection = (title, bodyText) => { if (cursorY > doc.internal.pageSize.getHeight() - 100) { doc.addPage(); cursorY = margin; } doc.setFont('times', 'bold'); doc.setFontSize(16); doc.text(title, margin, cursorY); cursorY += 25; doc.setFont('times', 'normal'); doc.setFontSize(12); const textLines = doc.splitTextToSize(bodyText, pageWidth - margin * 2); doc.text(textLines, margin, cursorY); cursorY += textLines.length * 14 + 20; }; const introText = `This report examines the relationship between two key economic variables: ${varXName} and ${varYName}. The primary objective is to determine the nature and strength of the correlation between these variables based on the provided dataset.`; addSection("1.0 Introduction", introText); const methodText = `The analysis is based on a dataset of ${count} observations. The methodology involves calculating descriptive statistics and a Pearson correlation coefficient (r) to quantify the linear relationship. The data was also visualized using a scatter plot.`; addSection("2.0 Methodology", methodText); // Add analysis table if (cursorY > doc.internal.pageSize.getHeight() - 150) { doc.addPage(); cursorY = margin; } doc.setFont('times', 'bold'); doc.setFontSize(14); doc.text("3.0 Results", margin, cursorY); cursorY += 20; // Draw table header doc.setFont('times', 'bold'); doc.text("Variable", margin + 20, cursorY); doc.text("Mean", margin + 250, cursorY); doc.text("Std. Dev.", margin + 350, cursorY); cursorY += 10; doc.setDrawColor(100); doc.line(margin, cursorY, pageWidth - margin, cursorY); cursorY += 15; // Draw table rows doc.setFont('times', 'normal'); doc.text(varXName, margin + 20, cursorY, {maxWidth: 200}); doc.text(xMean, margin + 250, cursorY); doc.text(xStdDev, margin + 350, cursorY); cursorY += 15; doc.text(varYName, margin + 20, cursorY, {maxWidth: 200}); doc.text(yMean, margin + 250, cursorY); doc.text(yStdDev, margin + 350, cursorY); cursorY += 15; doc.line(margin, cursorY, pageWidth - margin, cursorY); cursorY += 20; const correlationText = `The Pearson's r is ${correlation}, indicating a ${getCorrelationDescription(correlation)}.`; doc.text(correlationText, margin, cursorY); cursorY += 30; // Add Chart if (chartInstance) { const chartImg = chartInstance.toBase64Image(); if (cursorY > doc.internal.pageSize.getHeight() - 250) { doc.addPage(); cursorY = margin; } doc.addImage(chartImg, 'PNG', margin, cursorY, pageWidth - margin * 2, 200); cursorY += 220; } const conclusionText = `The analysis suggests a ${getCorrelationDescription(correlation, true)} between ${varXName} and ${varYName}. Further research with a larger dataset is recommended to validate these results.`; addSection("4.0 Conclusion", conclusionText); // Add Footer with page numbers const pageCount = doc.internal.getNumberOfPages(); for(let i = 1; i <= pageCount; i++) { doc.setPage(i); if (i > 1) { // No footer on title page doc.setFontSize(10); doc.text(`Page ${i-1} of ${pageCount - 1}`, pageWidth / 2, doc.internal.pageSize.getHeight() - 30, { align: 'center' }); } } doc.save('Economics-Research-Report.pdf'); }