6,537 questions
0
votes
1
answer
79
views
stat_regline_equation() doesn't match stat_smooth() line
I'm getting an odd problem where I've attempted to plot a scatter graph and fit a quadratic regression line to it. I used stat_smooth() to make the line, and stat_regline_equation() to print the ...
1
vote
0
answers
163
views
Plotting linear regression for geometric intuition
I am regressing Y~(X1, X2) such that this fit is perfect (R squared is 1), where the R squared for Y~X1 and Y~X2 are chosen somewhere in the interval $(0,1)$. I am trying to create the numerical ...
1
vote
0
answers
44
views
lm() and glm() equivalence for log-transformed response variable [migrated]
I can't seem to wrap my head around this:
What is the glm() equivalent for lm(log(y) ~ x1 + x2, data=data)?
Is it?
a. glm(y ~ x1 + x2, data=data, family=gausssian(link="log"))
b. glm(log(y) ...
0
votes
0
answers
59
views
How to make an interactive console version in Java for a simple linear regression model?
I’m trying to create a simple model in Java that predicts marks based on study hours (using a basic linear regression formula).
My goal is to make it interactive — where the user can enter the number ...
2
votes
0
answers
88
views
Quantify sum of squared differences in a robust multilinear regression in R
I would like to obtain estimates of the variance explained by each predictor in multiple regression using robust linear regression (for instance with the R function lmrob from robustbase R package or ...
-3
votes
1
answer
39
views
is mmec function of sommer package deprecated in latest version?
I just want to ask whether the function mmec is deprecated in the latest version? because when I am trying to use it, its displaying (could not find function "mmec") message. It is ...
0
votes
0
answers
66
views
Why is my plot of the cost function like this and not like a bowl?
My code:
def calc_cost_function(w, b, data):
m = len(data)
cost = 0
for i in range(m):
x = data.iloc[i].X
y = data.iloc[i].Y
cost += ((x * w + b) - y)**2
return ...
0
votes
1
answer
46
views
How to perform pairwise weighted least squares regression on multiple columns?
I'm working with DolphinDB and trying to compute weighted least squares (WLS) regression between multiple pairs of columns in a table. The mslr function (moving least squares regression) works ...
1
vote
1
answer
74
views
Memory management issues for a linear regression program in C
I am planning to make a Linear Regression model using C. It takes a set of m points as input from stdin using scanf. The points are defined as a struct:
typedef struct{
double x;
double y;
} ...
2
votes
1
answer
97
views
Why is there a major difference in R-Squared between my models created with the same data? [closed]
I created two models using the lm() function in R. The first model, I created the design matrix for my prediction variable and then fed that into the lm() function.
copy <- data.frame(mtcars)
...
3
votes
0
answers
76
views
Orthogonal Distance Regression (ODR) convergence on valid data
I have some real data points, and I'm trying to use the ODR to fit linear regression and also output the uncertainty error of the slope.
import numpy as np
from scipy.odr import ODR, Model, RealData
...
0
votes
1
answer
27
views
Why Does ols Fail with 'Dimension Mismatch' When Using sqlCol for Multiple Columns in DolphinDB?
In DolphinDB, I'm trying to perform multiple regression on multiple columns by using metaprogramming function sql, but I'm getting an error.
Here's my script:
sql(sqlColAlias(makeUnifiedCall(toArray, ...
2
votes
2
answers
66
views
Needing advice on linear regression and then replacing NA's with fitted values
I am quite new to the data analytics stuff and R/RStudio so I am in need of advice. I am doing a project and asked to do:
for every variable that has missing value to run a linear regression model ...
0
votes
1
answer
48
views
Gradient descent in linear regression causing parameter to be -infinity
I'm trying to implement a simple linear regression algo, and for that I've written two functions:
Cost function
Gradient descent
Cost function appears to work normally, as in it's not giving me ...
3
votes
1
answer
133
views
Plot the best fit linear regression with the slope set to a fixed value (m=1)
Currently using R 4.4.3 on Windows 11. I'm plotting the following data set with ggplot2 and performing a linear regression with geom_smooth:
df <- data.frame(A= c(1.313, 1.3118, 1.3132, 1.3122, 1....