STA 2311: Statistical Programming Exam
STA 2311: Statistical Programming Exam
The central limit theorem states that the sampling distribution of the sample mean will approach a normal distribution as the sample size increases, regardless of the population’s distribution, provided it has a finite variance. To demonstrate in R, you generate a large sample of data using a normal distribution, calculate means of sub-samples repeatedly, and plot them to show they form a normal distribution. R code example: x <- rnorm(10000, mean=0, sd=1); means <- replicate(1000, mean(sample(x, 30, replace=TRUE))); hist(means, breaks=30).
Residuals, the differences between observed and predicted values, help evaluate model fit and outliers. In examining home prices based on bedrooms, residuals close to zero indicate accurately predicted prices, while large residuals suggest the model might miss other influential variables or the data might have outliers. Analyzing residual plots can indicate if transformation or adding variables is necessary for model improvement .
Univariate data involves observations on a single variable and focuses on describing the central tendency, variability, and distribution shape for that one variable. Bivariate data involves observations on two different variables, and the primary interest is in determining the relationship between these two variables, often through measures like correlation or regression .
EDA is used for initial data analysis to summarize main characteristics often using visual methods. It helps in understanding data patterns, outliers, and underlying structure. Tools include histograms, scatter plots, and box plots. Histograms display the distribution of numeric data, scatter plots show relationships between two numerical variables, and box plots highlight the median and variability of data through quartiles and potential outliers .
Model assumptions in regression include linearity, independence, homoscedasticity, and normality of residuals. To validate, diagnostic plots like residual vs fitted plot, Q-Q plot, scale-location plot, and residuals vs leverage plot are used. In R, functions like plot(lm_model) produce these graphs. Residual vs fitted plots check for linearity and homoscedasticity, Q-Q plots verify the normality of residuals, and residuals vs leverage plots identify influential cases .
Chi-squared goodness of fit tests assess whether the observed frequency distribution of a categorical variable matches an expected distribution. They test a single categorical variable against a distribution. Chi-squared tests for homogeneity assess whether different populations have the same distribution across a set of categories, involving multiple samples to evaluate if there's a difference in distributions among them .
The R-code to find a 90% confidence interval for the proportion would use prop.test() with arguments adjusted for confidence level. Example: n <- 1512; p_hat <- 474/1512; error <- qnorm(0.95) * sqrt(p_hat * (1 - p_hat) / n); ci <- c(p_hat - error, p_hat + error). This reveals the range where the true proportion of correct responses is likely to fall 90% of the time, offering insights into the survey’s reliability .
Bootstrap sampling involves repeatedly sampling with replacement from a data set to generate a large number of simulated samples. It helps estimate properties of an estimator, such as its variance, or build confidence intervals. Benefits include non-parametric statistical inference without assuming data distribution, and effectively dealing with small sample sizes, increasing estimation precision and reliability .
To reject the manufacturer's claim, we perform a hypothesis test with the null hypothesis: μ = 10,000 (the mean lifetime is at least 10,000 hours) and the alternative hypothesis: μ < 10,000. Using the data (sample size n=30, sample mean = 9900, population standard deviation = 120), we calculate the z-score and p-value. If the p-value < 0.05, we reject the null hypothesis. The z-score is (9900 - 10000)/(120/sqrt(30)), and the p-value is computed from the standard normal distribution. Here, R code aids in calculation: H0: z <- (9900-10000)/(120/sqrt(30)); pval <- pnorm(z); if (pval < 0.05) reject H0 .
ANOVA, or Analysis of Variance, is used to compare the means across multiple groups to discover if at least one group mean is statistically different from others. It handles experimental designs and assesses interactions among different groups. In R, ANOVA is implemented using functions like aov() or lm(), followed by summary() to interpret results. The commands efficiently handle calculations required to test differences and interaction in datasets .