Calculating R^2 for a nonlinear least squares fit

前端 未结 5 1878
别跟我提以往
别跟我提以往 2020-12-14 02:36

Suppose I have x values, y values, and expected y values f (from some nonlinear best fit curve).

How can I compute R^2 in R? N

5条回答
  •  既然无缘
    2020-12-14 03:23

    Sounds like f are your predicted values. So the distance from them to the actual values devided by n * variance of y

    so something like

    1-sum((y-f)^2)/(length(y)*var(y))

    should give you a quasi rsquared value, so long as your model is reasonably close to a linear model and n is pretty big.

提交回复
热议问题