Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:04:21+00:00 2026-06-17T21:04:21+00:00

Suppose I have x values, y values, and expected y values f (from some

  • 0

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 lm fit.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:04:22+00:00Added an answer on June 17, 2026 at 9:04 pm

    You just use the lm function to fit a linear model:

    x = runif(100)
    y = runif(100)
    spam = summary(lm(x~y))
    > spam$r.squared
    [1] 0.0008532386
    

    Note that the r squared is not defined for non-linear models, or at least very tricky, quote from R-help:

    There is a good reason that an nls model fit in R does not provide
    r-squared – r-squared doesn’t make sense for a general nls model.

    One way of thinking of r-squared is as a comparison of the residual
    sum of squares for the fitted model to the residual sum of squares for
    a trivial model that consists of a constant only. You cannot
    guarantee that this is a comparison of nested models when dealing with
    an nls model. If the models aren’t nested this comparison is not
    terribly meaningful.

    So the answer is that you probably don’t want to do this in the first
    place.

    If you want peer-reviewed evidence, see this article for example; it’s not that you can’t compute the R^2 value, it’s just that it may not mean the same thing/have the same desirable properties as in the linear-model case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a matrix of weights, and another matrix of data values. Can
Suppose I have range from E2 to E16. How do I read values from
I have this code that is supposed to echo some values from a MySQL
Suppose I have an array of values [a,b,c,d,...] and a function f(x,...) which returns
Suppose we have a set x of N values {x_i; i=1,...,N} and a set
Suppose I have a STL map where the values are pointers, and I want
Suppose I have 3 radio buttons with different values for each radio button and
Suppose I have a dropdown (select tag) with 3 values. Our first option has
Suppose I have the following method signature int f (int[] values) and I call
Suppose I have a Window with TextBoxes I want to use the values. Right

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.