linear-regression

Are there any Linear Regression Function in SQL Server?

Are there any Linear Regression Function in SQL Server 2005/2008, similar to the the Linear Regression functions in Oracle ? ...

Linear Regression and Java Dates

I am trying to find the linear trend line for a set of data. The set contains pairs of dates (x values) and scores (y values). I am using a version of this code as the basis of my algorithm. The results I am getting are off by a few orders of magnitude. I assume that there is some problem with round off error or overflow because I am us...

Graphing perpendicular offsets in a least squares regression plot in R

I'm interested in making a plot with a least squares regression line and line segments connecting the datapoints to the regression line as illustrated here in the graphic called perpendicular offsets: http://mathworld.wolfram.com/LeastSquaresFitting.html I have the plot and regression line done here: ## Dataset from http://www.apsnet....

Conditionally colour data points outside of confidence bands in R

I need to colour datapoints that are outside of the the confidence bands on the plot below differently from those within the bands. Should I add a separate column to my dataset to record whether the data points are within the confidence bands? Can you provide an example please? Example dataset: ## Dataset from http://www.apsnet.org...

Optimal two variable linear regression calculation

Problem Am looking to apply the y = mx + b equation (where m is SLOPE, b is INTERCEPT) to a data set, which is retrieved as shown in the SQL code. The values from the (MySQL) query are: SLOPE = 0.0276653965651912 INTERCEPT = -57.2338357550468 SQL Code SELECT ((sum(t.YEAR) * sum(t.AMOUNT)) - (count(1) * sum(t.YEAR * t.AMOUNT))) / ...

Efficient Multiple Linear Regression in C# / .Net

Does anyone know of an efficient way to do multiple linear regression in C#, where the number of simultaneous equations may be in the 1000's (with 3 or 4 different inputs). After reading this article on multiple linear regression I tried implementing it with a matrix equation: Matrix y = new Matrix( new double[,]{{745}, ...

In R draw two lines, with slopes double and half the value of the best fit line

I have data with a best fit line draw. I need to draw two other lines. One needs to have double the slope and the other need to have half the slope. Later I will use the region to differentially color points outside it as per: http://stackoverflow.com/questions/2687212/conditionally-colour-data-points-outside-of-confidence-bands-in-r ...

Converting Numpy Lstsq residual value to R^2

I am performing a least squares regression as below (univariate). I would like to express the significance of the result in terms of R^2. Numpy returns a value of unscaled residual, what would be a sensible way of normalizing this. field_clean,back_clean = rid_zeros(backscatter,field_data) num_vals = len(field_clean) x = field_clean[:,r...

John Tukey "median median" (or "resistant line") statistical test for R and linear regression

Hello guy, I'm searching the John Tukey algorithm which compute a "resistant line" or "median-median line" on my linear regression with R. A student on a mailling list explain this algorithm in these terms : "The way it's calculated is to divide the data into three groups, find the x-median and y-median values (called the s...

Measuring rectangles at odd angles with a low resolution input matrix (Linear regression classification?)

I'm trying to solve the following problem: Given an input of, say, 0000000000000000 0011111111110000 0011111111110000 0011111111110000 0000000000000000 0000000111111110 0000000111111110 0000000000000000 I need to find the width and height of all rectangles in the field. The input is actually a single column at a time (think like a sc...

Kalman filter for car's tracking path

Hi, I am having a set of Points like Point(x,y). After the car gone through so many ways in the same road it is almost messing the resulting map. I heard that kalman filter can make a sigle path from the available paths. Can any body say, how to make it. I am not from computer science. So please explain me about that concept and those ma...

How to do exponential and logarithmic curve fitting in Python? I found only polynomial fitting.

Hi, I have a set of data and I want to compare which line describes it the best (polynomes of different orders, exponential or logarithmic). I use Python and Numpy and for polynomial fitting there is a function polyfit(). But I found no such functions for exponential and logarithmic fitting. Are there any? Or how to solve it otherwise...

How to draw the best fit line with c#.net

Hi everyone, I have been trying to do a regression analysis on some data points with c#.net. Can anyone suggest some references to me to be able to plot the data points as well as the best fit line on one chart with c#.net? ...

Making predictions from a CV

I have a database with many CVs, including structured data of the gender, age, address, number of years of education, and many other parameters of each person. For about 10% of the sample, I also have additional data about a certain action they've made at some point in time. For instance, that Jane took a home loan in July 1998 or that...

Java or C equivalent of MATLAB's robustfit

MATLAB has a magnificent robustfit function that solves the problem of excluding outliers with linear regression fitting. Is there anything similar written in Java or C (or in language X that could be adopted)? ...

How to force R to use a specified factor level as reference in a regression?

Somehow I can´t find it in my notes... nor do find the obivous on the net. How can I tell R to use a certain level as reference if I use dummy explanatories in a regression? It´s just using some level by default. lm(x ~ y + as.factor(b)) with b {0,1,2,3,4} . Let´s say I want to use 3 instead of the zero that is used by R. Thx in a...

Linear Regression with Python numpy

Hey all- I'm trying to make a simple linear regression function but continue to encounter a numpy.linalg.linalg.LinAlgError: Singular matrix error Existing function (with debug): def makeLLS(inputData, targetData): print "In makeLLS:" print " Shape inputData:",inputData.shape print " Shape targetData:",targetData.s...

How to best approach the problem of trying to determine the form of an unknown function

I have a set of variables X, Y, ..., Z. My job is to design a function that takes this set of variables and yields an integer. I have a fitness function to test this against. My first stab at the problem is to assume that I can model f to be a linear function: f(X, Y, ..., Z) -> aX + bY ... cZ My first idea was to use either PSO (Par...

Using a smoother with the L Method to determine the number of K-Means clusters

Has anyone tried to apply a smoother to the evaluation metric before applying the L-method to determine the number of k-means clusters in a dataset? If so, did it improve the results? Or allow a lower number of k-means trials and hence much greater increase in speed? Which smoothing algorithm/method did you use? The "L-Method" is deta...