Docsity

Statistical Analysis of Nitrogen Dioxide Concentration Data with Linear Regression, Exams of Statistics

Partial preview of the text

Download Statistical Analysis of Nitrogen Dioxide Concentration Data with Linear Regression and more Exams Statistics in PDF only on Docsity!

M.PHIL. IN STATISTICAL SCIENCE

Tuesday 3 June 2008 1.30 to 4.

APPLIED STATISTICS

Attempt no more than FOUR questions. There are FIVE questions in total. The questions carry equal weight.

STATIONERY REQUIREMENTS

Cover sheet Treasury tag Script paper

SPECIAL REQUIREMENTS

None

You may not start to read the questions

printed on the subsequent pages until

instructed to do so by the Invigilator.

1 Let Y = Xβ +  where Y T^ = (Y 1 ,... , Yn), βT^ = (β 1 ,... , βp), X is a known n × p matrix with rank p (< n), and T^ = ( 1 ,... , n), where  1 ,... , n are independent normal random variables with mean zero and variance σ^2. Find the least squares estimator βˆ of β and find its distribution. Define the residual sum of squares RSS and write down an estimator for σ^2. Explain how to test H 0 : β 1 = 0 in the above model.

In the edited R output below, NO2 contains observations of the nitrogen dioxide con- centration in a particular location for 25 days, and, for the same 25 days, wind contains the average windspeed (in miles per hour), maxtemp contains the maximum temperature (in degrees Fahrenheit), and insol contains the insolation (a measure of solar radiation energy, in langleys per day). Write down the model fitted in model1.lm and interpret in detail the output to summary(model1.lm).

> model1.lm <- lm(NO2 ~ wind + maxtemp + insol) > summary(model1.lm)

Call: lm(formula = NO2 ~ wind + maxtemp + insol)

Residuals: Min 1Q Median 3Q Max -2.3052 -1.1710 -0.4990 0.9823 3.

Coefficients: Estimate Std. Error t value Pr(>|t|)

(Intercept) 3.784916 7.979647 0.474 0. wind -0.527410 0.224904 -2.345 0. maxtemp 0.124991 0.075173 1.663 0. insol -0.005259 0.006637 -0.792 0.

Residual standard error: 1.844 on 21 degrees of freedom Multiple R-Squared: 0.6533, Adjusted R-squared: 0.

In the edited output below, explain the output to the stepAIC directive. Comment briefly on the output to boxcox(model1.lm) which is shown in Figure 1.

> library(MASS) > stepAIC(model1.lm, scope = list(upper = ~ wind + maxtemp + insol, lower=~1), test="F")

Start: AIC = 34. NO2 ~ wind + maxtemp + insol

Df Sum of Sq RSS AIC F Value Pr(F)

  • insol 1 2.136 73.564 32.982 0.628 0. 71.428 34.
  • maxtemp 1 9.403 80.832 35.337 2.765 0.
  • wind 1 18.705 90.133 38.060 5.499 0.

Paper 41

2 Let Yijk, i = 1,... , I, j = 1,... , J, k = 1,... , K, be random variables with

Yijk = μ + αi + βj + ijk , (1)

where the ijk’s are independent normally distributed random variables with mean zero and variance σ^2 ,

∑I

i=1 αi^ = 0 and^

∑J

j=1 βj^ = 0. By considering

S(μ, α 1 ,... , αI , β 1 ,... , βJ ) =

i,j,k

(Yijk − μ − αi − βj )^2 ,

show that the least squares estimates of μ , αi and βj are respectively

μˆ = Y¯+++ , αˆi = Y¯i++ − Y¯+++ and βˆj = Y¯+j+ − Y¯+++ ,

where Y¯i++ =

j,k Yijk/(JK) ,^ Y¯+j+^ =^

i,k Yijk/(IK) and^ Y¯+++^ =^

i,j,k Yijk/(IJK).

Find the residual sum of squares RSS 1 for this model. Find the residual sum of squares RSS 0 for the null model Yijk = μ + ijk. Show that the reduction in the residual sum of squares due to including the βj ’s into the null model is the same as the reduction in the residual sum of squares due to including the βj ’s into the model Yijk = μ + αi + ijk.

For a dataset with 3 levels for factor A, 2 levels for factor B , and with 2 replicates for each combination of factor levels, model (1) is fitted and the following analysis of variance table is obtained.

Analysis of Variance Table

Response: y Df Sum Sq

A * 12. B * 0. Residuals * 2.

where the degrees of freedom have been replaced by asterisks. What should the degrees of freedom be? Write down the values of the residual sums of squares for the following models (i) the null model, (ii) model (1), (iii) the model Yijk = μ + αi + ijk and (iv) the model Yijk = μ + βj + ijk. How could you check whether there is an interaction between the factors A and B?

Paper 41

3 Let Y 1 ,... , Yn be independent Poisson random variables, with E(Yi) = μi. Assume that

log(μi) = βT^ xi , i = 1 ,... , n ,

where β is p-dimensional vector of parameters and xi is a p-dimensional vector of known covariate values for the ith observation. Explain why this is a generalised linear model. Find the equations satisfied by the maximum likelihood estimator βˆ of β based on observations y 1 ,... , yn. Find the deviance for this model. If the first component of xi is 1 for all i, show that

∑n i=1 yi^ =^

∑n i=1 μˆi^ , where ˆμi^ = exp( βˆT^ xi).

The number of different plant species was recorded for each of 90 plots, each with different biomass values. Thirty of the plots had low soil ph-level, thirty had medium soil ph-level and thirty had high soil ph-level. In the R commands below, nspecies contains the numbers of species for each of the plots, biomass contains the biomass values and ph is a factor with three levels (low, medium and high).

> model1.glm <- glm(nspecies ~ biomass * ph, poisson) > model2.glm <- glm(nspecies ~ biomass + ph, poisson)

The deviances for model1.glm and model2.glm are 83.2 and 99.2 respectively. Write down in algebraic form the models that have been fitted, and illustrate with appropriate sketch graphs. What do you conclude about how the number of species depends on the biomass for the different soil ph-levels?

Paper 41 [TURN OVER

> summary(melanoma1.glm)

Call: glm(formula = propcases ~ age + city, family = binomial, weights = pop)

Deviance Residuals: Min 1Q Median 3Q Max -1.2830 -0.3355 0.0000 0.3927 1.

Coefficients: Estimate Std. Error z value Pr(>|z|)

(Intercept) -11.69364 0.44923 -26.030 < 2e- age25-34 2.62915 0.46747 5.624 1.86e- age35-44 3.84627 0.45467 8.459 < 2e- age45-54 4.59538 0.45104 10.188 < 2e- age55-64 5.08901 0.45031 11.301 < 2e- age65-74 5.65031 0.44976 12.563 < 2e- age75-84 6.20887 0.45756 13.570 < 2e- age85+ 6.18346 0.45783 13.506 < 2e- city1 0.85492 0.05969 14.322 < 2e-

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 2330.4637 on 14 degrees of freedom Residual deviance: 5.1509 on 6 degrees of freedom

Number of Fisher Scoring iterations: 4

Analysis 2:

> melanoma2.glm <- glm(cases ~ offset(log(pop)) + age + city, poisson) > anova(melanoma2.glm, test = "Chisq")

Analysis of Deviance Table

Model: poisson, link: log Response: cases Terms added sequentially (first to last)

Df Deviance Resid. Df Resid. Dev P(>|Chi|) NULL 14 2327. age 7 2095.56 7 231.73 0. city 1 226.52 6 5.21 3.423e-

Paper 41 [TURN OVER

5 (a) Explain the following statistical terms used in survival analysis

(i) survival data, (ii) right censoring, (iii) left truncation. (b) An academic researcher interested in Indian cuisine approaches two statisticians, Statistician A and Statistician B. The researcher has collected data on a sample of Indian restaurants, located in Cambridge and the surrounding villages, that were operational during all or part of the five-year period from the 1st January 2000 to 31st December 2005, and followed them up until the earlier of their date of closure and 31st December 2007.

The data collected comprise five variables:

obsage: either the length of time the restaurant was in business, if closed down before the end of follow-up or the length of time the restaurant has been operating at the end of follow-up period, if still open ageatentry: the length of time the restaurant had been in operation at entry into the study. status: the closure status of the restaurant (status = 1, if closed down; status = 0, if still in business) size: the size of the restaurant (small, medium or large, coded 0, 1, and 2 respectively), camb: camb = 1 if the restuarant is in Cambridge, and camb = 0 if it is in a village.

All time variables are measured in years.

The academic is particularly interested in determining the proportion of Indian restaur- ants open for 5 years or more and open for 10 years or more, and asked the two statisticians if they could analyse the data collected. Both statisticians recognise that this is a survival data problem, and use the R statistical software environment to construct Kaplan-Meier curves. However, Statisticians A’s and B’s results for the 5-year and 10-year survival probabilities differ from one another, which confuses the researcher.

The researcher approaches you with the two statisticians’ R codes and results, which are shown in the R output provided, and asks for your assistance.

(i) Examine the R output provided and determine, with explanation, which of the two statisticians has performed the more appropriate analysis for constructing the Kaplan-Meier curve. From your choice of the more appropriate analysis, what are the 5-year and 10-year survival probabilities? (The precision attached to point estimates is required.)

(ii) Also provided is the R output from a further analysis of the data performed by one of the statisticians. Comment in detail on the R commands, the analysis done and the results. (Derivations of the underlying techniques, e.g. for coxph( ), are not required.) What additional checks should be made before the results from this analysis are passed on to the academic researcher?

Paper 41

Statistician B

> srvobj <- Surv(time = ageatentry, time2 = obsage, event = status, type = "counting") > summary(survfit(srvobj~1)) Call: survfit(formula = srvobj ~ 1)

  • 0.52 60 1 0.983 0.0165 0.951 1. time n.risk n.event survival std.err lower 95% CI upper 95% CI
  • 0.63 59 1 0.967 0.0232 0.922 1.
  • 0.69 58 1 0.950 0.0281 0.896 1.
  • 0.84 57 1 0.933 0.0322 0.872 0.
  • 1.05 56 1 0.917 0.0357 0.849 0.
  • 1.32 55 1 0.900 0.0387 0.827 0.
  • 1.35 54 1 0.883 0.0414 0.806 0.
  • 1.48 53 1 0.867 0.0439 0.785 0.
  • 1.59 52 1 0.850 0.0461 0.764 0.
  • 1.65 51 1 0.833 0.0481 0.744 0.
  • 1.69 50 1 0.817 0.0500 0.724 0.
  • 1.86 49 1 0.800 0.0516 0.705 0.
  • 2.20 48 1 0.783 0.0532 0.686 0.
  • 2.21 47 1 0.767 0.0546 0.667 0.
  • 2.43 46 1 0.750 0.0559 0.648 0.
  • 2.68 45 1 0.733 0.0571 0.630 0.
  • 3.10 44 1 0.717 0.0582 0.611 0.
  • 3.31 43 1 0.700 0.0592 0.593 0.
  • 3.69 42 1 0.683 0.0601 0.575 0.
  • 4.40 41 1 0.667 0.0609 0.557 0.
  • 4.52 40 1 0.650 0.0616 0.540 0.
  • 5.24 38 1 0.633 0.0623 0.522 0.
  • 6.03 37 1 0.616 0.0629 0.504 0.
  • 6.47 36 1 0.599 0.0634 0.486 0.
  • 7.18 33 1 0.581 0.0641 0.468 0.
  • 7.30 32 1 0.562 0.0646 0.449 0.
  • 7.34 31 1 0.544 0.0650 0.431 0.
  • 7.42 30 1 0.526 0.0653 0.412 0.
  • 7.67 29 1 0.508 0.0655 0.394 0.
  • 7.76 26 1 0.488 0.0659 0.375 0.
  • 8.29 21 1 0.465 0.0667 0.351 0.
  • 9.19 16 1 0.436 0.0686 0.320 0.
  • 9.90 15 1 0.407 0.0699 0.291 0.
  • 10.58 13 1 0.376 0.0712 0.259 0.
  • 11.16 11 1 0.342 0.0724 0.225 0.
  • 12.42 6 1 0.285 0.0797 0.164 0.
    • 0.52 25 1 0.960 0.0392 0.886 1. time n.risk n.event survival std.err lower 95% CI upper 95% CI
    • 0.63 26 1 0.923 0.0523 0.826 1.
    • 0.69 26 1 0.888 0.0611 0.775 1.
    • 0.84 27 1 0.855 0.0671 0.733 0.
    • 1.05 30 1 0.826 0.0707 0.699 0.
    • 1.32 30 1 0.799 0.0735 0.667 0.
    • 1.35 29 1 0.771 0.0759 0.636 0.
    • 1.48 29 1 0.745 0.0778 0.607 0.
    • 1.59 31 1 0.721 0.0789 0.581 0.
    • 1.65 30 1 0.697 0.0799 0.556 0.
    • 1.69 29 1 0.672 0.0807 0.532 0.
    • 1.86 28 1 0.648 0.0813 0.507 0.
    • 2.20 28 1 0.625 0.0816 0.484 0.
    • 2.21 27 1 0.602 0.0818 0.461 0.
    • 2.43 27 1 0.580 0.0818 0.440 0.
    • 2.68 26 1 0.558 0.0816 0.419 0.
    • 3.10 26 1 0.536 0.0812 0.398 0.
    • 3.31 26 1 0.515 0.0807 0.379 0.
    • 3.69 26 1 0.496 0.0800 0.361 0.
    • 4.40 29 1 0.479 0.0790 0.346 0.
    • 4.52 29 1 0.462 0.0780 0.332 0.
    • 5.24 30 1 0.447 0.0769 0.319 0.
    • 6.03 34 1 0.434 0.0758 0.308 0.
    • 6.47 33 1 0.420 0.0746 0.297 0.
    • 7.18 30 1 0.406 0.0734 0.285 0.
    • 7.30 29 1 0.392 0.0722 0.274 0.
    • 7.34 28 1 0.378 0.0710 0.262 0.
    • 7.42 27 1 0.364 0.0697 0.250 0.
    • 7.67 27 1 0.351 0.0684 0.239 0.
    • 7.76 24 1 0.336 0.0671 0.227 0.
    • 8.29 21 1 0.320 0.0658 0.214 0.
    • 9.19 16 1 0.300 0.0647 0.197 0.
    • 9.90 15 1 0.280 0.0634 0.180 0.
  • 10.58 13 1 0.259 0.0621 0.162 0.
  • 11.16 11 1 0.235 0.0607 0.142 0.
  • 12.42 6 1 0.196 0.0620 0.105 0. - Paper

Further analysis performed on the "Indian restaurant" data

> size <- factor(size) > size <- relevel(size,2) > summary(coxph(srvobj ~ camb + size))

Call: coxph(formula = srvobj ~ camb + size)

n = 60 coef exp(coef) se(coef) z p

camb -0.803 0.448 0.344 -2.335 0. size1 -0.322 0.724 0.482 -0.669 0. size3 -0.224 0.799 0.375 -0.598 0.

exp(coef) exp(-coef) lower .95 upper.

camb 0.448 2.23 0.228 0. size1 0.724 1.38 0.282 1. size3 0.799 1.25 0.383 1.

Rsquare = 0.087 (max possible= 0.979)

Likelihood ratio test = 5.45 on 3 df, p = 0. Wald test = 5.76 on 3 df, p = 0. Score (logrank) test = 6.01 on 3 df, p = 0.

END OF PAPER

Paper 41