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
33
votes
1 answer

Distinguishing overfitting vs good prediction

These are questions on how to calculate & reduce overfitting in machine learning. I think many new to machine learning will have the same questions, so I tried to be clear with my examples and questions in hope that answers here can help others. I…
Zach
  • 4,624
  • 13
  • 43
  • 60
33
votes
5 answers

Extract standard errors from lm object

We got a lm object from and want to extract the standard error lm_aaa <- lm(aaa ~ x + y + z) I know the function summary, names and coefficients. However, summary seems to be the only way to manually access the standard error. Have you any idea how…
Fabian Stolz
  • 1,935
  • 7
  • 27
  • 30
32
votes
3 answers

How to add interaction term in Python sklearn

If I have independent variables [x1, x2, x3] If I fit linear regression in sklearn it will give me something like this: y = a*x1 + b*x2 + c*x3 + intercept Polynomial regression with poly =2 will give me something like y = a*x1^2 + b*x1*x2…
Dylan
  • 915
  • 3
  • 13
  • 20
32
votes
2 answers

tensorflow deep neural network for regression always predict same results in one batch

I use a tensorflow to implement a simple multi-layer perceptron for regression. The code is modified from standard mnist classifier, that I only changed the output cost to MSE (use tf.reduce_mean(tf.square(pred-y))), and some input, output size…
Sufeng Niu
  • 629
  • 1
  • 5
  • 9
32
votes
2 answers

How does predict.lm() compute confidence interval and prediction interval?

I ran a regression: CopierDataRegression <- lm(V1~V2, data=CopierData1) and my task was to obtain a 90% confidence interval for the mean response given V2=6 and 90% prediction interval when V2=6. I used the following code: X6 <-…
Mitty
  • 475
  • 1
  • 5
  • 9
32
votes
3 answers

Confidence interval for LOWESS in Python

How would I calculate the confidence intervals for a LOWESS regression in Python? I would like to add these as a shaded region to the LOESS plot created with the following code (other packages than statsmodels are fine as well). import numpy as…
pir
  • 5,513
  • 12
  • 63
  • 101
32
votes
7 answers

Stepwise Regression in Python

How to perform stepwise regression in python? There are methods for OLS in SCIPY but I am not able to do stepwise. Any help in this regard would be a great help. Thanks. Edit: I am trying to build a linear regression model. I have 5 independent…
user2174063
  • 321
  • 1
  • 3
  • 4
31
votes
7 answers

Stepwise regression using p-values to drop variables with nonsignificant p-values

I want to perform a stepwise linear Regression using p-values as a selection criterion, e.g.: at each step dropping variables that have the highest i.e. the most insignificant p-values, stopping when all values are significant defined by some…
DainisZ
  • 465
  • 1
  • 7
  • 8
30
votes
2 answers

lme4::lmer reports "fixed-effect model matrix is rank deficient", do I need a fix and how to?

I am trying to run a mixed-effects model that predicts F2_difference with the rest of the columns as predictors, but I get an error message that says fixed-effect model matrix is rank deficient so dropping 7 columns / coefficients. From this…
Lisa
  • 909
  • 2
  • 13
  • 31
30
votes
2 answers

Python sci-kit learn (metrics): difference between r2_score and explained_variance_score?

I noticed that that r2_score and explained_variance_score are both build-in sklearn.metrics methods for regression problems. I was always under the impression that r2_score is the percent variance explained by the model. How is it different from…
monkeybiz7
  • 4,898
  • 5
  • 21
  • 35
30
votes
2 answers

Working with neuralnet in R for the first time: get "requires numeric/complex matrix/vector arguments"

I'm in the process of attempting to learn to work with neural networks in R. As a learning problem, I've been using the following problem over at Kaggle: Don't worry, this problem is specifically designed for people to learn with, there's no reward…
user2548029
  • 425
  • 2
  • 6
  • 10
29
votes
3 answers

Activation function for output layer for regression models in Neural Networks

I have been experimenting with neural networks these days. I have come across a general question regarding the activation function to use. This might be a well known fact to but I couldn't understand properly. A lot of the examples and papers I have…
user7400738
  • 443
  • 2
  • 6
  • 18
29
votes
2 answers

Fit a non-linear function to data/observations with pyMCMC/pyMC

I am trying to fit some data with a Gaussian (and more complex) function(s). I have created a small example below. My first question is, am I doing it right? My second question is, how do I add an error in the x-direction, i.e. in the x-position…
Magnus Persson
  • 823
  • 1
  • 7
  • 22
28
votes
3 answers

What function defines accuracy in Keras when the loss is mean squared error (MSE)?

How is Accuracy defined when the loss function is mean square error? Is it mean absolute percentage error? The model I use has output activation linear and is compiled with loss= mean_squared_error model.add(Dense(1)) model.add(Activation('linear'))…
28
votes
3 answers

How is Elastic Net used?

This is a beginner question on regularization with regression. Most information about Elastic Net and Lasso Regression online replicates the information from Wikipedia or the original 2005 paper by Zou and Hastie (Regularization and variable…
Zach
  • 4,624
  • 13
  • 43
  • 60