mydat=structure(list(yield = c(5008L, 3402L, 4588L, 6004L, 7065L, 4449L,
6037L, 7200L, 4341L, 5433L, 4864L), x = c(5705.160194, 3562.567871,
4152.888076, 4428.184115, 3491.35426, 4093.656026, 5178.103678,
3349.67327, 4708.902256, 5949.647693, 4785.498224)), class = "data.frame", row.names = c(NA,
-11L))
I need calculate R^2
like here shown
Function to calculate R2 (R-squared) in R
preds <- dt$x
actual <- dt$yield
rss <- sum((preds - actual) ^ 2) ## residual sum of squares
tss <- sum((actual - mean(actual) ^ 2)) ## total sum of squares
rsq <- 1 - rss/tss
rsq
and rsq=1.10343
it can't be more then 1.
What i did wrong?