Questions tagged [linear-regression]

for issues related to linear regression modelling approach

linear-regression
2,469 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9 votes
0 answers
631 views

Bayesian error-in-variables (total least squares) model in R using MCMCglmm

I am fitting some Bayesian linear mixed models using the MCMCglmm package in R. My data includes predictors that are measured with error. I'd therefore like to build a model that takes this into ...
Alberto's user avatar
  • 133
7 votes
1 answer
686 views

In R, how do I define model contrasts for comparing two conditions relative to a common control?

I've been using the makeContrasts function in the Limma package to create contrasts, and I understand how to make simple contrasts, for example comparing each Treatment to a control independently or ...
Jay's user avatar
  • 452
7 votes
1 answer
598 views

Parameters shooting to infinity while training after some epochs

I'm implementing Linear Regression in Tensorflow first time. Initially, I tried it using a linear model but after few iterations of training, my parameter shot up to infinity. So, I changed my model ...
asn's user avatar
  • 2,521
6 votes
0 answers
881 views

python least squares regression modification to objective function

Least squares regression is defined as the minimization of the sum of squared residuals e.g. Minimize(sum_squares(X * beta - y)) However, I'd like to propose a slight modification such that we are ...
Michael's user avatar
  • 7,257
5 votes
0 answers
62 views

Calculating the ridge parameter for given ridge estimates

Suppose response and covariate data are below: (1.4, 0.0), (1.4, -2.0), (0.8, 0.0), (0.4,2.0). I want to find the ridge parameter k, for which the ridge estimates are (1, -1/8) by applying the ...
Emma Johnsons's user avatar
5 votes
1 answer
886 views

Getting statsmodel RollingOLS results summary information

I am running rolling regressions using the RollingOLS function on statsmodels.api, and wondering if its possible to get the summary statistics (betas, r^2, etc.) out for each regression done in the ...
learningiskey's user avatar
5 votes
0 answers
545 views

How to incorporate many features into a TensorFlow Probability Structural Time Series

I'm wondering how to train a Multivariate Bayesian Structural Time Series (BSTS) model that automatically performs feature selection on hundreds of input time series using Tensorflow Probability. The ...
magnawhale's user avatar
5 votes
0 answers
805 views

Python Parallel Computing - Scoop

I am trying to get familiar with the library Scoop (documentation here: https://media.readthedocs.org/pdf/scoop/0.7/scoop.pdf) to learn how to perform statistical computations in parallel, using in ...
Nicg's user avatar
  • 280
5 votes
1 answer
1k views

Multiple linear regression: Plot a straight line with confidence intervals

Here is my question: 1) I ran a multiple linear regression: suppose like: lm(attitude~quality+price+location+Income) I mainly care about the relationship between attitude and quality, and other ...
Will's user avatar
  • 51
5 votes
0 answers
2k views

LinearRegression() : R2 scoring with cross_val_score - weird results

I'm using the cross_val_score() function to compute the R2 coefficient of my fit. Here is my code: from sklearn.linear_model import LinearRegression from sklearn.model_selection import ...
Krukiou's user avatar
  • 141
5 votes
0 answers
143 views

R: Can´t find mistake on Linear Regression

I have to reproduce the code used by http://scholar.harvard.edu/files/mankiw/files/permanent_income.pdf. I do understand the concept of linear regressions and instrumental variables, I just can´t find ...
Luis's user avatar
  • 51
5 votes
0 answers
1k views

How to calculate confidence interval for orthogonal distance regression line fit in python

I am using orthogonal distance regression method(scipy.odr) to fit my data, after fit, I have trouble in calculate the 95% confidence interval, please help me no how to calculate it~ here the code: #...
Owen's user avatar
  • 427
4 votes
1 answer
133 views

how to use anovascores results to eliminate columns/predictors with pvalues greater than 0.01

I had a dataset with 36400 columns/features/predictors (types of proteins) and 500 observations and the last column is response column "class" that indicates 2 types of cells - A and B. we'...
Heena 's user avatar
  • 113
4 votes
1 answer
3k views

RFECV in sklearn, scores from grid_scores_

