Question: 5)Build a function my.ls() which performs the least square estimation for a continuous response variable y regressed on two predictors x1 which is a numeric

5)Build a function my.ls() which performs the least square estimation for a continuous response variable y regressed on two predictors x1 which is a numeric predictor and x2 which is a categorical predictor. You may assume that your model contains an intercept. Test the function on the ChickWeight dataset in R, where y is weight, x1 is Time (assumed to be continuous) and x2 is Diet, i.e., check if the function can reproduce the estimated beta coefficients from

data(ChickWeight) fit <- lm(ChickWeight$weight~ChickWeight$Time+ChickWeight$Diet) fit$coef

#using R, the code step by step so I learn

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!