User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » ST370 Page [1]  
Jumbles
New Recruit
5 Posts
user info
edit post

I know it's really simple, but can anyone tell me the formula for a least squares line? I probably won't understand the variables either because I'm particularly clueless. I know it comes out to be y=mx+b, but somehow or another I'm supposed to account for the error of all the data points. If anyone wants to use them, here's some data points that I know the the line of best fit for because I used Matlab.

X Y

14 42
16 51
22 68
18 59
30 91

y=2.95x+3.2

2/17/2006 12:58:24 PM

pimpmaster69
All American
4519 Posts
user info
edit post

you in the online course? If its problem4 HW10 then it says to use matlab?

and that leads into my question

if i have a table of data in webass and it tells me to put it in matlab, how exactly does one go about doing this?

This is what webass says:
Use the table below for pasting into M-LAB:

X Y
5 11.2
7 17.0
11 20.3
11 20.9
9 15.3
25 27.3
17 16.9
12 18.0
45 47.7
23 25.8
15 19.3
38 42.9

2/17/2006 1:50:48 PM

lockrugger
Veteran
122 Posts
user info
edit post

i've got exactly the same question....

2/17/2006 7:02:40 PM

Shivan Bird
Football time
11094 Posts
user info
edit post

Quote :
"can anyone tell me the formula for a least squares line?"


Look it up. Simple linear regression is something everyone in college should know.

Quote :
"somehow or another I'm supposed to account for the error of all the data points."


The errors are the true values minus the predicted values from mx+b.

2/17/2006 9:24:58 PM

joe17669
All American
22728 Posts
user info
edit post

here's some generic code that can help you... however, if you're supposed to use some special packages for ST370, then this won't help you:

x=[0 1 2 3 4 5] ; 
y=[0 20 60 68 77 110] ;
plot(x,y)
coefficients=polyfit(x,y,3);
newy=polyval(coefficients,x);
plot(x,y,'*',x,newy,':')

in the function polyfix(x,y,3), the 3 is the degree of fit such that degree <= number of data points

2/17/2006 9:59:35 PM

kartelite
Starting Lineup
97 Posts
user info
edit post

http://www.vanderbilt.edu/Engineering/CIS/Sloan/web/es130/statist/mols.html

You want this line y=mx+b that predicts behavior for your population. How do we decide how 'bad' any line is at predicting? By looking at how far off the data points are from the predicted value, squaring this "distance" for each point then adding them up. Line with the lowest sum wins.

[Edited on February 17, 2006 at 10:42 PM. Reason : sp]

2/17/2006 10:42:28 PM

Jumbles
New Recruit
5 Posts
user info
edit post

pimpmaster, you have to create a file in notepad, copy and paste those numbers into the file and save it somewhere on your computer. If for instance you named the file test, and saved it in the directory, c:/Matlab, and you wanted the name of your data set to be statistics, then in Matlab you would type in:

addpath c:/Matlab
statistics=readfile

It will then prompt you to type in the names of the variables and you will type them in just as you would want them to appear and then you press enter. You now have access to your data set under the name statistics.

2/19/2006 10:56:12 PM

pimpmaster69
All American
4519 Posts
user info
edit post

what kind of file extension would you use, .dat?

2/24/2006 12:49:50 PM

 Message Boards » Study Hall » ST370 Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.