Questions tagged [coefficient-of-determination]

17 questions
20
votes
6 answers

Calculating R^2 for a nonlinear least squares fit

Suppose I have x values, y values, and expected y values f (from some nonlinear best fit curve). How can I compute coefficient of determination (R2)? Note that this function is not a linear model, but a nonlinear least squares (nls) fit, so not an…
CodeGuy
  • 28,427
  • 76
  • 200
  • 317
3
votes
2 answers

SciKit Learn R-squared is very different from square of Pearson's Correlation R

I have 2 numpy arrays ike so: a = np.array([32.0, 25.97, 26.78, 35.85, 30.17, 29.87, 30.45, 31.93, 30.65, 35.49, 28.3, 35.24, 35.98, 38.84, 27.97, 26.98, 25.98, 34.53, 40.39, 36.3]) b = np.array([28.778585, 31.164268, 24.690865,…
1
vote
1 answer

Tweaking ggpairs() or a better solution to a correlation matrix

I am trying to create a correlation matrix between my X and Y variables and display this information in a nice figure. I am currently using ggpairs() from the GGally package, but if there's a better way to do this then I am happy to try something…
seak23
  • 195
  • 9
1
vote
1 answer

How to create an Adjusted R-squared scorer using sklearn.metrics.make_scorer?

I've to make an Adjusted R-squared callable function, using make_scorer function of sklearn.metrics. The Adjusted R-squared has a parameter, the number of features, which I am finding hard to code. The reason why I am making this scorer is that I…
1
vote
1 answer

Why do coefficient of determination, R², implementations produce different results?

When attempting to implement a python function for calculating the coefficient of determination, R², I noticed I got wildly different results depending on whose calculation sequence I used. The wikipedia page on R² gives a seemingly very clear…
1
vote
0 answers

Coefficient of determination is close to -1

I am down loading stock data from you finance. I am trying to generate stock trading signal using ANN. I am getting Coefficient of determination is close to -1 and prediction is seem to be mirror image. Can someone suggest. I am getting similar…
0
votes
0 answers

R-Squared (Coefficient of determination) range beyond 0 and 1?

I was under the impression that the R-squared value is bound between 0 and 1. However after reading some online literature/forums and also some personal experience, I now feel that the R-squared value (coefficient of determination) is: a) bound…
0
votes
1 answer

Produce R-squared value from model fit

I hope you're doing well! I'm trying to produce an R-squared value from my model fit in R, but the model fit itself is based on a specific function from a script. Unfortunately, I haven't been able to find a solution so far. First things first, a…
0
votes
0 answers

How to calculate the partial R squared for a linear model with factor interaction in R

I have a linear model where my response Y is say the percentage (proportion) of fat in milk. I have two explanatory variables one (x1) is a continuous variable, the other (z) is a three level factor. I now do the regression in R as: contrasts(z) <-…
0
votes
3 answers

Regression Model (Outputs with only meaninful predictors)

I have constructed a linear regression model, reg_model1, and the model has factors within it. However, within the different sets of factors in the model, very few are significant along with other continuous variables. Is there any code that one can…
0
votes
1 answer

How to record R Squareds of a linear regression together with the group name into a data frame in R?

I have a linear regression which uses cities as groups in R: pop_model <- lmList(Value ~ Year | City, data = df) I can make a vector of corresponding R-Squareds using this: r_squareds <- summary(pop_model)$r.squared But this does not give me the…
0
votes
1 answer

Q: When P(# Regressors)=N(# Observations), does R^2 = 1?

I'm challenging a question from a quiz in a Data Science curriculum. The answer I gave was "Not enough information." The tester claims the answer is "R^2 = 1." I can't make sense of this mathematically or conceptually. I ran a regression with SciKit…
0
votes
1 answer

Pseudo R-squared for glm.cluster object

I have estimated several glms with cluster robust standard errors using the function glm.cluster() from the miceadds package in R. Unfortunately, the function does not automatically calculate a pseudo R-squared. Moreover, I am unable to find a…
0
votes
0 answers

Getting non zero value for r2_score() when I comapre true values with their mean

I was using r2_score() method, for evaluation of a Regression problem using scikit learn. As we know that we should get, 0.0 for the coefficient of determination R^2 of the prediction. but I'm getting 2.220446049250313e-16 when I do so. here is the…
0
votes
1 answer

Make a R2 graph with Python

I have datas in two lists. One with the real ones (observed) and one with the predicted ones. I wanna put it in a graph to get something with the two lists with different colors and the line between them but I don't get how to put the line in the…
1
2