Question

You should submit your report in ONE file (in PDF or MS Word format). Your report must contain the original R code, with outputs and a clear statement of the final answer. Partial

points will be rewarded only when you have the correct R code. Font size should be 10 - 12pt and plots (if any) should be clearly labeled.

Question 3 (extra credit 5 points): In the simple linear regression we introduced in the class, vertical distance is used (left panel as above). As we discussed, alternatively, you can also consider the perpendicular distance (right panel as above). Please derive Bo and B for the same problem of minimizing the sum of squared distance but with such perpendicular distance.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Define the squared perpendicular distance of observed data (i,vi) i- 1,2,..., n from the line is given by where, (X,, Yi) denotes the ith pair of observation without any error i.e 7L Now, minimize di under the constraints Es using Lagrangians multiplier method 7L 7L Define, Δ- di-2 Xi Ei, where, X1, x2, , xn are lagrangian multipliers OA 7l -0 〉 = 0 (3), อั30 7t

Now~from~(1)~and~(2)\Rightarrow E_i=y_i+\lambda_i-\beta_0-\beta_1(x_i-\lambda_i\beta_1)=0\\ \Rightarrow \lambda_i=\frac{\beta_0+\beta_1x_i-y_i}{1+\beta_1^2}\\ Now,~from~(3),~\sum_{i=1}^n\lambda_i=0\Rightarrow \sum_{i=1}^n(\beta_0+\beta_1x_i-y_i)=0\\ \Rightarrow \hat{\beta}_0=\bar{y}-\hat{\beta}_1\bar{x},~where,~\bar{x}=\frac{1}{n}\sum_{i=1}^nx_i,~\bar{y}=\frac{1}{n}\sum_{i=1}^ny_i\\ From~(4),~\sum_{i=1}^n\lambda_iX_i=0\Rightarrow \sum_{i=1}^n(\beta_0+\beta_1x_i-y_i)X_i=0\\ \Rightarrow \sum_{i=1}^n(\beta_0+\beta_1x_i-y_i)(x_i-\lambda_i\beta_1)=0\\ \sum_{i=1}^n((y_i-\bar{y})-\beta_1(x_i-\bar{x}))((1+\beta_1^2)x_i-(-(y_i-\bar{y})+\beta_1(x_i-\bar{x}))\beta_1)=0\\ or,~(1+\beta_1^2)\sum_{i=1}^nx_i((y_i-\bar{y})-\beta_1(x_i-\bar{x}))+\beta_1\sum_{i=1}^n(-(y_i-\bar{y})+\beta_1(x_i-\bar{x}))^2=0\\ Take,~u_i=x_i-\bar{x},~v_i=y_i-\bar{y},~then\\ \sum_{i=1}^n(\beta_1^2u_iv_i+\beta_1(u_i^2-v_i^2)-u_iv_i)=0,~sinve~\sum_{i=1}^nu_i=\sum_{i=1}^nv_i=0\\or,~\beta_1^2s_{xy}+\beta_1(s_x^2-s_y^2)-s_{xy}=0\\ then~\hat{\beta}_1=\frac{s_{yy}-s_{xx}+sign(s_{xy})\sqrt{(s_{xx}-s_{yy})^2+4s_{xy}^2}}{2s_{xy}}\\ where,~sign(s_{xy})=1~if~s_{xy}>0\\ =-1~if~s_{xy}<0

R code:

x=c(11,12,13,14,15,16,17,18,19,20) # values of independent variable
y=c(30,29,29,25,24,24,24,21,18,15) # values of dependent variable
n=length(x) # no. of pair observations
s_xx=sum(x^2)-(sum(x))^2/n
s_yy=sum(y^2)-(sum(y))^2/n
s_xy=sum(x*y)-(sum(x)*sum(y))/n
bar_x=mean(x)
bar_y=mean(y)
sign=0
if(s_xy>0){
sign=1
} else{
sign=-1
}
beta1=(s_yy-s_xx+sign*sqrt((s_xx-s_yy)^2+4*s_xy^2))/(2*s_xy)
beta0=bar_y-beta1*bar_x

beta0

beta1

