473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Linear regression code in VB

Hi every1,this is my 1st time using this forum....pls can any1 tell me how to create a code in VB that can do LINEAR REGRESSION in excel.....i'm not sure how to xplain exactly what i need but basically you know when u use the data analysis tool for regression in excel and it outputs the intercept,anova,residuals e.t.c.,basically i need to be able to do a code in VB that can calculate all dis(linear regression) using the data that i have and output the result in2 excel.
PLS if any1 knows how to do this pls pls reply me asap...am at my wits end....Thanx...x
Feb 12 '08 #1
7 15862
kadghar
1,295 Expert 1GB
Hi every1,this is my 1st time using this forum....pls can any1 tell me how to create a code in VB that can do LINEAR REGRESSION in excel.....i'm not sure how to xplain exactly what i need but basically you know when u use the data analysis tool for regression in excel and it outputs the intercept,anova,residuals e.t.c.,basically i need to be able to do a code in VB that can calculate all dis(linear regression) using the data that i have and output the result in2 excel.
PLS if any1 knows how to do this pls pls reply me asap...am at my wits end....Thanx...x
Do you need the code to get this result using the excel's Linear Regression?? then just use the Macro Recorder.
If what you want is to program each function, well, i think it's going to take you a little bit more time, but you can find all the formulas and algorithms in wikipedia, in case you need them.
Feb 12 '08 #2
Killer42
8,435 Expert 8TB
Yes, try here .
Feb 12 '08 #3
Hi thanx 4 d reply,i was going 2 use the macro recorder but i'm not allowed to,i'll av 2 write d code from start myself and thats where i'm stuck,i've tried wikipedia but i havent had much help from dat either as i'm not able 2 apply d formulas in2 writing a code but i'm giving it a try....pls any more help would b appreciated..thanx..x
Feb 12 '08 #4
kadghar
1,295 Expert 1GB
Hi thanx 4 d reply,i was going 2 use the macro recorder but i'm not allowed to,i'll av 2 write d code from start myself and thats where i'm stuck,i've tried wikipedia but i havent had much help from dat either as i'm not able 2 apply d formulas in2 writing a code but i'm giving it a try....pls any more help would b appreciated..thanx..x
Here's a little example to calculate the variance of A1:A10... we're not supposed to help you in your homework, it's for you to learn, but i think this might point you in the right direction:

Expand|Select|Wrap|Line Numbers
  1. sub var()
  2. dim i as long
  3. dim a as double
  4. dim b as double
  5. for i = 1 to 10
  6.     a= a + cells(i,1)
  7. next
  8. a=a/10 'now a is the mean
  9. for i = 1 to 10
  10.     b = b+ (cells(i,1)-a)^2
  11. next
  12. b= b/9 'and b is the variance
  13. cells(1,2) = b 'write it in the cell B1
  14. end sub
Please, give it a try by your self.

Kad
Feb 12 '08 #5
Here's a little example to calculate the variance of A1:A10... we're not supposed to help you in your homework, it's for you to learn, but i think this might point you in the right direction:

Expand|Select|Wrap|Line Numbers
  1. sub var()
  2. dim i as long
  3. dim a as double
  4. dim b as double
  5. for i = 1 to 10
  6.     a= a + cells(i,1)
  7. next
  8. a=a/10 'now a is the mean
  9. for i = 1 to 10
  10.     b = b+ (cells(i,1)-a)^2
  11. next
  12. b= b/9 'and b is the variance
  13. cells(1,2) = b 'write it in the cell B1
  14. end sub
Please, give it a try by your self.

Kad
Hi Kad..i know am being a bad girl...lol...and i'm not supposed 2 get help but i only need a push in d right direction and i'll be able to take it from there..cos i've neva done VB b4 and i've jst been kinda pushed in2 it and i'm faced with a lot of obstacles.....i fink i shud b able 2 giv it a go now from ur help...thanx a lot....really sorry if i offeded any1...x
Feb 13 '08 #6
kadghar
1,295 Expert 1GB
Hi Kad..i know am being a bad girl...lol...and i'm not supposed 2 get help but i only need a push in d right direction and i'll be able to take it from there..cos i've neva done VB b4 and i've jst been kinda pushed in2 it and i'm faced with a lot of obstacles.....i fink i shud b able 2 giv it a go now from ur help...thanx a lot....really sorry if i offeded any1...x
bad girl Ô_o ... hmm .... pushed into it???

VB is a nice language, many do it for living. Search some tutorials in google about functions and how to use Excel's VBA. If you have more particular doubts about how tu make something work in a function, or how to have the right results in your excel's sheet, we'll be glad to help you in your future tasks.
Feb 13 '08 #7
bad girl Ô_o ... hmm .... pushed into it???

VB is a nice language, many do it for living. Search some tutorials in google about functions and how to use Excel's VBA. If you have more particular doubts about how tu make something work in a function, or how to have the right results in your excel's sheet, we'll be glad to help you in your future tasks.
Thanx....i didnt mean any offence to any1....hope we're cool....lol...i'll take ur advice on board especially what u gave me earlier and i'll holla if i have any more problems...Thanx 4 ur time..x
Feb 13 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: nikie | last post by:
I'm a little bit stuck with NumPy here, and neither the docs nor trial&error seems to lead me anywhere: I've got a set of data points (x/y-coordinates) and want to fit a straight line through...
3
by: sql guy123 | last post by:
This is a real challenge. I hope someone is smart enough to know how to do this. I have a table TABLE1
1
by: wirecom | last post by:
Hi all, I am seeking a module that will do the equivalent of linear regression in 3D to yield a best fit a plane through a set of points (X1, Y1, Z1), (X1, Y1, Z1),... (Xn, Yn, Zn). The...
1
by: zRaVeNk | last post by:
anyone help me with linear regression in visual basic here's what i'm working with: screenshot
1
by: benjamin.d.rogers | last post by:
Hello, Does anybody have vba code to share that performs a multiple regression analysis? I need the analysis to return summary statistics, stats for each independent variable, as well as...
1
by: Nod Lee | last post by:
Hi all Is there any tools/objects from Microsoft that I can use to perform linear regression in webform and generate the results into a graph? If not, is there any recommendations for 3rd...
3
by: ntuyen01 | last post by:
Hi All, Does anyone has examples for Linear Regression formula using c#. Or any good third party software create this. Thanks in advance Regards, Ted
2
by: company1484 | last post by:
This program calculates the solution (x,y) of a system of linear equations in 2 variables. This is my third C programming assignment so be gentle. problem: 1)on my int menu() function definition,...
0
by: drfish | last post by:
Hi, I'm a complete novice when it comes to VB so need some help. I would like a macro that performs linear regression for different cell ranges each time it is run, depending on the number of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.