This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM jupyter/datascience-notebook | |
| USER root | |
| RUN apt-get update && apt-get install -yq graphviz | |
| USER $NB_USER | |
| RUN pip install lingam graphviz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def lag(x, n=0): | |
| observed = np.isnan(x) == False | |
| observed[0] = True | |
| offsets = np.flatnonzero(observed) | |
| return offsets[np.maximum(np.cumsum(observed) - 1 - n, 0)] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [beta, beta0] = truncated_tls(X, y, k) | |
| % TRUNCATED_TLS Computes the Truncated Total Least Squares solution. | |
| % | |
| % Inputs: | |
| % X : Matrix of predictors (n x p) | |
| % y : Target column vector (n x 1) | |
| % k : Truncation rank (number of singular values to KEEP) | |
| % Must satisfy: 1 <= k <= p | |
| % | |
| % Outputs: |
OlderNewer