Add a comment
Know the answer?
Add Answer to:
You should submit your report in ONE file (in PDF or MS Word format). Your report...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • FINAL Project 1-) Please submit the solution of your final as Ms-word or PDF document 2-)...

    FINAL Project 1-) Please submit the solution of your final as Ms-word or PDF document 2-) Complete THREE QUESTIONS out of the four exam questions below. 3-) FOR EACH QUESTION, IT IS REQUIRED to include Ms-Word or Pdf file contains the following A. Source file and sample of your output screen shots. B. Up to one page of your program discussion. In the discussion, state the issues that you may have problem with if there is any. Why your program...

  • Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed, w...

    Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed, what output is expected, the step by step process (algorithm) to get the output from the input, and test data (input for which you know the expected output) for each of the 3 problems given below. You should not write any actual C++ code. Make sure the problem statement is in your own words and is descriptive enough so someone not...

  • PLEASE ANSWER QUESTION 1 & 2. ALSO PLEASE SUBMIT CODE + PDF OF REPORT/ASSIGNMENT Problem1 You are choreographing a...

    PLEASE ANSWER QUESTION 1 & 2. ALSO PLEASE SUBMIT CODE + PDF OF REPORT/ASSIGNMENT Problem1 You are choreographing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location z1 and moves at a rate of vl meters per jump. The second kangaroo starts at location z2 and moves at a rate of u2 meters per...

  • In this assessment, you are required to program an Algorithm-based agent to solve a real-world, which is a challenging case study. This assessment is done individually, and you are required to submit programs and supporting documents in report format. Ple

    You are required to create a robot path planner that is able to find an optimal path to navigate an environment and reach a target. By completing this assessment, you will show your skills on leveraging the best algorithm to solve a simplified real-world problem.The maze can be seen in the image below. It can be seen that there are 12 rows and 24 columns, meaning there is a total of 288 blocks on the map. There are four different...

  • INSTRUCTIONS: After reading the attached article, How To Reskill Your Workforce For AI (Artificial Intelligence).pdf your...

    INSTRUCTIONS: After reading the attached article, How To Reskill Your Workforce For AI (Artificial Intelligence).pdf your job is to provide a very brief summary, analysis, and evaluation. We can define these important concepts as follows: Summary- A formal, logical, consistent way of highlighting the main points. Purpose: In school - to quickly and accurately describe something you have read In professional life - to provide a faster-to-read version of the material to other readers In personal life - to reflect...

  • . The data set below contains information about the gasoline mileage performance for 32 au- tomob...

    please answer the following using the r code provided . The data set below contains information about the gasoline mileage performance for 32 au- tomobiles. We are interested in developing a model to predict the miles per gallon () using related predictor variables. The variables in the study are Dependent variable: Miles per gallon (v) Independent variables: ri horsepower (ft-lb) ra: torque (ft-lb) r: horsepower+torque (ft-lb) rs: carburetor (barrels) (a) We first start by fitting a model using y and...

  • PYHTON CODING FUNCTIONS HELP Part 2. Also need help with these last functions. Requirements/restraints and the...

    PYHTON CODING FUNCTIONS HELP Part 2. Also need help with these last functions. Requirements/restraints and the map referred to is pictured in the screenshot. Need help with these 4 tasks: Function 4: def is_map(map) : given a map (see screenshot), does it meet the following criteria? 1) it is a list of lists of values of type int; 2) it has at least one row and one column; 3) it’s rectangular (all sub-lists are same length); 4) only non-negative ints...

  • In this lab, a piece of working software is given. You are asked to make changes...

    In this lab, a piece of working software is given. You are asked to make changes to the software according to some requirement. The scenario in this lab mimics the situation that most old software applications are facing---need to update. When covering inheritance and polymorphism, we introduced a pattern that has three elements: instanceof operator, base pointers, and a collection data structure. In the given code, the collection used is a dynamic array (will change its length automatically) called Vector....

  • I need this in C++. This is all one question. Introduction Your eighth assignment will consist...

    I need this in C++. This is all one question. Introduction Your eighth assignment will consist of two programs, which will involve the use of simple classes. The source code for these problems should be submitted using the naming conventions we specified in class. Please note that your computer programs should comply with the commenting and formatting rules as described in class. For example, there should be a header for the whole program that gives the author's name, class name,...

  • The Acme Trucking company has hired you to write software to help dispatch its trucks. One important element of this sof...

    The Acme Trucking company has hired you to write software to help dispatch its trucks. One important element of this software is knowing the distance between any two cities that it services. Design and implement a Distance class that stores the distances between cities in a two-dimensional array. This class contains the following required data members and methods: Required Data Members: String[] cities; //it is used to store city names int[][] distance; // this 2-D array repreents distance between two...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT