SQL/프로젝트
[Oracle] 상관계수 구하기 - corr
김초송
2022. 12. 7. 17:49
데이터 출처
1. 원-달러 환율 : https://kr.investing.com/currencies/usd-krw-historical-data
2. 미국 금리 : https://kr.investing.com/rates-bonds/u.s.-10-year-bond-yield
3. 코스피 : https://kr.investing.com/indices/kospi-historical-data
4. 미국 시간 당 임금 : https://fred.stlouisfed.org/series/CES0500000003
select round(corr(a_dollar, a_rate),3) dollar_rate
, round(corr(a_rate, kospi),3) rate_kospi
, round(corr(a_rate, earnings),3) rate_earnings
, round(corr(kospi, earnings),3) kospi_earnings
from dollar_rate_kospi_earnings;
-- 전 달과 비교한 상관계수들
select a_month
, round(corr(a_dollar, a_rate) OVER (order by a_month), 3) dollar_rate
, round(corr(a_rate, kospi) OVER (order by a_month), 3) rate_kospi
, round(corr(kospi, earnings) OVER (order by a_month), 3) kospi_earings
from dollar_rate_kospi_earnings;
참고: http://statwith.com/corr-oracle-function-list/
4월에 보이는 손이 개입됐나...? (개그임) 저 달만 상관계수가 조금 낮네
파이썬은 corr 쓰면 모든 변수 간 상관계수 보여주는데 sql은 하나씩 다 입력해야 되고 변수 여러 개 넣는 것도 안되고ㅠ 귀찮아 죽겠다
본 내용은 아이티윌 '빅데이터&머신러닝 전문가 양성 과정' 을 수강하며 작성한 내용입니다.