Questions tagged [linear-regression]

for issues related to linear regression modelling approach

Linear Regression is a formalization of relationships between variables in the form of mathematical equations. It describes how one or more random variables are related to one or more other variables. Here the variables are not deterministically but stochastically related.

Example

Height and age are probabilistically distributed over humans. They are stochastically related; when you know that a person is of age 30, this influences the chance of this person being 4 feet tall. When you know that a person is of age 13, this influences the chance of this person being 6 feet tall.

Model 1

heighti = b0 + b1agei + εi, where b0 is the intercept, b1 is a parameter that age is multiplied by to get a prediction of height, ε is the error term, and i is the subject

Model 2

heighti = b0 + b1agei + b2sexi + εi, where the variable sex is dichotomous

In linear regression, user data X is modelled using linear functions Y, and unknown model parameters W are estimated or learned from the data. E.g., a linear regression model for a k-dimensional user data can be represented as :

Y = w1 x1 + w2 x2 + ... + wk xk

Reading Statistical Modeling: The Two Cultures http://projecteuclid.org/download/pdf_1/euclid.ss/1009213726

In scientific software for statistical computing and graphics, function lm (see ) implements linear regression.

6517 questions
2
votes
4 answers

Negative Coefficients in linear regression

I have a data set consisting of about 10 independent variables. (1000 rows x 10 columns). All of which i know will have a positive contribution to my target variable. Once i run a multivariate linear regression on this, i have negative…
2
votes
2 answers

Is there an equivalent function for anova.lm() in Java?

I am comparing two linear models in R with Anova, and I would like to do the same thing in Java. To simplify it, I took the example code from…
Niek de Klein
  • 8,524
  • 20
  • 72
  • 143
2
votes
1 answer

What is target in Python's sklearn coef_ output?

When I do ridge regression using sklearn in Python, the coef_ output gives me a 2D array. According to the documentation it is (n_targets, n_features). I understand that features are my coefficients. However, I am not sure what targets are. What is…
2
votes
1 answer

Fminsearch Matlab (Non Linear Regression )

Can anyone explain to me how I can apply non linear regression to this equation t find out K using the matlab command window. I = 10^-9(exp(38.68V/k)-1). Screenshot of Equation I have data values as follows: Voltage := [0, 0.1, 0.2, 0.3, 0.4, 0.5,…
Saavin
  • 59
  • 8
2
votes
2 answers

How should I incorporate State N as a weight variable?

My data structure is: State N Var1 Var2 Alabama 23 54 42 Alaska 4 53 53 Arizona 53 75 65 Var1 and Var2 are aggregated…
KubiK888
  • 4,377
  • 14
  • 61
  • 115
2
votes
1 answer

Multiple linear regression with numpy

I want to calculate multiple linear regression with numpy. I need to regress my dependent variable (y) against several independent variables (x1, x2, x3, etc.). For example, with this data: print 'y x1 x2 x3 x4 x5 x6…
xeon123
  • 819
  • 1
  • 10
  • 25
2
votes
3 answers

Loop linear regression and saving coefficients

This is part of the dataset (named "ME1") I'm using (all variables are numeric): Year AgeR rateM 1 1751 -1.0 0.241104596 2 1751 -0.9 0.036093609 3 1751 -0.8 0.011623734 4 1751 -0.7 0.006670552 5 1751 -0.6 0.006610552 6 1751 -0.5…
DanielUp
  • 23
  • 1
  • 8
2
votes
0 answers

How do I create Interaction Terms in a Linear Regression Model in R that Uses a transformed response variable?

I've created a linear regression model in R that contains the following interaction terms. lm.data <- lm(sharer_prob ~ sympathy + trust + fear + greed, na.action=NULL, data=data) Greed, Sympathy, Trust and fear are independent variables with…
Larry John
  • 41
  • 3
2
votes
1 answer

How can I constrain weights of linear classifier?

There are a number of neurons and we know their firing rates on -3s, -2s, -1s, like Neuron index: 1 2 3 4 Firing rata 0s: 1 1 -1 1 -1s: -1 -1 0 -1 -2s: 0…
이희승
  • 23
  • 3
2
votes
1 answer

Anomaly in test data-set for carrying out multivariate regression in python

I have a dataset (train, test and result) which consists of 32 Independent Variables and 5 Dependent Variables. To get a grasp of the data, I am trying to build a simple linear regression model on it and test its performance. But all the rows of…
Shubhanshu
  • 975
  • 1
  • 8
  • 21
2
votes
1 answer

How can I add a linear regression in a for loop or s/lapply?

I’ve been trying (for several days now) to “automate” several linear regressions that use the same x axis data (”Methane”) but the y axis varies (days 1, 10, 16, etc.). From each regression, I want to extract the Intercept and Slope and write them…
2
votes
1 answer

How to visualize (make plot) of regression output against categorical input variable?

I am doing linear regression with multiple variables. In my data I have n = 143 features and m = 13000 training examples. Some of my features are continuous (ordinal) variables (area, year, number of rooms). But I also have categorical variables…
2
votes
0 answers

SGD does not converge if #samples < #features

I'm trying to implement a stochastic gradient descent and it works, as long as the number of sampes are greater than the number of features, otherwise, the loss diverges as seen in the figures, in which i compare the loss to the scikit.learn…
TobSta
  • 766
  • 2
  • 10
  • 29
2
votes
1 answer

using apache spark for temperature prediction

I am a newbie with respect to spark and have just started some serious work with it. We are building a platform where we are receiving temperature data from stations at a particular timestamp. So the data is getting posted to RabbitMQ as a csv…
Raveesh Sharma
  • 1,486
  • 5
  • 21
  • 38
2
votes
1 answer

change colors of multiple fitlm lines

I'm trying to display two linear models and their confidence intervals (made with fitlm) to a figure I created in MatLab. LM1 = fitlm(1:5, TL_martin); LM = fitlm(our_TL, our_data) plot(LM,'Color','b'); plot(LM1,'Color','r'); I can plot these…
Lauren
  • 23
  • 6