Memuat
Memuat
Principal Component Analysis (PCA) for Public Health and Epidemiology
0 views
Apply Principal Component Analysis (PCA) to synthetic data to simplify the variables in public health status indicators from life expectancy and sanitation access and interpret the results. PCA transforms correlated variables into uncorrelated principal components ordered by variance. It is used to reduce dimensionality, lessen multicollinearity, and visualise multivariate data.

Apply Principal Component Analysis (PCA) to synthetic data to simplify the variables in public health status indicators from life expectancy and sanitation access and interpret the results.
| Role | Variable | Unit |
|---|---|---|
| Main | Public health status | indeks |
| Supporting 1 | Life expectancy | tahun |
| Supporting 2 | Access to sanitation | % |
PCA condenses 7 indicators (including Public health status, Life expectancy and Access to sanitation) into 4 components for 90% of the variance; PC1 alone carries 48.3%.
Computed from illustrative synthetic data, not from a real study.
PCA transforms correlated variables into uncorrelated principal components ordered by variance. It is used to reduce dimensionality, lessen multicollinearity, and visualise multivariate data.
Report the variance explained by each component and the number retained with the reason. Interpret components through dominant variable loadings.
A short starting script with this project's variable names. The delivered version is adapted to your data and fully commented.
import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
rng = np.random.default_rng(20)
n = 300
f1 = rng.normal(size=n)
f2 = rng.normal(size=n)
life_expectancy = f1 + rng.normal(0, 0.3, n)
access_to_sanitation = f1 + rng.normal(0, 0.3, n)
x3 = f2 + rng.normal(0, 0.3, n)
x4 = f2 + rng.normal(0, 0.3, n)
x5 = rng.normal(size=n)
public_health_status = np.column_stack([life_expectancy, access_to_sanitation, x3, x4, x5])
Z = StandardScaler().fit_transform(public_health_status)
pca = PCA().fit(Z)
cum = np.cumsum(pca.explained_variance_ratio_)
print("Variance ratio:", pca.explained_variance_ratio_.round(3))
print("Cumulative:", cum.round(3))
k = int(np.searchsorted(cum, 0.90) + 1)
print("Components for 90%:", k)
print("Loadings (PC1, PC2):\n", pca.components_[:2].round(2))
scores = pca.transform(Z)
fig, ax = plt.subplots(1, 2, figsize=(10, 4))
ax[0].plot(range(1, 6), pca.explained_variance_ratio_, marker="o")
ax[0].set_title("Scree plot"); ax[0].set_xlabel("Component")
ax[1].scatter(scores[:, 0], scores[:, 1], s=10)
ax[1].set_xlabel("PC1"); ax[1].set_ylabel("PC2")
plt.tight_layout()
plt.show()Choose how much help you need. Each higher package includes everything in the lower ones. Prices exclude 11% VAT.
Package 1
US$19
excl. 11% VAT
Duration: 3 working days
Output: Python files + result figures
Deliverables
Package 2 · most chosen
US$56
excl. 11% VAT
Duration: 7 working days
Output: Code + analysis + interpretation notes
Includes all of Package 1, plus
Package 3
US$125
excl. 11% VAT
Duration: 12-15 working days
Output: Code + analysis + guidance until ready to present
Includes all of Packages 1 & 2, plus
Yes. Principal Component Analysis (PCA) is commonly used at this level in Public Health and Epidemiology. We adapt the analysis to your research question, your own data and your supervisor's requirements.
No. The sheet is computed from illustrative synthetic data so you can see the kind of output Python gives. For your order we run the same method on your own data.
That is the point of the packages. Every script is commented, and Package 3 includes two coaching sessions plus practice questions so you can explain the method and the results at your seminar and defence.
Each project has three packages: Package 1 (code and explanation) US$19, Package 2 (your data analysis and interpretation) US$56 and Package 3 (full guidance) US$125, excluding 11% VAT. Larger datasets, extra methods or tight deadlines adjust the quote after a short consultation.
The result sheet uses illustrative synthetic data. Python is a trademark of the Python Software Foundation.
Back to Python portfolio