In R, how do you create a bootstrap distribution for the 5% trimmed mean by taking 1000 resamples (with replacement), with a given dataset named 'data'? I am just looking for the correct R code that will allow me to plug in my data to find the 5% trimmed mean by taking 1000 resamples. The dataset is composed of salaries of a random sample, and I am not providing it because the only question I have is how to correctly format this bootstrapping code in R. This is all I need.
R code with comments (all statements starting with # are comments)
#set the random seed
set.seed(123)
# get the data,
#data<-read....
#assuming that the data is in the dataset named data
# get the sample size (That is number of observations in
data)
# assuming that data has 1 column, else use data$salary everywhere,
if data is a dataframe
n<-nrow(data)
#set the bootstrap resamples
B<-1000
#initialize variable to hold the trimmed mean of resamples
mustar<-numeric(B)
for (i in 1:B){
#sample with replacement using sample(), assuming data
has 1 column, else use data$salary
s<-sample(data[,1],size=n,replace=TRUE)
#calculate the 5% trimmed mean
mustar[i]<-mean(s,0.05)
}
#Do all the things that you want to do with this, for
example
#plot the distribution of mean
hist(mustar,xlab="average Salary",freq=FALSE, main="Bootstrap
distribution of mean Salary")
#98% confidence interval using percentile
# get the value of alpha
alpha<-1-98/100
ci<-quantile(mustar,c(alpha/2,1-alpha/2))
sprintf("98% confidence interval for the mean Salary is
[%.4f,%.4f]",ci[1],ci[2])
In R, how do you create a bootstrap distribution for the 5% trimmed mean by taking 1000 resamples...
can you sovle this problem, also I need the code for part d.
thanks
Problem #5 Ri Vy= Probe I R- 1502 o VOLTMETER INPUT CIRCUIT Probe 2 Express resistance in ohms (2) and voltage in volts (V) Requirements-Part 1 (voltmeter not attached yet) a) Suppose you want to produce a voltage of 1 V across resistor R2 (i.e. Vor 1 V) Use the voltage divider equation to find the value of Ri that is needed to do this. b)...
how
to make my code of python work probely
my q is how to write a code to find the average actual water
level, average error by using python
and my program should be flexible where user can select the
column no. If you can see in the main program, it asked which
column to know the maximum or average, the column number is passed
to the function. The function should look which column to do.
#THIS PROGRAMMING IS ABLE...
1 Overview The goal of this assignment is to help you understand caches better. You are required to write a cache simulator using the C programming language. The programs have to run on iLab machines. We are providing real program memory traces as input to your cache simulator. The format and structure of the memory traces are described below. We will not give you improperly formatted files. You can assume all your input files will be in proper format as...
Need this in C
The starter code is long, if you know how to do it in other way
please do.
Do the best you can please.
Here's
the starter code:
//
-----------------------------------------------------------------------
// monsterdb.c
//
-----------------------------------------------------------------------
#include
#include
#include
//
-----------------------------------------------------------------------
// Some defines
#define NAME_MAX 64
#define BUFFER_MAX 256
//
-----------------------------------------------------------------------
// Structs
typedef struct
{
char name[NAME_MAX];
int hp;
int attackPower;
int armor;
} Character;
typedef struct
{
int size;
Character *list;
} CharacterContainer;
//
-----------------------------------------------------------------------
//...
Hello! Could you please write your own four paragraph (5-6 sentences per paragraph) take away or reflection of the below information? Please complete in 24 hours if possible. Thank you! RIS BOHNET THINKS firms are wasting their money on diversity training. The problem is, most programs just don’t work. Rather than run more workshops or try to eradicate the biases that cause discrimination, she says, companies need to redesign their processes to prevent biased choices in the first place. Bohnet...
The following are screen grabs of the provided files
Thanks so much for your help, and have a nice day!
My Java Programming Teacher Gave me this for practice before the exam, butI can't get it to work, and I need a working version to discuss with my teacher ASAP, and I would like to sleep at some point before the exam. Please Help TEST QUESTION 5: Tamagotchi For this question, you will write a number of classes that you...