All problems
Dynamic Factor Estimate
Problem
Estimate a single dynamic factor from cross-sectional observations by least squares: f = sum(loading_i * x_i) / sum(loading_i^2).
Return 0.0 when all loadings are zero.
Hint
This is a one-factor regression with unit-variance factor normalization.
Test cases
case 1
in: [[0.5,0.5],[2,4]]
expected: 6
case 2
in: [[1,2,3],[1,2,3]]
expected: 1
case 3
in: [[0,0],[5,7]]
expected: 0
case 4
in: [[2,-1],[4,-2]]
expected: 2
Starter codePython
def dynamic_factor_estimate(loadings, observations):
# Your code here
pass4 test cases · run your code against them in the editor