Questions tagged [least-squares]

Refers to a general estimation technique that selects the parameter value to minimize the squared difference between two quantities, such as the observed value of a variable, and the expected value of that observation conditioned on the parameter value. Questions about the theory behind least-squares should utilize the Cross Validated (https://stats.stackexchange.com/questions) Stack Exchange site.

Overview

From the "Least squares" article on Wikipedia:

The method of least squares is a standard approach to the approximate solution of overdetermined systems, i.e., sets of equations in which there are more equations than unknowns. "Least squares" means that the overall solution minimizes the sum of the squares of the errors made in the results of every single equation.

Least squares problems fall into two categories: linear or ordinary least squares and non-linear least squares, depending on whether or not the residuals are linear in all unknowns. The linear least-squares problem occurs in statistical regression analysis; it has a closed-form solution. A closed-form solution (or closed-form expression) is any formula that can be evaluated in a finite number of standard operations. The non-linear problem has no closed-form solution and is usually solved by iterative refinement; at each iteration the system is approximated by a linear one, and thus the core calculation is similar in both cases.

Other References

Least squares methods are treated in many introductory statistics resources and textbooks, but there are also advanced resources dedicated only to the subject, for example:

Tag usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

1013 questions
0
votes
2 answers

How to get the predicted values in training data set for Least Squares Support Vector Regression

I would like to make a prediction by using Least Squares Support Vector Machine for Regression, which is proposed by Suykens et al. I am using LS-SVMlab, which you can find the MATLAB toolbox here. Let's consider I have an independent variable X and…
ARAT
  • 884
  • 1
  • 14
  • 35
0
votes
1 answer

How to run OLS Regression by using SPSS?

I need to conduct OLS regression by using SPSS for my thesis. I was wondering what are the steps in conducting OLS regression? (1) SPSS - Analyze - Regression - Linear ? Is this correct? (2) Where to put control variable? and what are the steps to…
user24877
  • 1
  • 1
  • 1
0
votes
1 answer

fitting data with an integral equation in python

I have some data that I am trying to fit with a model that includes and definite integral equation. My strategy was to use the optimize.leastsq and integrate.quad, I keep getting a type error: "only length-1 arrays can be converted to Python…
0
votes
1 answer

NonLinearModelFit in scipy (leastsq) with weightings

I have been using mathematica recently to mess around with my data. I have a method of calculating an x,y coordinate from 4 or more distance measurements coming from static receivers (also x,y coords). The function I use to do this most effectively…
0
votes
1 answer

Least squares interpolation in Octave

I did a physics experiment, and got the following data: R=[2.91 2.19 1.76 1.43 1.20 1.01 0.88 0.77 0.67 0.6 0.52 0.46 0.41 0.37]; t=[35:5:100]; T=t+273.15; Now I need to do a least squares interpolation for the formula ln R = f(1 / T). I tried…
Cristi Mocanu
  • 205
  • 1
  • 3
  • 9
0
votes
1 answer

histogram$breaks works for data, histogram$mids gives error

I'm wondering if this is a bug. I have the following piece of code: h2 <- hist(c(rep(65, times=5), rep(25, times=5), rep(35, times=10), rep(45, times=4))) model2 = nls(formula = log(counts[1:5]) ~a+log(mids[1:5])*gamma,…
jbssm
  • 6,861
  • 13
  • 54
  • 81
0
votes
2 answers

Fitting an inverse parabola. Cant reach least squares analytical expression

I am trying to fit some points to an inverse parabola, in the form of F(x)=1/(ax^2+bx+c). My objective is to program a function in c++ that would take a set of 10-30 points and fit them to the inverse parabola. I started trying to get an analytical…
Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
0
votes
1 answer

Matlab non-linear, multi-parameter curve fitting issue

I am trying to implement a routine for fitting electrophoretic data from my experiments. The aim is to derive kinetic parameters for the interaction of biomoecules from the relative areas of peaks in the electropherogram, based on the areas of the…
Kris
  • 2,100
  • 5
  • 31
  • 50
0
votes
1 answer

Linear least squares fitting

DF times a b s ex 1 0 59 140 1e-4 1 2 20 59 140 1e-4 0 3 40 59 140 1e-4 0 4 60 59 140 1e-4 2 5 120 59 140 1e-4 20 6 180 59 140 1e-4 30 7 240 59 140 1e-4 31 8 360 59 140 1e-4 37 9 0 60 140 1e-4 0 10 20 60 140 1e-4 0 11 40 60 140…
Doug
  • 597
  • 2
  • 7
  • 22
0
votes
1 answer

How to evaluate predictions from incomplete data, where not all data is incomplete

I am using Non-negative Matrix Factorization and Non-negative Least Squares for predictions, and I want to evaluate how good the predictions are depending on the amount of data given. For example the original Data was original = [1, 1, 0, 1, 1,…
0
votes
1 answer

In Scipy LeastSq - How to add the penalty term

If the object function is How to code it in python? I've already coded the normal one: import numpy as np import scipy as sp from scipy.optimize import leastsq import pylab as pl m = 9 #the degree of the polynomial …
lhdgriver
  • 315
  • 1
  • 3
  • 17
0
votes
3 answers

levenberg marquardt curve fitting MATLAB

enter image description hereI don't know how choose the lb and ub for lsqcurvefit in MATLAB , as well as x0, to fit my function to data, I mean I have some output but they are not correct, Here is my data: xdata=…
user1331843
  • 123
  • 1
  • 6
  • 15
0
votes
1 answer

Using ordinary least squares (OLS)

I have the equation A * x = b sizes of A is matrix sized n x m, x is m x 1 and b is n x 1. A has more rows than columns (n < m). My unknown is A and since n != m, A does not have an inverse. My knowns are the two vectors x and b. Basically, I want…
bushbo
  • 53
  • 1
  • 6
0
votes
2 answers

Kalman, least squares, or

In an effort to help people understand what i the question is that i am asking, i have chosen to reword it entirely. I hope this clears it up. i am collecting gps data (lat/long) at a 1 second rate. With understanding that this data may not be…
Jason
  • 2,147
  • 6
  • 32
  • 40
-1
votes
1 answer

Is there any function for calculating k and b coefficients for linear regression model with only one independent variable?

I know I can just write needed method by myself but there must be a function for this because this problem is so common as heck. If somebody does't understand what I am talking about take a look at the following formula {Image must be here} For…