least-squares

Tools for sparse least squares regression

Hi, I want to do sparse high dimensional (a few thousand features) least squares regression with a few hundred thousands of examples. I'm happy to use non fancy optimisation - stochastic gradient descent is fine. Does anyone know of any software already implemented for doing this, so I don't have to write to my own? Kind regards. ...

How do I use the least squares approximation in MATLAB?

For a homework assignment in linear algebra, I have solved the following equation using MATLAB's \ operator (which is the recommended way of doing it): A = [0.2 0.25; 0.4 0.5; 0.4 0.25]; y = [0.9 1.7 1.2]'; x = A \ y which produces the following answer: x = 1.7000 2.0800 For the next part of assignment, I'm supposed to solve the ...

Least squares optimal scaling

Hi, I have two waveforms which are linked by a numerical factor. I need to use optimal scaling (least squares) between the two waveforms to calculate this factor in Matlab. Unfortunately I have no idea how to do this. The two wave forms are seismic signals related by the velocity of the seismic waves, which I'm trying to calculate. Any ...

least squares equation for a vertical line

Given the following 2d points: 213 106.8 214 189 214 293.4 213 324 223 414 I want to find an equation for the least squares vertical axis line that runs through them. My plan is to get a line equation so I can test subsequent points for their distances to that least squares line. Thanks ...

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....

How can I calculate a trend line in PHP?

So I've read the two related questions for calculating a trend line for a graph, but I'm still lost. I have an array of xy coordinates, and I want to come up with another array of xy coordinates (can be fewer coordinates) that represent a logarithmic trend line using PHP. I'm passing these arrays to javascript to plot graphs on the...

Plotting data and doing a least squares regression with cosines in java

I have data I would like to plot, and more importantly, do a least squares regression on using cosines (instead of using polynomials): http://imgur.com/AkEaE.png Any recommendations? Thanks. ...

Calculating the null space of a matrix

I'm attempting to solve a set of equations of the form Ax = 0. A is known 6x6 matrix and I've written the below code using SVD to get the vector x which works to a certain extent. The answer is approximately correct but not good enough to be useful to me, how can I improve the precision of the calculation? Lowering eps below 1.e-4 causes...

finding constants of equation by LSQ

Hello, I have the following equation: P = c0 + c1 * T + c2 * T^2 + c3 * H + c4 * H^2 + c5 * T * H and I have hundreds of data for P, T and H How can I find the constants c0,c1 ......c5 by least square method in MATLAB 7.0 Thanks any help is highly appreciated best regards ...

Rating the straightness of a line

I have a data set that defines a set of points on a 2-dimensional Cartesian plane. Theoretically, those points should form a line, but that line may be perfectly horizontal, perfectly vertical, and anything in between. I would like to design an algorithm that rates the 'straightness' of that line. For example, the following data sets...

Least squares fit routine for timescaling in Matlab

Dear all, I would like to know if there is a least squares routine in Matlab to scale a template signal to a measured signal in time. Let's say my template is a signal of approx. 1 second, but the corresponding part in the measurement is 1.2 seconds. Now I want to scale my template to be 1.2 seconds long as well. Of course it is possibl...

How can I solve a system of linear equations in Excel

Hi, I am having some trouble finding a solution for a system of equations using excel. The system is of the form Ax=b, with A a matrix and x and b vectors. Obviously, the goal is to find x. The system does not necessarily have the same number of equations and unknowns. An exact solution is not always possible. Therefor I want to find t...

Two stage least square in R

Hi, I want to run a two stage probit least square regression in R. Does anyone know how to do this? Is there any package out there? I know it's possible to do it using Stata, so I imagine it's possible to do it with R. Thanks in advance, Manoel Galdino ...