Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-227

Factor Score

Problem

Return the regression factor score sum(l_i*z_i)/sum(l_i^2) for standardized variable scores and loadings. Return 0.0 for mismatched or empty input or a zero sum of squared loadings.

Hint

The regression method weights each standardized score by its loading.

Test cases

case 1
in: [[1,2],[1,1]]
expected: 1.5
case 2
in: [[2,-1],[0.8,0.6]]
expected: 1
case 3
in: [[1,1,1],[0.5,0.5,0.5]]
expected: 2
case 4
in: [[1,2],[0,0]]
expected: 0
case 5
in: [[5],[2]]
expected: 2.5
Starter codePython
def factor_score(z_scores, loadings):
    # Your code here
    pass

5 test cases · run your code against them in the editor