# simle R coding task

预算 $10-30 USD

it's an exercise with three simple tasks:

In the exercise, we will analyze experimental data using mixed-model methodology.

The exercise has three main parts:

1. Analyze the data according to the mixed models methodology.

2. Re-analyze the data using naive linear regression and comparing the results.

3. Use parametric bootstrap to approximate the bias and variance of the estimators under

each method.

Comments:

• Feel free to use plots or tables as needed to present your results.

• Please attach your code at the end of your work.

• You may discuss your work with Danielle and me. You may not discuss your work or

share code with other students.

The data

We will use the lawn dataset from library(”faraway”). The data describes cutoff times for

lawnmowers (mecasahat deshe). 3 machines were randomly selected from manufacturers A

and B. Each machine was tested twice at low speed and twice at high speed (total n = 24

measurements). We are interested in testing the difference between Manufacturer A and B,

and between low speed and high speed.

1 Fitting the model as a mixed model

1. Set this problem as a mixed effects model and explain your choices.

2. Use the lmer function from the lme4 package to get estimates for the random effects.

You can use ”REML=TRUE”.

3. Estimate the fixed effects and the variance of your estimators using GLS. Here, I expect

you to write your own functions. For Σ = V ar(Y ), plug in the parameters from (2). Form

asymptotical marginal confidence intervals for the fixed effects.

1

2 Fitting the model as a fixed-effects model using OLS

1. Re-run your analysis, fitting the model as a fixed effects model. Write your own code (do

not use lm). Make sure the parameters of interest have the same meaning as in Part 1.

2. Estimate the effects of manufacterer and speed, as well as the variance of your estimators

according to the OLS theory. Form asymptotical marginal confidence intervals for the effects

in Part 1.

3 Parametric Bootstrap

1. Write a function that takes all the parameters in the model and samples of the response

vector (Y

∗

) according to the mixed effects model. This would require sampling the random

effects and noise terms, and adding the fixed effects according to the design. Specify the

assumptions of your sampling procedure.

2. Use the parameters estimated in 1.2 to sample many (e.g. B = 1000) datasets according

to the model. For each run, estimate the effect of manufacterer and speed according to GLS

(as in Part 1) and according to OLS (as in Part 2).

3. Compare the B estimates to the parameters you used to generate the data in 3.1. Estimate

the bias of each method and the standard-deviation of each method. Estimate the root-meansquared

error for each method. Check which procedure better estimates the variance of the

estimators.

Discussion

Summarize briefly your findings. In particular, discuss:

1. For this data set, which method would you recommend?

Use empirical evidence from Part 3.

2. What is your conclusion regarding difference between manufacturers and the effect of

speed?

2

## 2 freelancers are bidding on average $40 for this job

Expert in machine learning 1. [url removed, login to view] 2. [url removed, login to view]