Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 2. Describe mathematically what the following code does. Add comments to each line describing what each line accomplishes. Design a scenario where this code
Exercise 2. Describe mathematically what the following code does. Add comments to each line describing what each line accomplishes. Design a scenario where this code would be useful and write that scenario in R. (The scenario should not involve more than four lines of R code) OpSp = function(y, x) { n = length (y) s=n - 1 xs = sort (x) ci = rep(0, s) ssri = rep(0, s) for (i in 1:s) { ci [i] = (xs[i] + xs [i+1])/2 y1 = y [xci [i]] - mean( y [x>ci [i]] ) ssri [i] = sum( y1~2 ) + sum( y2-2 ) } return (ci [which . min (ssri) ]) 7
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started