Sort by

recency

|

7 Discussions

|

  • + 0 comments
    import math
    
    def b_from_correlation_formula(r_squared, std_x, std_y):
        corr = math.sqrt(r_squared)
        b_x = corr * std_y / std_x
        return b_x
    
    def b_from_covariance_formula(r_squared, std_x, std_y):
        corr = math.sqrt(r_squared)
        cov_xy = corr * std_x * std_y
        b_x = cov_xy / (std_x ** 2)
        return b_x
    
    method = 0
        
    if method == 0:
        b_x = b_from_correlation_formula(0.4, 4, 8)
    else:
        b_x = b_from_covariance_formula(0.4, 4, 8)
           
    
    print(f'{b_x:.2f}')
    
  • + 0 comments

    A short program in Python 3. Question was unclear. It says R2 and correlation coefficient but R2 is (Correlation coefficient)^2. Check here: https://www.statisticshowto.com/probability-and-statistics/coefficient-of-determination-r-squared/

    def slope(x_std, y_std, corr):
        cov_xy=corr**.5*y_std*x_std 
        slp=cov_xy/x_std**2
        
        print (round(slp, 2))
    
    
    if __name__ == '__main__':
        # s_mean=int(input())
        # p_mean=int(input())
        s_std=int(input())
        p_std=int(input())
        corr=float(input())
        
        
        slope(s_std, p_std, corr)
    
  • + 0 comments

    The correlation is defined as r=cov(x,y)/sd(x)/sd(y). We also know that for linear regression r^2=R^2. In addition, the slope, m=cov(x,y)/var(x).

    Using all the above we get that R^2=m^2var^2(x)/sd^2(x)sd^2(y). Or that 0.4=m^2*4^4/4^2/8^2 and that m=1.26

  • + 0 comments

    The given information seems sufficient only to determine the slope magnitude, and not its sign. I got the "correct" answer by assuming a positive slope.

  • + 2 comments

    We need slope = Sps/Sss. We know: R^2 = 0.4 = (Sps)/(Sss * Spp).

    We also have: Sss = (standard deviation of S)^2 = (4)^2 and Spp = (standard deviation of P)^2 = (8)^2.

    We need Sps = (deviation between S and P), which we must solve for.

    Solving for Sps from the R^2 equation above gives: Sps = (Sss * Spp) * R^2 = (4^2 * 8^2 * 0.4)

    Finally: Slope = Sps/Sss = (4^2 * 8^2 * 0.4)/(4^2) = 1.26. Which is the answer.