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

Sklearn | LinearRegression | Fit

I'm having a few issues with LinearRegression algorithm in Scikit Learn - I have trawled through the forums and Googled a lot, but for some reason, I haven't managed to bypass the error. I am using Python 3.5 Below is what I've attempted, but keep…
AdrianC
  • 383
  • 4
  • 18
2
votes
0 answers

I am trying to check the Multicollinearity between the variables using vif() in R to improve my Linear Regression Model

#install.packages("car") library(car) model1<-lm(Temp ~ . , data = climate) # all the independent variables are numeric. summary(model1) # Proper output vif(model1) I get an error and a warning when I execute the the vif(model1). Error in…
2
votes
2 answers

R Linear Regression - Trouble setting values

I am new to R and I need help getting some values from my data set. The information is dollar amounts per each year for a list of cities. I'm trying to setup my values so that I can run a linear regression model on the entire dataset names…
Delbudge
  • 59
  • 4
2
votes
1 answer

Custom tuning grid caret package in R

I have a linear model with a weighting factor that weights the most recent observations. The weights use a tuning parameter that I would like to optimize using a tuning grid. A simple example is…
MidnightDataGeek
  • 938
  • 12
  • 21
2
votes
1 answer

java.lang.IllegalArgumentException: Field "label" does not exist using SparkML

I am using Spark with Scala for time series analysis. I have a dataset taken from a Cassandra database that looks like this: scala> train.printSchema root |-- timestamp: timestamp (nullable = true) |-- vx: double (nullable = true) |-- speed:…
2
votes
3 answers

Ignore zeros (or blanks) in Excel LINEST function with multiple independent variables

I would like to run a multiple (!) factor analysis through linest, again excluding all rows that contain zeros (or if that’s easier blank cells). Is there a way I can do this using the linest functions? I tried using the following formular, which I…
Julian
  • 21
  • 1
  • 1
  • 2
2
votes
1 answer

Is there a way to export the linear regression summaries from R as an image? I need to export the summaries as .jpeg or as .png

I am trying to export the linear regression summary to a powerpoint slide by R using the "R2PPT" package. But there is no option to export ".txt" file into powerpoint, so only "jpeg" files will do. Can someone please help me with this?
Syed Muzaffar
  • 33
  • 1
  • 4
2
votes
2 answers

Reading coef value from OLS regression results

I use pandas and statsmodels to do linear regression. However, i can't find any possible way to read the results. the results are displayed but i need to do some further calculations using coef values. is there any possible way to store coef values…
HussainBiedouh
  • 99
  • 2
  • 11
2
votes
1 answer

R: Coeftest causes error

I am performing a Newey-West test to assess an estimator of a regression with heteroskedastic and autocorrelated residuals. I am using the "sandwich" and "lmtest" packages. While I can easily reproduce examples found on other sites, my own script…
user169340
  • 45
  • 5
2
votes
0 answers

scikit-learn LinearRegression coefficient explosion

I'm using the scikit-learn LinearRegression class to fit some data. I have a combination of numeric, boolean, and nominal data, the latter of which is split into one boolean feature per class. When I try to fit 4474 samples or less, everything…
Kirk
  • 21
  • 2
2
votes
1 answer

Fitting a higher degree function using PolynomialFeatures and LinearRegression

In a book I have found the following code which fits a LinearRegression to quadratic data: m = 100 X = 6 * np.random.rand(m, 1) - 3 y = 0.5 * X**2 + X + 2 + np.random.randn(m, 1) poly_features = PolynomialFeatures(degree=2,…
2Obe
  • 3,570
  • 6
  • 30
  • 54
2
votes
1 answer

Logistic regression not generalizing

According to Andrew Ng's lecture on logictic regression on Coursera the following cost function can be minimized using the update expression below: Running that update function several hundred times on ~150 samples, I get the following pattern,…
2
votes
2 answers

How we can compute intercept and slope in statsmodels OLS?

Here I asked how to compute AIC in a linear model. If I replace LinearRegression() method with linear_model.OLS method to have AIC, then how can I compute slope and intercept for the OLS linear model? import statsmodels.formula.api as smf regr =…
YNR
  • 867
  • 2
  • 13
  • 28
2
votes
1 answer

How can I apply weights in this scipy least squares optimization routine?

I am trying to do a generalized least squares fit to find the best fitting line through some (x,y) data points. I was able to do this via scipy, but I am having trouble applying weights. I would like to get the weights from the residuals of the…
user7345804
2
votes
0 answers

Tensorflow in Android: How do i use my linear regression model to predict a value in an android application?

I currently have a ipynb file (ipython notebook) that contains a linear regression code / model(im not entirely sure if it's a model) that I've created earlier. How do i implement this model in an android application such that if I were to input a…
Tix
  • 449
  • 1
  • 8
  • 27