Solved

Slope

Posted on 2006-11-30
2
449 Views
Last Modified: 2008-03-03
Hello,

I am trying to find the linear regression of weight gain over time via MS SQL Server.  I found a function for slope and im trying to apply it.  I am looking for a conformation on this equation and if im applying it correctly.

Slope = ( COUNT(*)*SUM(x*y) -SUM(x)*SUM(y) ) / (COUNT(*)*SUM(x^2)-SUM(x)^2)

The site i found it said x is date and y is weight.  I figured (correct me if im wrong) that x would be the age of the bird in days so i came up with the following query....

SELECT
      (COUNT(*)*SUM(Cast(DateDiff(dd, [Hatch Date], [Date]) As Float)*Weight) -SUM(Cast(DateDiff(dd, [Hatch Date], [Date]) As Float))*SUM(Weight) ) / (COUNT(*)*SUM(Cast(DateDiff(dd, [Hatch Date], [Date]) As Float)^2)-SUM(Cast(DateDiff(dd, [Hatch Date], [Date]) As Float))^2)
FROM
      WingbandFlock As wf
INNER JOIN
      Weight As w
ON
      wf.[Bird ID] = w.[Bird ID]

In concept, am i correct?  I am still running into an SQL error i have not solved, if you know that you can post the answer in my related question for more points :)

http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_22077814.html#a18045854

Thanks!

-Navicerts
0
Comment
Question by:Navicerts
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
Comment Utility
I thought ^ in SQL meant xor, not power
0
 
LVL 7

Author Comment

by:Navicerts
Comment Utility
Well shoot, that explains some things.  Working now!  Sorry i *thought* it was a math question, but you answered an SQL Server question :)  I graphed it and the answer checks out too.

Thanks again!


SELECT
      (Count(*)*SUM(Cast([Feed Consumed] As float)*([Weight Gain]*453.6)) -SUM(Cast([Feed Consumed] As float))*SUM(([Weight Gain]*453.6)) ) / (Count(*)*SUM(power(Cast([Feed Consumed] As float),2))-power(SUM(Cast([Feed Consumed] As float)), 2))
FROM
      WingbandFlock As wf
INNER JOIN
      [Feed Consumed] As fc
ON
      wf.[Bird ID] = fc.[Bird ID]
INNER JOIN
      [Keepers Report] As kr
ON
      wf.[Bird ID] = kr.[Bird ID]
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Nicole
This is a research brief on the potential colonization of humans on Mars.
Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now