Question

Trend analysis

Asked by: gregoryyoung

I have some stat based data in a table ... I would like to query for ranges in an attempt to do some correlation.

EX:
Table measurements
pkMeasurmentId int
Subject string
Time DateTime
Value double

All values are between 0 and 1

my data has dips and troughs ... I would like to narrow these dips and troughs and get there size ...

ex:
....
....
.... trend coming down
1:00 .23
1:02 .27
1:03 .25
1:05 .29
1:07 .28
1:08 .31
1:09 .35
1:11 .41
1:12 .42
1:13 .45
1:15 .48
1:17 .45
1:19 .44
1:20 .42
1:21 .43
1:23 .39
1:25 .37

what I want to query for here is my large points of change in directionality (1:00 and 1:15) ... Yes I know I could use max and min if I wanted to specify an appropriate time window but I dont want to do this I want to find multiples of these types of numbers in the set (i.e. there can be 3-4 directionality changes in the set).

I know how to do this in code on my own using curve fitting but figured there might be a way to do this in SQL? as the data is already in SQL this would be a bit easier than me reading it out and doing libear calculations on it. Suggestions for linear analysis are welcomed as well (hence put in the math section)

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-06-26 at 15:35:12ID22659915
Tags

trend

,

analysis

,

sql

Topics

MS SQL Server

,

Math & Science

Participating Experts
3
Points
500
Comments
17

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Correlation Function
    I trying to use the CORREL function on 36 pairs of data (3 years) and I getting results of 0.06, 0.01, -0.05 for each set of data. I thought the closer the number is to 1 or -1, the more correlation. Am I correct? I was really expect more correlation here. Please Help Neer
  2. Trend with variables
    Happy Holidays to all, I need to trend "Customer Complaints" and after reviewing the data I noticed many complaints have more than one category to a situation. I know how to use the "Trend" function, but my question is do I breakdown each complaint into t...
  3. trend line functions in vb.net
    Hello experts, I am using crystal reports with ms access to build a chart. The problem I am having is with trend lines. Is there a function I can use to take array of data values and figure out what the trend line plots should be. Basically I need a linear equation. Belo...
  4. Trend Line Query?
    I am looking to say in a report if a trend line is going up or down... as a column. So 'UP' or 'DN'. I have records to make this measurement with like this.. select value from table So how to tell if value is going up or down? One way I thought of was to check the diffe...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: aburrPosted on 2007-06-27 at 07:01:12ID: 19372303

I am a bit unsure as to your example. You mention four data elements but your example shows only two or three. I am assuming that your example is two of your four columns.
It would appear that you have one maximum at 1:15. From your data it would be hard to say that 1:00 is a minimum but the suggestion below could be modified to identify it.
Extract your data and find the difference between each adjacent point. When that difference changes sign you have your max or min. (When the sign goes from + to  you have a max, when from  to + a min.)

 

by: harfangPosted on 2007-06-29 at 22:16:10ID: 19394953

You could use variations on this theme:

SELECT M.*
FROM measurements AS M
WHERE M.Value>=All (
    Select Value
    From measurements
    Where Time Between M.Time - #0:05# and M.Time + #0:05#
    )
OR M.Value<=All (
    Select Value
    From measurements
    Where Time Between M.Time - #0:05# and M.Time + #0:05#
    )

This shows local maximas and minimas, highest or lowest in +- 5 minutes.

Cheers!
(°v°)

 

by: harfangPosted on 2007-06-30 at 09:54:31ID: 19396406

It shows all values that are higher or lower than all others in a +-5 min. range. In other words, local peaks.

\            _
 \_/\   _/   \_
       \/          \
------*------

The * is lowest in the +-5m range, so it's selected. I showed you the Access syntax, and just noticed you use MS-SQL. I think #0:05# would have to be something like convert(datetime,'0:05') or cast('0:05' as datetime); you'll have to check it out.

> I guess what I am looking for is a regression + correlation coefficient.

Regression is used for linear trends, and loosely also for other least-square fitting methods. You need some hypothesis on the function that your data should be following. For temperatures, you would have a complex time-based cyclic wave function; for exchange rates you don't have a function as it follows a random walk.

Correlation is also used for linear trends, almost never as a loose reference to remaining variance after best fit. So I'm not sure I follow.

(°v°)

 

by: PaulCaswellPosted on 2007-07-06 at 01:37:13ID: 19430268

>>I know how to do this in code on my own using curve fitting...
Try posting some pseudocode, perhaps we will be able to tell more clearly what you are looking for.

P.S. Was the 'Admin Comment' a mistake?

Paul

 

by: gregoryyoungPosted on 2007-07-06 at 02:05:09ID: 19430349

yeh sorry it defaults that way ... gotta be careful to catch it.

per curve fitting:  http://en.wikipedia.org/wiki/Gauss-Newton_algorithm would be a good example.

 

by: gregoryyoungPosted on 2007-07-06 at 02:07:10ID: 19430357

 

by: harfangPosted on 2007-07-06 at 06:30:07ID: 19431591

For any regression analysis, you need some hypothesis, namely what function are you trying to fit? In linear regression, it's a line; in logarithmic, it's a log; in exponential; it's... you get the idea.

So, what will it be?

(°v°)

 

by: harfangPosted on 2007-07-06 at 16:21:46ID: 19435689

Well, there is a misunderstanding, then. Sorry if I don't understand your question. I simply don't see how we can help you further if you don't tell us the function you are interested in.

I did provide an answer to your original question; here is my test db (Access):
http://www.ee-stuff.com/Expert/Upload/getFile.php?fid=3932

I can add the best fitting sine curve or the best fitting third degree polynomial function if you like...

(°v°)

 

by: harfangPosted on 2007-07-06 at 20:55:52ID: 19436284

> M.Value>=All which as you say is access.

In fact, it's quite plain SQL. See for example:

ALL (Transact-SQL)
http://msdn2.microsoft.com/en-us/library/ms178543.aspx

Subquery Fundamentals
http://technet.microsoft.com/en-us/library/ms189575.aspx

As for polynomial best fits, see these links:

Least Squares Fitting--Polynomial [for the theory]
http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html

Least Squares & Data Fitting [source code in java]
http://www.mste.uiuc.edu/exner/java.f/leastsquares/

(°v°)

 

by: gregoryyoungPosted on 2007-07-06 at 22:24:52ID: 19436404

again I know how to do least squares fitting in code I currently use L-BFGS and Leveberg-Marquardt

I guess this is just best done in code.

 

by: harfangPosted on 2007-07-06 at 22:45:31ID: 19436439

Yes, I think so too. I have done various regressions or moving statistics as a standalone query, but not regression of functions requiring more than two factors.

And I now understand what you were looking for, but I have never seen anything like it for polynomes.

(°v°)

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...