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
-1
votes
2 answers

Least square method doesn't work as expected, or does it?

I tried to improve trilateration accuracy by doing least square method. For initial estimation, I get the average value of the cluster points. This value is then increased until the distance to the next estimation is small enough. The increment…
springrolls
  • 1,331
  • 1
  • 14
  • 40
-1
votes
1 answer

Method to accept 10 dimensional data

I have this least squares method, but I need it to obtain 10 dimensional data. This is from a practice text I'm learning from. I came up with this method for a two-dimensional data set. Now I need to have it work for a 10 dimensional one, but I'm…
Aloma85
  • 63
  • 1
  • 1
  • 6
-1
votes
1 answer

TypeError: fun() takes 1 positional argument but 2 were given error in sciply.optimize.curve_fit

I am attempting to use scipy.optimize.curve_fit but appear to be coming across some issues. Here is my code: import numpy as np import matplotlib.pyplot as plt import os os.chdir('C:/Users/Sams…
samman
  • 559
  • 10
  • 29
-1
votes
2 answers

Find the nearest point to a group of 3D lines

This problem has had me stumped for days. I have a group of lines formed from some data that produces 3D lines of the form: P = a + dt Where a is a position vector and d is the unit direction vector. So basically I want to find the nearest point to…
jameslfc19
  • 1,084
  • 1
  • 10
  • 14
-1
votes
2 answers

C Program forLeast Square Regression Line and Errors

I wanted to create a program to calculate the regression line of some given data, along with the errors, so I can use in my university assignments. This is the following program: #include #include int main(void) { int i,n,N; …
-1
votes
1 answer

Least Squares Fit on Line in polar representation

I'm working on the basis of a robot localization system, and truth be told, I'm not sure if this is a maths or an implementation issue. I'm trying to fit a line to a set of polar coordinates using Least Square Fitting. The line is represented in…
-1
votes
2 answers

Least squares assuming functional form of the solution

I am trying to solve the following least squares problem: b(alpha)=A(alpha,beta)x(beta) I am trying to use an alternative approach, which is to assume the functional form of x(beta) through the use of tunable parameters, say x(beta, a, c). How can I…
Andrea
  • 13
  • 2
-1
votes
1 answer

QR factorization programming in Matlab

I'm trying to build a program to compute the error of the QR method with data points compared to the actual solution. I am already stuck on the basic first draft since the matrix dimensions do not agree and I do not know how to fix this in a way I…
p.late
  • 31
  • 6
-1
votes
1 answer

How to get weights matrix with R with plsr?

I´m using the plsr package in R, with the SIMPLS method, but this didn´t give me the weight matrix W, somebody can help me, and tell me how to create or get this W matrix ? This is part of my code: plsr(Y ~ X, ncomp, validation = "CV", dframe = T,…
-1
votes
1 answer

Least Absolute Deviation function

I'm trying to estimate LAD regression, but it gives my the message: "false convergence (8)". What does it mean and why nlminb estimators are equal to lm estimators? Sample generation step dgp=function(){ x=c(sample(0:9,10),sample(0:9,10)); …
Art
  • 43
  • 8
-1
votes
1 answer

getting least squares and residuals by comparing data

I have a set of simulated data (df1) I've generated. I have a second set of data (df2) that I would like to compare and see if df1 can explain the observations of df2. Ideally I'd like to plot the residuals and calculate least squares but I am not…
user3141121
  • 480
  • 3
  • 8
  • 17
-1
votes
1 answer

FFT frequency measurement VS measuring signal's period with timer

Hello! I am working around a project, in which I have to measure a frequency of the signal coming to STM32 microprocessor. The frequency is about 2210 Hz. I have done it by measuring period of square wave (sine wave passed through comparator) with…
-2
votes
1 answer

how to implement least square polynomial with no built in methods using python?

currently running into a problem solving this. The objective of the exercise given is to find a polynom of certian degree (the degree is given) from a dataset of points (that can be noist) and to best fit it using least sqaure method. I don't…
-2
votes
1 answer

Passing data frame data through function

# mtcars <- view(mtcars) sq_sum_diff <- function(d, w) { # d, and c are columns draft and weight a <- d^2 b <- w^2 p <- sqrt(sum(a^2 - b^2) return(p) } What I want returned is a df with the difference in squares between the two.
Toy L
  • 55
  • 6
-2
votes
1 answer

Fit a Logit/Probit regression model in R using Maximum Likelihood

A simple question here: I'd like to know if there is any function in R that can fit a logit/probit regression model using maximum likelihood method? Currently, I'm using OLS method given by function glm (I hope it does use OLS method)... I read…
zy.G
  • 43
  • 1
  • 10
1 2 3
67
68