Commit 7d4d00d3 authored by starter371639's avatar starter371639
Browse files

stata kompatibles master file

parent 70f84104
Loading
Loading
Loading
Loading

00_master_run.do

0 → 100644
+109 −0
Original line number Diff line number Diff line
// =========================================
// Haupt-Do-Datei: master_project.do
// =========================================

clear all

// === 0. Hinweise ===
// Voraussetzungen:
// - R und Python (z. B. Anaconda oder System) müssen installiert sein
// - Internetverbindung für Paketinstallation
// - Dieses Skript muss im Hauptverzeichnis des Projekts liegen

// === 1. Projektpfad setzen ===
global projectpath = c(pwd)

// === 2. Globale Pfade definieren ===
global datapath      "$projectpath/01_data"
global codepath      "$projectpath/02_code"
global vispath       "$projectpath/03_visualization"

global rpath         "$codepath/R"
global pypath        "$codepath/py"
global statapath     "$codepath/STATA"

// === 3.0 Python-Interpreter automatisch erkennen ===
capture shell "/Users/`c(username)'/anaconda3/bin/python" --version
if _rc {
    // macOS & Linux: Fallback auf python3
    capture shell python3 --version
    if _rc {
        // Windows Beispielpfad für Anaconda
        global pythonexec `"C:\Users\`c(username)'\anaconda3\python.exe"`
    }
    else {
        global pythonexec = "python3"
    }
}
else {
    global pythonexec = "/Users/`c(username)'/anaconda3/bin/python"
}

display "Aktiver Python-Interpreter: $pythonexec"

// === 3.1 Python-Abhängigkeiten installieren ===
python:
import subprocess
import sys

dependencies = ["pandas", "numpy", "matplotlib", "seaborn", "networkx", "scipy"]

try:
    subprocess.run([sys.executable, "-m", "pip", "install"] + dependencies, check=True)
except Exception as e:
    print("Fehler bei der Python-Installation:", e)
end

// === 3.2 R-Pakete installieren mit nativer rcall ===

capture which rcall
if _rc {
    display as error "Fehler: Der Befehl 'rcall' ist nicht verfügbar. Bitte STATA R-Integration aktivieren (ab Version 16)."
    exit 1
}

// R starten testen
capture rcall: R.version.string
if _rc {
    display as error "Fehler beim Start von R. Bitte prüfen, ob R korrekt installiert und erreichbar ist."
    exit 1
}

// .R-Skript für Paketinstallation ausführen
rcall clear
rcall : source("$rpath/install_packages.R")

// === 4. Analyse-Skripte ausführen ===

cd "$projectpath"

// 4.1 STATA: Datensammlung
do "$statapath/01_data_collection.do"

// 4.2 PYTHON: Datenvorverarbeitung
capture shell $pythonexec "$pypath/02_data_preprocessing.py"
if _rc {
    display as error "Fehler bei der Ausführung von 02_data_preprocessing.py"
    exit 1
}

// 4.3 PYTHON: Deskriptive Analyse
capture shell $pythonexec "$pypath/03_descriptiv_analysis.py"
if _rc {
    display as error "Fehler bei der Ausführung von 03_descriptiv_analysis.py"
    exit 1
}

// 4.4 STATA: Modellierung mit IPW
do "$statapath/04_data_modeling_IPW.do"

// 4.5 Rcall: Causal Forest Modellierung
rcall : source("$rpath/05_data_modeling_causalforest.R")


// 4.6 PYTHON: Visualisierung
capture shell $pythonexec "$pypath/05_data_visualization.py"
if _rc {
    display as error "Fehler bei der Ausführung von 05_data_visualization.py"
    exit 1
}

01_data/.DS_Store

0 → 100644
+6 KiB

File added.

No diff preview for this file type.

02_code/.DS_Store

0 → 100644
+12 KiB

File added.

No diff preview for this file type.

02_code/R/.DS_Store

0 → 100644
+6 KiB

File added.

No diff preview for this file type.

02_code/R/.RData

0 → 100644
+4.72 MiB

File added.

No diff preview for this file type.

Loading