Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intermediate Algebra With Trigonometry

Authors: Charles P McKeague

1st Edition

1483218759, 9781483218755

More Books

Students also viewed these Mathematics questions

Question

Why We Form Relationships Managing Relationship Dynamics?

Answered: 1 week ago