I am using sklearn.feature_selection.RFECV: ref = RFECV(lr, step=1, cv =5, scoring="r2") ref.fit(X_ndarr, y_ndarr) print(ref.grid_scores_) I get: [ 0.9316829 0.93472609 0.79440118 -2.37744438 -...
towi_parallelism's user avatar
4 votes
0 answers
972 views

time series prediction with variable-length input

My thesis is about cancer prediction in mice. I collected data from 35 mice. I measure the volume of the tumors every day after the beginning of cancer until the death of mice. The time of death ...
tayebe's user avatar
  • 41
4 votes
0 answers
2k views

calculate a confidence interval from the outputs of stats.linregress in python

I have a data set with two variables and I have calculated the type 1 linear regression line. I used the stats.linregress and got these results: LinregressResult(slope=0.06310526340834267, intercept=0....
Victoria Dickey's user avatar
4 votes
2 answers
407 views

Approximate the values of a matrix given a function built with a given base vector

First of all forgive me if the title sounds a bit confusing. English is not my native language so although I'm fluent at it, some technical terms might not be correct. Let me know if and how I can ...
J. Devez's user avatar
  • 329
4 votes
1 answer
186 views

(linear or polymonial) regression algorithm for lower bound of nearly sinusoidal data

I need to find a curve that would fit lower poinds of my discreete data. Linear regression would be ok, but polymonial would be great :) Usualy I do not deal with such task, so please do not be harsh ...
Kowalski Paweł's user avatar
4 votes
0 answers
941 views

Does scikit-learn support general Tikhonov regularization in its Ridge modules?

Using the notation from Wikipedia, it seems that the scikit-learn Ridge modules use a multiple of the identity matrix as the Tikhonov matrix Gamma. The Tikhonov matrix is therefore specified by a ...
jonthalpy's user avatar
  • 1,052
4 votes
0 answers
252 views

What's the difference between resid_working, resid_anscombe, and resid_deviance in GLM

What's the difference between resid_working, resid_anscombe, and resid_deviance in statsmodel.GLMResults? Here are some explanation from the source code: Working residuals; the working residuals are ...
ZHU's user avatar
  • 944
4 votes
0 answers
403 views

sklearn weighted Elastic Nets

When I use the sklearn.linear_model.LinearRegression module, I found it support the sample_weight variable in the fit method. I was wondering why other linear_model (e.g., ElasticNet, LASSO, ...
Frank The Tank's user avatar
4 votes
0 answers
574 views

Python Regression giving 2 different results

So I have the data below: 1995 0.379769 1996 0.384967 1997 0.344343 1998 0.384179 1999 0.282823 2000 0.337774 2001 0.298339 2002 0.351266 2003 0.338709 ...
qwertylpc's user avatar
  • 2,036
4 votes
0 answers
203 views

How to encode a Dataset for linear regression in Spark with Java?

I have a Dataset<Row> with 3 colums and i want to modify for make a linear regression. My colums are [id , x, y] and i want a linear regression for each id; For example: [1 , 1005, 0.29] [...
Cristu Naranjo's user avatar
4 votes
0 answers
1k views

prediction plots for statsmodels OLS fit, taking out categorical effects

I have some data for about 500 galaxies in a pandas DataFrame (a few hundred measurements per galaxy), and I'm trying to perform OLS regression on a few variables, one of which is categorical (each ...
DathosPachy's user avatar
4 votes
0 answers
691 views

piecewise linear regression python: arbitrary amount of knots

I have an experimental data, which is piecewise continuous, and each part should fit linearly. However, I would like to fit it without knowing where exactly are the knots (so the points where the ...
Antonio's user avatar
  • 325
4 votes
0 answers
550 views

Linear Regression fill_between with matplotlib

I'm currently performing a linear regression on my data with the following code (from the stats models.api): import statsmodels.api from statsmodels.stats.outliers_influence import summary_table X = ...
GCien's user avatar
  • 2,281
4 votes
1 answer
861 views

Bootstrapping Standard Errors of lm

I am new to R and I could need some help. I have obtained the standard error and the p-value of a lm regression of y ~ z. Now i would like to do a bootstrap and compare the results. All i could find ...
Konditola's user avatar
4 votes
0 answers
340 views

Limit to the number of explanatory variables that R's BMA package can handle?

Using R's BMA (Bayesian Model Averaging) package, I want to run the following code: result = bic.glm(x,y,prior.param = c(1,1,1,1,0.5,1,0.5,0.5,0.5,1,1,1,1,1,0.5,1, 1,1,1,1,1,1,1,1,1,1,1,1,0.5,1), glm....
cauda_equina's user avatar
4 votes
1 answer
519 views

Finding the break in data from a piecewise function

Greetings, I'm performing research that will help determine the size of observed space and the time elapsed since the big bang. Hopefully you can help! I have bilinear data on which I want to ...
rhombidodecahedron's user avatar
3 votes
0 answers
335 views

Function to compute R^2 value for Generalized Linear Model in Julia

I have a dataset df and I need to calculate it's glm summary. I got everything working properly using jlm=glm(@formula(y~x1+x2),df,Normal()) This gets me the Beta Values and Standard-Error, but I need ...
Akhoury Shauryam's user avatar
3 votes
1 answer
66 views

How can run 2 separate regression models with lmer using only one formula?

Consider, "y" as the dependent variable and "x1" and "x2" as the independent variables. Consider two categorical variables "GROUPING" and "REGION" ...
Mukund Komati's user avatar
3 votes
0 answers
445 views

Constrained linear regression with pyspark

I want to do a multiple linear regression in pyspark where y = Bx = b1 * x1 + b2 * x2 + b3 * x3 (assume the number of features is 3) Sum of weights in vector B equals to 1; Each weight is non-...
Molly Zhou's user avatar
3 votes
1 answer
646 views

How to solve 'Input contains NaN, infinity or a value too large for dtype('float64')' after already preprocessing using Pipeline?

There are many posts containing this error, but I couldn't find the solution for this problem. I'm using this dataset. This is what I've done, a preprocessing, with SimpleImputer for categorical and ...
dsbr__0's user avatar
  • 241
3 votes
0 answers
220 views

python numpy piecewise linear fit not robust?

I have applied the elegant solution to piecewise linear fitting as given in How to apply piecewise linear fit in Python?. As shown in the figure (source code is given below), I do get as a result the ...
itmatters's user avatar
  • 665
3 votes
0 answers
478 views

Huber-M estimator for Robust Linear Regression R Vs Python

For Robust Linear regression in R using package Huber-M estimator, we use the below code: rlm(x,y, weight,init='ls' psi=psi.huber, scaler.est=c('MAD'), method=c('M), maxit=50) Is there any similar ...
Ussu20's user avatar
  • 171
3 votes
1 answer
2k views

Regression without intercept in R and Stata

Recently, I stumbled upon the fact that Stata and R handle regressions without intercept differently. I'm not a statistician, so please be kind if my vocabulary is not ideal. I tried to make the ...
der_grund's user avatar
  • 1,898
3 votes
0 answers
507 views

No update of bias in linear Regression via Pytorch

I want to use PyTorch to build linear regression to solve a simple task. The 1-D output is just the average of 10-D input. What is strange is that during training, weights would converge to 0.1 while ...
star-fire's user avatar
3 votes
0 answers
886 views

PyTorch linear regression model

I have a multivariate linear regression problem in which each data point looks like this: y_i = 3 # Some integer between 0 and 20 X_i = [0.5, 80, 0.004, 0.5, 0.789] # A 5 ...
tam63's user avatar
  • 311
3 votes
0 answers
144 views

Configure r sandwich package to find felm's clustered standard error

I have a regression with many fixed effects, and, therefore, I'm using the lfe::felm function to calculate my coefficients. I'm clustering the standard error with the felm function, but I would like ...
rt.l's user avatar
  • 306
3 votes
0 answers
129 views

Where did I go wrong in numpy normalization of input data in linear regression?

When following through Andrew Ng's Machine learning course assignment - Exercise:1 in python, I had to predict the prize of a house given the size of the house in sq-feet,number of bedroom using multi ...
Savannah Madison's user avatar
3 votes
0 answers
2k views

why do i get PearsonRConstantInputWarning when using stats.boxcox_normmax?

i'm trying to transform my data and lessen the skewness of some features with astats.boxcox_normmax to find the best value for boxcox. ### Transforming with boxcox normmax for field in list(...
mitra mirshafiee's user avatar
3 votes
0 answers
250 views

Draw residuals for linear, major axis and standardized major axis regressions

I have been going in circles trying to replicate a figure from Warton et al (2006) in R. I want to highlight how the direction of the residuals are drawn for a presentation and have a reproducible ...
Paul Julian's user avatar
3 votes
0 answers
65 views

How to update code to create a function for calculating Welch's for polynomial trends?

I am trying to reproduce the SPSS output for significance a linear trend among means when equal variances are not assumed. I have gratefully used code from http://www-personal.umich.edu/~gonzo/...
Cassandra's user avatar
  • 137
3 votes
0 answers
165 views

I am getting patsy error because of the formula i used while implementing OLS Regression

I am trying to predicting Car sale for which i m using OLS Regression. i have got list of some important features using F regression which i m using as part of the formula my formula looks something ...
bhawna singh's user avatar
3 votes
0 answers
421 views

linear (log-log) model with 'lm': how to get prediction variance of sum of predicted values

I'm fitting a power model to a dataset by applying a simple linear model with the R function lm after log-log transformation, as in the example below (instead of fitting directly the power model, for ...
Marco's user avatar
  • 31
3 votes
0 answers
4k views

Is there a Python Statsmodels OLS function to get only the statistical significant coefficients after fit a regression?

I have fit a linear regression using the OLS.fit() function of Statsmodels, obtained the estimated coefficients and corresponding p-values by calling the .params and .pvalues of the results classes. ...
G.mc's user avatar
  • 123
3 votes
0 answers
393 views

R - Why is linear model intercept significant despite being set (indirectly) to zero?

From my understanding, the significance of an intercept term (β0 in y = β0 + β1x + ɛ) in a given model is tested by comparison to zero (whereby, a non-significant β0 = 0, and a significant β0 ≠ 0). If ...
JK.Robertson's user avatar
3 votes
0 answers
652 views

R - Threshold linear regression model

I am looking for a package in R containing a threshold regression model or a threshold autoregressive (ar) model with extra exogenous explonatary variables for time series? By now I came across ...
krson's user avatar
  • 41
3 votes
1 answer
1k views

Negative predictions in polynomial regression

I am trying to predict a value each week. I have 4 months and the actual value goes near to zero on weekends but never negative. My polynomial regression model is predicting well for weekdays and goes ...
Dexter's user avatar
  • 195
3 votes
1 answer
320 views

CSV file unable to upload

Trying to load CSV file while doing simple linear regression . When I try to run , the error is coming as - "File name" is not exist as file/directory . Do I need to save the file in a particular ...
Aditi's user avatar
  • 83

1
2 3 4 5
50