Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Answer the following questions in R: I. Create functions which perform the follo

ID: 3374528 • Letter: A

Question

Answer the following questions in R:

I. Create functions which perform the following tasks: (Use R)

(a) Takes in a vector, and subtracts the mean and divides by the standard deviation?I.e., for every xi finds (xi - ?x+ 2s)/s)

Then returns the standard deviation of the result. Test the function on the following vector: X = 1:100 (Use R)

(b) Takes in a vector and finds the values which are ( ?x- 2s, ?x+ 2s), where s is the sample standard deviation, and

returns both values, with labels of “lower” and “upper” respectively. Test the function on the following vector: X = 1:100  (Use R)

(c) Takes in a vector, and calculates the mean after removing any observations that are more than 3 standard deviations from the mean. Test the function on the following vector: Test the function on the following vector: X = c(1:100,200,300)  (Use R)

Explanation / Answer

a) R code is;

f=function(x)
{
y=(x-mean(x))/sqrt(var(x))
return(sqrt(var(y)))
}
x=c(1:100)
f(x)

b) The R code is

g=function(y)
{
upper=mean(y)+2*sqrt(var(y))
lower=mean(y)-2*sqrt(var(y))
return(c("upper"=upper,"lower"=lower))
}
y=c(1:100)
g(y)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote