Question

2. [20] Consider the car stopping distance example we studied in Section 2.2, with the model where d is the stopping distance, v is the velocity of the car before braking, tr is the response time, and k is a coefficient related to the ratio of the braking force and the mass fo the car. (a) [5] Fit the model (i..e, determine the parameters tr and k) to the data in the first column and the last column of Table 2.4 (on Page 75 in the le containing the data has been posted on CourseSpaces), using the least aquare method. (You will need to use software such as MATLAB or R). Make a plot to compare text, for your convenience, a CSV h your predicted stopping distance with the observed distance.Can someone show me an example on how to fit a model using least square method in R, and make a plot to compare the observed and predicted value?

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

(a)

Since we do not have data in question, I will explain the steps with R commands. You need to replace the bold characters with your filename or directory or field names. All commands are shown in italics.

First you need to read csv file into R Studio with the below command.

Run the command to set the directory where your file resides as working directory.

setwd("Path name of directory where your csv file resides")

Read the file

file1 = read.csv("filename.csv")

Fit the model. Replace the d and v in the command below with the field names from your file (1st and last column of Table 2.4).

model = lm(d ~ v + v2 - 1, data = file1)

Run the command model$coefficients to get the coefficients of the model. In the output, the coefficient of v is t and the coefficient of v2 is k.

Run the below command to compare the observed and predicted value. Replace the d in the command below with the field names from your file

plot(file1$d, model$fitted.values, pch = 16, xlab = "Observed distance", ylab = "Predicted distance")

The plot should be a straight line as shown in the below image.

0.6 0.8 1.0 1.21.41.61.8 Observed distance

Add a comment
Know the answer?
Add Answer to:
Can someone show me an example on how to fit a model using least square method...
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
  • 2. [20| Consider the car stopping distance example we studied in Section 2.2, with the model...

    2. [20| Consider the car stopping distance example we studied in Section 2.2, with the model 2 where d is the stopping distance, v is the velocity of the car before braking, tr is the response time, and k is a coefficient related to the ratio of the braking force and the mass fo the car. (a) [5] Fit the model (i.e, determine the parameters t and k) to the data in the first column and the last column of...

  • K-means clustering K-means clustering is a very well-known method of clustering unlabeled data. The simplicity of...

    K-means clustering K-means clustering is a very well-known method of clustering unlabeled data. The simplicity of the process made it popular to data analysts. The task is to form clusters of similar data objects (points, properties etc.). When the dataset given is unlabeled, we try to make some conclusion about the data by forming clusters. Now, the number of clusters can be pre-determined and number of points can have any range. The main idea behind the process is finding nearest...

  • In cell C6, insert a Scatter Chart for the Returns Completed versus Return Price data from...

    In cell C6, insert a Scatter Chart for the Returns Completed versus Return Price data from the Data worksheet. You may be used to seeing Price placed on the Y-axis from other economics courses, but in this problem we are using price as the independent variable. Inserting Chart Select the Scatter chart from the provided chart options in the Charts group of the Insert tab of the Ribbon. Selecting Data Series Then choose Select Data in the Design tab on...

  • (I did this homework in completion but professor was not happy with answers whatsoever, need additional...

    (I did this homework in completion but professor was not happy with answers whatsoever, need additional answers and especially improvement to 1.b help!! photos not attaching? mean by severai steps. inis is a View Feedback homework and will need you to work, in one two View Feedback or various steps. Unfortunately, I cannot read your screen shot of what you did on excel. As I have said in numerous messages announcements etc, I cannot аcсept pictures. You need to write...

  • just one example/demonstration! Data needed to be calculated is in highlighted in green boxes. And I...

    just one example/demonstration! Data needed to be calculated is in highlighted in green boxes. And I highlighted in red an equation (not sure if thats what you use to calculate it) And ignore the lab instructions on completeing a graph!! I already know how to do that in excel, just curious how Ln (relative rate) and 1/T in K^-1 is calculated by hand* here is the rest of that lab leading up to the question as I know its typically...

  • Using the book, write another paragraph or two: write 170 words: Q: Compare the assumptions of...

    Using the book, write another paragraph or two: write 170 words: Q: Compare the assumptions of physician-centered and collaborative communication. How is the caregiver’s role different in each model? How is the patient’s role different? Answer: Physical-centered communication involves the specialists taking control of the conversation. They decide on the topics of discussion and when to end the process. The patient responds to the issues raised by the caregiver and acts accordingly. On the other hand, Collaborative communication involves a...

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
ADVERTISEMENT