Questions tagged [regression]

Regression analysis is a collection of statistical techniques for modeling and predicting one or multiple variables based on other data.

Wiki

Regression is a common applied statistical technique and a cornerstone of machine learning. Various algorithms and software packages can be used to fit and use regression models.

In other words, regression is a statistical measure that attempts to determine the strength of the relationship between one dependent variable (usually denoted by Y) and a series of other changing variables (known as independent variables). Typically the dependent variables are modeled with probability distributions whose parameters are assumed to vary (deterministically) with the independent variables.

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 and machine learning.

Read more:

9532 questions
10
votes
1 answer

Difference in Differences in Python + Pandas

I'm trying to perform a Difference in Differences (with panel data and fixed effects) analysis using Python and Pandas. I have no background in Economics and I'm just trying to filter the data and run the method that I was told to. However, as far…
pceccon
  • 9,379
  • 26
  • 82
  • 158
10
votes
2 answers

Ratio of polynomials approximation

I am trying to fit a polynomial to my dataset, which looks like that (full dataset is at the end of the post): The theory predicts that the formulation of the curve is: which looks like this (for x between 0 and 1): When I try to make a linear…
marco11
  • 235
  • 2
  • 8
10
votes
2 answers

lm() Regression with interactions for an entire dataframe

I know there is a shortcut in Rto run an lm()regression on all a dataframe like this : reg<-lm(y~.,data=df) With df having explanatory variables x1, x2, ... x5, so it is the same as writing reg<-lm(y~x1+x2+x3+x4+x5,data=df) But this doesn't…
etienne
  • 3,648
  • 4
  • 23
  • 37
10
votes
1 answer

how can I do a maximum likelihood regression using scipy.optimize.minimize

How can I do a maximum likelihood regression using scipy.optimize.minimize? I specifically want to use the minimize function here, because I have a complex model and need to add some constraints. I am currently trying a simple example using the…
user14241
  • 727
  • 1
  • 8
  • 27
10
votes
1 answer

Ordering of points in R lines plot

I want to add a fitted line of a quadratic fit to a scatteprlot, but the ordering of the points is somehow messed up. attach(mtcars) plot(hp, mpg) fit <- lm(mpg ~ hp + I(hp^2)) summary(fit) res <- data.frame(cbind(mpg, fitted(fit), hp)) with(res,…
phildeutsch
  • 683
  • 1
  • 8
  • 18
10
votes
1 answer

Scaling of target causes Scikit-learn SVM regression to break down

When training a SVM regression it is usually advisable to scale the input features before training. But how about scaling of the targets? Usually this is not considered necessary, and I do not see a good reason why it should be necessary. However in…
user1774143
  • 192
  • 1
  • 7
10
votes
3 answers

How to return predicted values, residuals, R square from lm()?

this piece of code will return coefficients :intercept , slop1 , slop2 set.seed(1) n=10 y=rnorm(n) x1=rnorm(n) x2=rnorm(n) lm.ft=function(y,x1,x2) return(lm(y~x1+x2)$coef) res=list(); for(i in 1:n){ x1.bar=x1-x1[i] x2.bar=x2-x2[i] …
sacvf
  • 2,463
  • 5
  • 36
  • 54
10
votes
3 answers

How to put a complicated equation into a R formula?

We have the diameter of trees as the predictor and tree height as the dependent variable. A number of different equations exist for this kind of data and we try to model some of them and compare the results. However, we we can't figure out how to…
donodarazao
  • 2,773
  • 4
  • 26
  • 26
10
votes
2 answers

How to write R formula for multivariate response?

In R I want to do some regression on multivariate response on all predictors, for univariate response, I know the formula is like y~., this is to use all predictors to regress y, what if now I face 100 response, I can not type 100 yi like …
user974270
  • 627
  • 3
  • 8
  • 18
9
votes
2 answers

How to vectorize equations?

I'm trying to implement the Softmax regression algorithm to solve the K-classifier problem after watching Professor Andrew Ng's lectures on GLM. I thought I understood everything he was saying until it finally came to writing the code to implement…
oort
  • 1,840
  • 2
  • 20
  • 29
9
votes
2 answers

When using Gnuplot, how can the equation of a line be printed in the line title?

I have used Gnuplot to plot my data, along with a linear regression line. Currently, the 'title' of this line, which has its equation calculated by Gnuplot, is just "f(x)". However, I would like the title to be the equation of the regression line,…
JPK
  • 143
  • 1
  • 1
  • 7
9
votes
3 answers

Visual Comparison of Regression & PCA

I'm trying to perfect a method for comparing regression and PCA, inspired by the blog Cerebral Mastication which has also has been discussed from a different angle on SO. Before I forget, many thanks to JD Long and Josh Ulrich for much of the core…
Bryan Hanson
  • 6,055
  • 4
  • 41
  • 78
9
votes
2 answers

How to check if sklearn model is classifier or regressor

Is there a simple way to check if a model instance solves a classification or regression task in the scikit-learn library?
9
votes
1 answer

How to find coefficients of model in XGBoost Regressor?

In XGBoost Regression to predict prices, How to get coefficients, intercepts of model? How to get summary of model like we get in Statsmodel for Linear regression? See below code from xgboost import XGBRegressor # fit model no training data model =…
9
votes
3 answers

What is causing this error? Coefficients not defined because of singularities

I'm trying to find a model for my data but I get the message "Coefficients: (3 not defined because of singularities)" These occur for winter, large and high_flow I found…
Laura
  • 177
  • 1
  • 12