Question & Answer: Based on the following ci function definition, ci…..

Based on the following ci function definition, ci function(n, mu, sigma, p) uppermu + qt(1-(1-p)/2, n-1) sigma/sqrt(n); lower mu - qt(1-(1-p)/2, n-1) sigma/sart(n); ci < c(lower, upper) narnes(ci) <-c(pastelp* 100, CI Lower, sep=), pastelp* 100, CI Upper, sep = )) ci Please create a new ci function so that the function only takes two parameters (a vector and percentage), such as, ci <-function(data, P) Please test your new function by the following function cal, library(UsingR apply(homedata, 2, ci, 0.9) Your answer should look like, 2, ci, 0.9) > apply (h㎝edata, y1970 y2000 90CILower 70377.72 265769.5 90CIUpper 71264.14 270970.0

Based on the following ci function definition, ci

Expert Answer

 

Ci<-function(s, p) #passing vector s to the function

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Based on the following ci function definition, ci…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

{

Upper<-s[2]+qt(1-(1-p)/2,s[1]-1)*s[3]/sqrt(n);#vector can be #accessed using index value s[1] or s[2] or s[3]

Lower<-s[2]-qt(1-(1-p)/2,s[1]-1)*s[3]/sqrt(n);#S[2]=

Ci<-c(lower, upper) #lower and upper values are passed to ci vector

Names(ci) <-c(paste(p*100,”CILower”,sep=””), paste(p*100,”CIUpper”,sep=””)) # row values are labeled here

Ci #print ci result

}

library(UsingR)

apply(c(homedata, 2,ci),0.9) # c will concatenate all the values and pass values as single parameter as a vector

Still stressed from student homework?
Get quality assistance from academic writers!