Question
We are interested in constructing a step function learner as follows: First draw a random number U uniformly on the interval spanned by the minimum
We are interested in constructing a step function learner as follows: First draw a random number U uniformly on the interval spanned by the minimum and maximum values of the input values (x1; :::; xn) and then use it to construct the following function whose purpose is to give the prediction of Y given X = x: f(x) = 1I(U 6 x) + 2I(U > x); where 1 and 2 are just unknown constants to be learned. It goes without saying that I(some statement) is the indicator function that equals 1 when the statement is true and 0 otherwise. Construct an R function called wst that implements an estimate f^(x) = ^1I(U 6 x) + ^2I(U > x) of f. This R function must take the following inputs: A vector x of values at which you would like to compute f^. A data frame data containing the input and output variables. An optional numerical input argument u that overrides the behavior of the learner by forcing the cutpoint of f to be at u instead of the randomly gen- erated cutpoint U. The outputs of the function wst should be a list that contains the following: A vector fitted that contains the predictions at x. A vector coefficients that contains ^1 and ^2. A number cutpoint that is either equal to the input u provided by the function user or equal to the randomly generated U if the input argument u is not pro- vided.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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