﻿ 计算机代写美国 function代写 - 美国代写, 计算机作业代写

# 计算机代写美国 function代写

2022-11-06 10:46 星期日 所属： 美国代写 浏览：137

## Project 2:  Write functions to do the following:

You need to write your r codes, not to use the existing r functions. You may use the existing r function to check your results. If you only provide the results from the existing r function, you will not receive any point.

### （a）Write functions to compute the sample mean and 100(1-a)% confidence interval of sample mean.  计算机代写美国

Plot a histogram for the original sample of 50 cases for “rs” and “dpi” variable and impose a smooth curve on the top of the histogram, respectively.

Add proper x-axis label, y-axis label, and a title for each histogram.

Plot these two histograms in one row and side-by-side.

Add a global title for the two plots.

Apply the function to the variables “sr” and “dpi” of the data set LifeCycleSavings, which is a data set provided in R [in R Studio, ?LifeCycleSavings  to see the description of this data set].  计算机代写美国

The data frame with 50 observations on 5 variables.

 [,1] sr numeric aggregate personal savings [,2] pop15 numeric % of population under 15 [,3] pop75 numeric % of population over 75 [,4] dpi numeric real per-capita disposable income [,5] ddpi numeric % growth rate of dpi

#### Present the results in the following for variable “sr”, and a table for the variable “dpi”

 Variable Mean SD of Mean 95% CI: Lower Bound 95% CI: Upper Bound “rs”: Aggregate personal savings “dpi”: Real per-capita disposable income

And plot the histograms following the table.

(b)Write a function to compute the trimmed mean and 100(1-a)% confidence interval of trimmed mean.

perform similar plots as described in (a) for trimmed sample.

[NOTE: Trimmed mean is explained at the end of the Project 2]

Apply the function to the variables “sr” and “dpi” of the data set LifeCycleSavings.

Present the table results and the histogram plots similar to (a).  计算机代写美国

(c)Write a function to compute bootstrapping mean and 100(1-a)% confidence interval of bootstrapping mean. [NOTE: Bootstrapping mean is explained below.]

Perform histogram plots similar to that described in (a) for the 500 bootstrapping sample means for each variable.

Apply the function to the variables “sr” and “dpi” of the data set LifeCycleSavings.

Present the table results and histogram plots similar to (a).

### Explanation of Trimmed Mean  计算机代写美国

Given a sample, x1, x2, x3, …., xn; n cases, drop the smallest k% and largest k% from the sample. Based on this timed sample, compute the sample mean, standard deviation(SD), Standard deviation of Mean = SD/Sqrt(n),  and (100-a)% confidence bounds.

### Explanation of Bootstrapping Mean:

Given a sample, x1, x2, x3, …., xn; n cases. Treat the n cases as the “population” to be sampled. The sampling process for obtaining bootstrapping samples:

(i)Select a random sample of size n (the same the original sample size) WITH REPLACEMNT:

{b1,b2,b3, …., bn} form a bootstrapping sample. Compute a bootstrapping sample mean.  计算机代写美国

(ii)Repeat step (i) for 500 times. You should have 500 sample means.

(iii)Bootstrapping mean, BM = Average of these 500 bootstrapping sample means.

Bootstrapping standard deviation (BSD) is the standard deviation of these 500 sample means.

100(1-a) % confidence limit:

Lower bound = BM – Za/2 (SBD), Upper Bound = BM + Za/2 (SBD)

NOTE: You need to specify seed for each bootstrapping sample. Using the seed (1) for the first bootstrapping sample, then, use 11, 21, 31, 41, and so on as the new seed for the next bootstrapping sample, in sequence.

### Reporting your results for Project 2:

In your R-Markdown report with the file names, such as:

Submit Test1_LeeC_prj2.rmd  and Test2_LeeC_prj2.pdf

The R-Markdown should include three chunks of r-code. Each chunk is the r-codes for solving (a), (b), and (c) respectively.