خرید بک لینک

Vote count: 0

I am trying to use the command abline to fit a line and find an R-squared value for a relationship between columns from two different data sources. My data manipulation is as follows:

df<-data.frame(prop=as.numeric(as.character(prop$factorised column)), spv=column_from_a_matrix[,1]) #align the columns

df<-subset(df, !is.na(df$prop) & df$prop!=0.00) # 'as.numeric(as.character' introduces NA 
                                                # values by coercion and get rid of 0's
with(df, plot(prop, spv))
abline(fit <- lm(prop ~ spv, data=df), col='red')
legend("topright", bty="n", legend=paste("R2 is", format(summary(fit)$adj.r.squared, digits=4)))

However the produced line is clearly wrong:

enter image description here

 summary(lm(prop ~ spv, data=df))

 Call:
 lm(formula = prop ~ spv, data = df)

 Residuals:
   Min         1Q     Median         3Q        Max 
 -3.6856794 -0.9907636 -0.3290975  0.6782148  7.7086112 

 Coefficients:
                 Estimate  Std. Error  t value               Pr(>|t|)    
  (Intercept)  2.78546164  0.07840516 35.52651 < 0.000000000000000222 ***
  spv         22.61806073  2.18325279 10.35980 < 0.000000000000000222 ***
  ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Residual standard error: 1.633367 on 432 degrees of freedom
 Multiple R-squared:  0.1989994,    Adjusted R-squared:  0.1971452 
 F-statistic: 107.3254 on 1 and 432 DF,  p-value: < 0.00000000000000022204

As I do not get any errors I can not see where I'm going wrong even though the relationship is clearly wrong.....

My research of the abline command has just told me that exactly what I'm doing is right.... can someone point me in the right direction?

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 15 ارديبهشت 1395 ساعت: 16:53

صفحه بندی