Unit 14: Statistical Tools and Techniques
I. Orientation — Statistical Reasoning, Decisions, and Software
Statistical tools convert observed data into estimates, predictions, and decisions under uncertainty. Bayesian statistics, developed from Thomas Bayes’s posthumously published theorem (1763), updates prior beliefs using observed evidence; decision theory then connects posterior distributions to actions and losses. Excel, RStudio, and SPSS provide increasingly specialized environments for implementing these techniques.
- Governing principle: Statistical inference uses a model to learn about an unknown parameter (\theta) from observed data (x).
- Bayesian foundation: Uncertainty about (\theta) is represented by a probability distribution, both before and after observing data.
- Core assumptions:
- Model specification: A likelihood (p(x\mid\theta)) adequately describes how the data arise.
- Prior specification: A prior distribution (p(\theta)) represents existing information or a deliberately weak starting position.
- Conditional reasoning: Inference is based on the posterior distribution (p(\theta\mid x)).
- Decision convention: An optimal action minimizes posterior expected loss rather than relying only on a point estimate.
- Software roles: Excel emphasizes spreadsheet calculation, RStudio supports programmable and reproducible analysis, and SPSS provides menu-driven statistical procedures.
II. Bayesian Concepts — Probability as Quantified Uncertainty
A. Bayesian Concepts
Bayesian concepts provide a coherent framework for revising uncertainty when new evidence becomes available.
- Bayes’ theorem: The posterior distribution is obtained by multiplying the prior by the likelihood and normalizing:
p(θ | x) = p(x | θ)p(θ) / p(x)
p(x) = ∫ p(x | θ)p(θ)dθHere, (\theta) is an unknown parameter, (x) is observed data, (p(\theta)) is the prior, (p(x\mid\theta)) is the likelihood, (p(\theta\mid x)) is the posterior, and (p(x)) is the marginal likelihood or evidence.
- Prior distribution: The prior expresses knowledge about (\theta) before current data are observed.
- Informative prior: Concentrates probability around values supported by earlier studies or expert knowledge.
- Weakly informative prior: Rules out implausible extremes while allowing the data substantial influence.
- Conjugate prior: Produces a posterior in the same distribution family; a Beta prior is conjugate to a binomial likelihood.
- Likelihood: For (x) successes in (n) independent Bernoulli trials with success probability (\theta),
L(θ | x) ∝ θ^x(1 − θ)^(n − x)The symbol (L) denotes likelihood, (n) is the number of trials, and (\propto) means “proportional to.”
- Posterior distribution: If (\theta\sim\operatorname{Beta}(\alpha,\beta)), then
θ | x ~ Beta(α + x, β + n − x)Parameters (\alpha) and (\beta) are prior shape parameters; observed successes and failures update them directly.
- Predictive distribution: A future observation (y) is predicted by averaging over posterior uncertainty:
p(y | x) = ∫ p(y | θ)p(θ | x)dθ- Credible interval: A 95% posterior credible interval ([a,b]) satisfies (P(a\leq\theta\leq b\mid x)=0.95); unlike a frequentist confidence interval, it directly assigns probability to (\theta).
B. Applications and Limitations
Bayesian analysis is most useful when prior information, sequential evidence, or complete uncertainty statements matter.
- Sequential updating: Today’s posterior can become tomorrow’s prior, making the method suitable for accumulating clinical, industrial, or survey evidence.
- Small samples: A justified prior can stabilize estimates when data are scarce; however, an overly concentrated prior may dominate the likelihood.
- Sensitivity analysis: Analysts should repeat calculations under plausible priors and compare posterior means, intervals, and decisions.
- Computational limitation: Complex normalizing integrals may require Markov chain Monte Carlo (MCMC) or numerical approximation rather than closed-form calculation.
III. Bayesian Inferences — Learning from Posterior Distributions
A. Bayesian Inferences
Bayesian inference draws estimates, intervals, hypotheses, and predictions from the posterior distribution.
- Point inference: Common posterior summaries correspond to different objectives.
- Posterior mean: (E(\theta\mid x)), balancing all parameter values according to posterior probability.
- Posterior median: A value (m) satisfying (P(\theta\leq m\mid x)\geq0.5) and (P(\theta\geq m\mid x)\geq0.5).
- MAP estimate: The maximum a posteriori estimate maximizes (p(\theta\mid x)).
- Worked Beta-binomial example: Suppose (\theta\sim\operatorname{Beta}(2,2)), and 8 successes occur in 10 trials. The posterior is
θ | x ~ Beta(2 + 8, 2 + 2) = Beta(10, 4)
E(θ | x) = 10 / (10 + 4) = 0.714The posterior mean (0.714) combines the prior information with 8 observed successes and 2 failures.
- Interval inference: Equal-tailed credible intervals use posterior quantiles, while highest posterior density intervals contain the most probable values for a specified probability mass.
- Hypothesis comparison: Posterior odds combine prior odds and the Bayes factor:
Posterior odds = Bayes factor × Prior odds
BF₁₀ = p(x | H₁) / p(x | H₀)Here, (H_0) and (H1) are competing hypotheses, and (BF{10}) measures how strongly the observed data favor (H_1) over (H_0).
- Posterior prediction: Predictions incorporate both random future variation and uncertainty about model parameters, producing wider and more realistic uncertainty statements than plug-in predictions.
B. Diagnostic Requirements
Reliable Bayesian inference depends on checking both the statistical model and the computational procedure.
- Posterior predictive checking: Simulated datasets from (p(y\mid x)) are compared with observed features such as means, ranges, or zero counts.
- MCMC convergence: Trace plots should show stable mixing, while an (\hat R) value near 1 indicates agreement among chains.
- Effective sample size: Highly autocorrelated draws contain less information than independent draws, so nominal simulation size alone is insufficient.
- Model dependence: Posterior conclusions remain conditional on the likelihood, prior, and assumptions such as independence.
IV. Bayes Estimates Using Decision Theory Framework — Optimal Actions Under Loss
A. Bayes Estimates Using Decision Theory Framework
Decision theory defines a Bayes estimate as the action that minimizes posterior expected loss.
- Decision elements: A statistical decision problem contains data (x), parameter (\theta), action (a), and loss (L(\theta,a)).
- Posterior expected loss: After observing (x), the posterior risk of action (a) is
ρ(a | x) = E[L(θ, a) | x]
= ∫ L(θ, a)p(θ | x)dθThe Bayes action (a_B) is the value minimizing (\rho(a\mid x)).
- Squared-error loss:
L(θ, a) = (θ − a)²
a_B = E(θ | x)Under squared error, large estimation errors receive disproportionately large penalties, and the posterior mean is optimal.
- Absolute-error loss:
L(θ, a) = |θ − a|
a_B = posterior medianAbsolute loss treats deviations linearly and is less sensitive to extreme posterior values.
- Zero-one loss: For discrete (\theta), (L(\theta,a)=0) when (a=\theta) and 1 otherwise; the Bayes action is the posterior mode or MAP estimate.
- Asymmetric loss: If underestimation is more costly than overestimation, unequal loss weights move the Bayes estimate away from the posterior center toward the more costly side.
B. Significance and Limitations
The framework makes explicit that a statistically accurate estimate is not automatically the best practical decision.
- Action-focused inference: Two organizations using the same posterior may choose different actions because their financial, safety, or operational losses differ.
- Bayes risk: Before data collection, expected performance averages the sampling risk over the prior:
r(π, δ) = ∫ R(θ, δ)π(θ)dθHere, (\pi(\theta)) is the prior, (\delta) is a decision rule, and (R(\theta,\delta)) is its frequentist risk.
- Limitation: Loss functions can be difficult to quantify, and hidden stakeholder preferences may make an apparently objective optimum misleading.
V. Microsoft Excel — Spreadsheet-Based Statistical Analysis
A. Microsoft Excel
Microsoft Excel supports accessible data management, descriptive statistics, probability calculations, simulation, and basic inference.
- Data organization: Each row should represent one observation and each column one variable, with a single header row and consistent coding.
- Descriptive formulas:
=AVERAGE(B2:B101),=MEDIAN(B2:B101), and=STDEV.S(B2:B101)calculate the sample mean, median, and standard deviation. - Probability functions:
=BINOM.DIST(x,n,p,FALSE)returns a binomial point probability;=NORM.DIST(x,mean,sd,TRUE)returns a cumulative normal probability. - Bayesian calculation: For a (\operatorname{Beta}(\alpha,\beta)) prior, Excel can compute the posterior mean as
=(alpha+x)/(alpha+beta+n). - Simulation:
=RAND()generates a uniform value on ((0,1)), while repeated recalculation supports elementary Monte Carlo experiments. - Analysis ToolPak: The add-in provides regression, ANOVA, histograms, moving averages, and descriptive statistics through dialog boxes.
B. Applications and Limitations
Excel is effective for transparent small-scale calculations but requires careful control.
- Strength: Cell references expose individual computational steps and facilitate charts or quick sensitivity tables.
- Limitation: Manual copying, hidden formulas, and accidental overwriting reduce reproducibility; scripts are preferable for complex Bayesian models.
- Good practice: Preserve raw data on a separate sheet, label formulas, use data validation, and audit references before reporting results.
VI. RStudio — Reproducible Statistical Programming
A. RStudio
RStudio is an integrated development environment for R, combining scripts, console output, graphics, package management, and reproducible documents.
- Core workflow: Import data, inspect structure, transform variables, fit models, diagnose assumptions, and save code-based results.
- Descriptive analysis:
mean(data$score, na.rm = TRUE)
sd(data$score, na.rm = TRUE)
summary(data)data$score selects the variable score, and na.rm = TRUE excludes missing values.
- Bayesian computation:
alpha_post <- alpha + x
beta_post <- beta + n - x
posterior_mean <- alpha_post / (alpha_post + beta_post)
qbeta(c(0.025, 0.975), alpha_post, beta_post)qbeta returns the lower and upper quantiles of a 95% equal-tailed Beta credible interval.
- Reproducibility: Scripts preserve each transformation;
set.seed(123)makes pseudo-random simulations repeatable. - Extended modeling: Packages such as
rstanarm,brms, orBayesFactorsupport Bayesian regression, hierarchical modeling, and model comparison.
B. Applications and Limitations
RStudio is suited to advanced analysis where flexibility and reproducibility outweigh the convenience of menus.
- Strength: Functions, loops, version-controlled scripts, and Quarto or R Markdown documents integrate computation with reporting.
- Limitation: Correct results depend on programming accuracy, package knowledge, and careful interpretation of warnings and diagnostics.
- Good practice: Keep raw data unchanged, comment non-obvious code, inspect missing values, and record package versions.
VII. SPSS — Menu-Driven Statistical Analysis
A. SPSS
IBM SPSS Statistics provides data management and established inferential procedures through menus and command syntax.
- Data structure: Data View stores cases in rows and variables in columns; Variable View defines type, labels, missing values, and measurement level.
- Core procedures:
Analyzemenus provide descriptive statistics, (t)-tests, ANOVA, correlation, regression, nonparametric tests, and contingency-table analysis. - Concrete syntax:
DESCRIPTIVES VARIABLES=score
/STATISTICS=MEAN STDDEV MIN MAX.This command reports the mean, standard deviation, minimum, and maximum for score.
- Bayesian procedures: Supported editions include Bayesian one-sample, independent-sample, paired-sample, correlation, and regression analyses, with posterior summaries and Bayes factors.
- Output management: The Output Viewer separates tables, charts, warnings, and model summaries from the active dataset.
B. Applications and Limitations
SPSS is valuable for standardized institutional analysis but is less flexible than a general programming environment.
- Strength: Labelled variables, dialog boxes, and publication-ready tables support survey, social-science, health, and administrative workflows.
- Reproducibility: Menu actions should be pasted into syntax and saved rather than performed only through dialogs.
- Limitation: Licensing costs, edition-dependent Bayesian features, and restricted customization can constrain advanced analysis.
- Selection principle: Excel suits transparent basic work, RStudio suits programmable and complex modeling, and SPSS suits standardized menu-driven analysis with formal output.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →