# R代码代写｜Stat 4230/6230 Take-home Midterm Exam

这是一篇来自美国的关于统计数据需要带回家期中考试的**R代码代写**

**Note: For all hypothesis testing questions, state your null and ****alternative, and give the name/formula of the testing statistic, its ****value, the p-value and your conclusion using ***α *= 5%**. **

Researchers at the University of North Carolina–Greensboro investigated a model for the rate of seed germination *(Journal of Experimental **Botany*, January 1993). In one experiment, alfalfa seeds were placed in a specially constructed germination chamber. Eleven hours later,the seeds were examined and the change in free energy (a measure of germination rate) recorded. The results for seeds germinated at seven difffferent temperatures are given in the data set SEEDGERM. The data were used to fifit a simple linear regression model, with *y *= change in free energy and *x *= temperature.

(a) (5 points) Graph the points in a scatterplot, locate any unusual data point (outlier) and remove it from the data set (e.g., using data = data[-4, ] if you want to remove the 4th row) for all subsequent analyses.

(b) (5 points) Write an order-one regression model for *y *using *x*, and specify the assumptions on the error.

(c) (5 points) Find all least squares estimates for all coeffiffifficients, and interpret these estimates.

(d) (5 points) Find the estimate for the variance of the error term,and specify the degree of freedom.

(e) (5 points) Find the 95% confifidence intervals for all coeffiffifficients,and the 95% **simultaneous **confifidence intervals for all coeffiffifficients using Bonferroni correction.

(f) (5 points) Give the ANOVA table (with SST, SSReg and SSE and their df).

(g) (5 points) Test if *H*0 : *β*1 = 0 vs *H*1 : *β*1 *< *0 using a one-sided *t *test.

(h) (5 points) Predict the mean response at the temperature of 286.5 and give both the 95% confifidence intervals for the mean response and 95% prediction interval for a new observation at this temperature. Is such this prediction appropriate?

One of the most promising methods for extracting crude oil employs a carbon dioxide (CO2) flflooding technique. When flflooded into oil pockets, CO2 enhances oil recovery by displacing the crude oil. In a microscopic investigation of the CO2 flflooding process, flflow tubes were dipped into sample oil pockets containing a known amount of oil. The oil pockets were flflooded with CO2 and the percentage of oil displaced was recorded. The experiment was conducted at three difffferent flflow pressures and three difffferent dipping angles. The data

set is CRUDEOIL in the data.zip fifile.

(a) (5 points) Fit the complete second-order model relating percentage oil recovery *y *to pressure *x*1 and dipping angle *x*2,

*E*(*y*) = *β*0 + *β*1*x*1 + *β*2*x*2

1 + *β*3*x*2 + *β*4*x*2

2 + *β*5*x*1*x*2

and give the fifitted equation.

(b) (5 points) Run a global utility test for the model in the part (a),and give the ANOVA table (SST, SSReg and SSE and their df).

(c) (5 points) Run an F test to check if we should drop all second-order terms together from the model in part (a).

(d) Suppose we keep the interaction but omit other second-order terms,write the new model, and make

**line. **

Consider a second experiment designed to investigate the effffect of arrival rate of product components, (x1) and temperature of the room (x2) on the length of time (y) required by individual workers to perform a product assembly operation. Each factor will be held at two levels:

arrival rate at .5 and 1.0 component per second and temperature at 70*◦*F and 80*◦*F. The data set is ASSEMBLY2 in the data.zip fifile.

(a) (5 points) Fit a main-effffect-only regression of *y *on *x*1 and *x*2.

(b) (5 points) Fit a full model including the interaction between *x*1 and *x*2, and test whether the interaction term is signifificantly difffferent from 0 or not. Be clear about the hypothesis you are testing.

(c) (10 points) Obtain the confifidence intervals for the mean of *y *for each pair of *x*1 and *x*2 in the data set and the prediction intervals for single observations of *y *for each pair of *x*1 and *x*2 in the data set.

(d) (10 points) What is the effffect of arrival rate (*x*1) of 1.0 compared to 0.5 when temperature (*x*2) is controlled at 70*◦*F and 80*◦*F respectively? What is the difffference in the effffect between 70*◦*F and 80*◦*F? Give a 95% confifidence interval for this difffference.