Lisp-Stat

Table of Contents

1. Intro

First we'll load the Data Frame Input/Output package.

(require 'dfio)     
(use-package 'dfio) 
T
(require 'data-frame)     
(use-package 'data-frame) 
T
(require 'lisp-stat)     
(use-package 'lisp-stat) 
T
(in-package :ls-user)
#<PACKAGE "LS-USER">
(defparameter energy_prices
        (read-csv #P"ng_cl_data.csv"))

energy_prices
#<DATA-FRAME (1531 observations of 3 variables)>

Here is a reference for data frames: https://lisp-stat.github.io/data-frame/

(head energy_prices)

;;   INDEX      NG-RNGC1-W PET-RCLC1-W
;; 0 1994-01-14      2.231       14.63
;; 1 1994-01-21      2.297       15.05
;; 2 1994-01-28      2.404       15.31
;; 3 1994-02-04      2.506       15.73
;; 4 1994-02-11      2.369       14.87
;; 5 1994-02-18      2.330       14.11
(tail energy_prices)

;;   INDEX      NG-RNGC1-W PET-RCLC1-W
;; 0 2023-04-07      2.092       80.61
;; 1 2023-04-14      2.114       81.84
;; 2 2023-04-21      2.269       79.20
;; 3 2023-04-28      2.292       76.33
;; 4 2023-05-05      2.188       71.16
;; 5 2023-05-12      2.230       72.07
(column-names energy_prices)
INDEX NG-RNGC1-W PET-RCLC1-W
(rename-column! energy_prices 'ng 'NG-RNGC1-W)
#<DATA-FRAME (1531 observations of 3 variables)>
(rename-column! energy_prices 'cl 'PET-RCLC1-W)
#<DATA-FRAME (1531 observations of 3 variables)>
(column-names energy_prices)
INDEX NG CL
(aops:dims energy_prices)
1531 3

To select a column we can use:

(column energy_prices 'NG)
2.231d0 2.297d0 2.404d0 2.506d0 2.369d0 2.33d0 2.267d0 2.178d0 2.146d0 2.108d0 2.058d0 2.065d0 2.092d0 2.127d0 2.126d0 2.097d0 2.025d0 1.959d0 1.933d0 1.855d0 1.938d0 2.052d0 2.128d0 2.065d0 2.183d0 2.087d0 1.991d0 1.886d0 1.862d0 1.783d0 1.709d0 1.757d0 1.573d0 1.6d0 1.631d0 1.661d0 1.506d0 1.699d0 1.662d0 1.641d0 1.605d0 1.932d0 1.894d0 1.754d0 1.68d0 1.803d0 1.724d0 1.778d0 1.759d0 1.59d0 1.697d0 1.587d0 1.399d0 1.388d0 1.387d0 1.407d0 1.471d0 1.397d0 1.446d0 1.465d0 1.443d0 1.523d0 1.543d0 1.664d0 1.657d0 1.615d0 1.683d0 1.676d0 1.666d0 1.666d0 1.725d0 1.768d0 1.714d0 1.702d0 1.683d0 1.577d0 1.542d0 1.481d0 1.525d0 1.483d0 1.46d0 1.476d0 1.499d0 1.548d0 1.604d0 1.707d0 1.653d0 1.667d0 1.609d0 1.75d0 1.825d0 1.778d0 1.726d0 1.802d0 1.848d0 1.858d0 1.946d0 2.17d0 2.046d0 2.195d0 2.286d0 2.851d0 2.616d0 2.931d0 2.636d0 2.171d0 2.305d0 2.493d0 2.43d0 2.543d0 2.534d0 2.272d0 2.165d0 2.233d0 2.642d0 2.412d0 2.305d0 2.364d0 2.338d0 2.263d0 2.199d0 2.187d0 2.288d0 2.329d0 2.415d0 2.381d0 2.45d0 2.606d0 2.739d0 2.803d0 2.76d0 2.59d0 2.288d0 2.188d0 2.12d0 2.079d0 2.028d0 1.873d0 1.814d0 1.834d0 1.98d0 2.023d0 2.264d0 2.399d0 2.405d0 2.563d0 2.756d0 2.648d0 2.743d0 3.449d0 3.524d0 3.477d0 3.498d0 4.338d0 3.639d0 2.857d0 3.456d0 3.371d0 2.902d0 2.568d0 2.356d0 2.089d0 1.959d0 1.835d0 1.883d0 1.942d0 1.886d0 1.875d0 1.904d0 1.919d0 2.009d0 2.097d0 2.183d0 2.279d0 2.226d0 2.218d0 2.299d0 2.147d0 2.112d0 2.186d0 2.205d0 2.104d0 2.098d0 2.166d0 2.134d0 2.168d0 2.409d0 2.478d0 2.444d0 2.577d0 2.743d0 2.73d0 2.783d0 3.14d0 3.091d0 2.955d0 3.122d0 3.461d0 3.509d0 3.382d0 3.337d0 2.85d0 2.605d0 2.6d0 2.4d0 2.407d0 2.27d0 2.24d0 2.125d0 2.06d0 2.119d0 2.093d0 2.335d0 2.244d0 2.204d0 2.257d0 2.206d0 2.149d0 2.238d0 2.336d0 2.51d0 2.637d0 2.491d0 2.419d0 2.261d0 2.186d0 2.21d0 2.122d0 2.088d0 2.1d0 1.969d0 2.138d0 2.362d0 2.436d0 2.35d0 2.208d0 1.991d0 1.921d0 1.86d0 1.844d0 1.968d0 1.77d0 1.737d0 1.885d0 2.141d0 2.172d0 2.254d0 2.315d0 2.083d0 2.173d0 2.2d0 2.464d0 2.441d0 2.232d0 2.147d0 1.951d0 1.911d0 2.006d0 1.914d0 1.846d0 1.928d0 1.795d0 1.828d0 1.775d0 1.791d0 1.815d0 1.765d0 1.673d0 1.747d0 1.861d0 1.713d0 1.794d0 1.923d0 2.046d0 2.124d0 2.187d0 2.314d0 2.319d0 2.259d0 2.26d0 2.248d0 2.396d0 2.405d0 2.331d0 2.258d0 2.321d0 2.164d0 2.166d0 2.316d0 2.565d0 2.632d0 2.728d0 2.807d0 3.002d0 2.712d0 2.735d0 2.639d0 2.539d0 2.71d0 2.629d0 2.906d0 3.008d0 3.009d0 2.866d0 2.627d0 2.472d0 2.168d0 2.368d0 2.302d0 2.574d0 2.498d0 2.334d0 2.178d0 2.258d0 2.461d0 2.561d0 2.704d0 2.551d0 2.604d0 2.549d0 2.774d0 2.783d0 2.834d0 2.788d0 2.919d0 2.905d0 3.021d0 3.096d0 3.106d0 3.138d0 3.275d0 3.613d0 4.055d0 4.204d0 4.186d0 4.315d0 4.309d0 4.502d0 4.145d0 4.166d0 3.924d0 3.76d0 4.104d0 4.423d0 4.361d0 4.608d0 4.7d0 4.974d0 5.095d0 5.278d0 5.244d0 5.23d0 5.391d0 5.183d0 4.751d0 4.67d0 5.233d0 5.975d0 6.411d0 6.234d0 8.051d0 8.18d0 9.272d0 9.705d0 8.695d0 9.163d0 7.401d0 7.208d0 6.226d0 6.014d0 5.704d0 5.174d0 5.156d0 5.271d0 5.007d0 5.175d0 5.325d0 5.242d0 5.45d0 5.228d0 4.988d0 4.567d0 4.269d0 4.376d0 4.075d0 3.842d0 3.907d0 4.121d0 3.828d0 3.28d0 3.168d0 3.291d0 3.042d0 3.103d0 3.23d0 3.006d0 3.246d0 2.943d0 2.405d0 2.429d0 2.392d0 2.187d0 2.032d0 2.287d0 2.419d0 2.511d0 2.889d0 3.225d0 2.911d0 2.678d0 2.818d0 2.576d0 2.564d0 2.774d0 2.708d0 2.746d0 2.394d0 2.234d0 2.285d0 2.066d0 2.027d0 2.126d0 2.245d0 2.414d0 2.373d0 2.615d0 2.981d0 3.285d0 3.375d0 3.459d0 3.188d0 3.442d0 3.444d0 3.704d0 3.696d0 3.697d0 3.425d0 3.284d0 3.243d0 3.175d0 3.291d0 3.327d0 3.159d0 2.882d0 2.872d0 2.943d0 2.904d0 2.712d0 3.025d0 3.341d0 3.386d0 3.233d0 3.36d0 3.717d0 3.788d0 3.965d0 3.898d0 4.263d0 4.137d0 4.181d0 3.866d0 3.875d0 4.277d0 4.2d0 4.326d0 4.815d0 5.217d0 5.053d0 5.046d0 5.134d0 5.393d0 5.522d0 5.537d0 5.808d0 5.841d0 6.203d0 8.686d0 7.012d0 5.822d0 5.311d0 5.143d0 5.022d0 5.253d0 5.647d0 5.575d0 5.253d0 5.699d0 6.171d0 6.084d0 6.04d0 6.435d0 6.027d0 5.749d0 5.594d0 5.288d0 5.363d0 5.025d0 4.857d0 4.73d0 4.834d0 5.052d0 5.104d0 4.944d0 4.728d0 4.772d0 4.588d0 4.513d0 4.771d0 5.267d0 5.38d0 4.854d0 4.612d0 4.738d0 4.845d0 4.838d0 4.968d0 5.818d0 6.834d0 6.959d0 6.286d0 6.313d0 7.033d0 6.281d0 6.083d0 5.654d0 5.526d0 5.4d0 5.275d0 5.232d0 5.478d0 5.493d0 5.668d0 5.447d0 5.724d0 5.856d0 5.777d0 5.567d0 5.871d0 6.264d0 6.371d0 6.342d0 6.616d0 6.456d0 6.145d0 6.427d0 6.411d0 6.155d0 6.28d0 5.894d0 5.994d0 6.083d0 5.718d0 5.614d0 5.438d0 5.243d0 4.943d0 4.662d0 4.885d0 5.488d0 6.292d0 7.07d0 6.798d0 7.47d0 8.265d0 8.438d0 7.432d0 7.166d0 7.177d0 7.295d0 6.791d0 7.238d0 6.824d0 6.231d0 5.915d0 6.207d0 6.244d0 6.362d0 6.251d0 6.11d0 6.041d0 6.358d0 6.705d0 6.796d0 7.204d0 7.191d0 7.436d0 7.466d0 7.089d0 7.055d0 6.87d0 6.63d0 6.619d0 6.402d0 6.312d0 6.716d0 7.045d0 7.446d0 7.483d0 7.07d0 7.508d0 7.794d0 7.494d0 7.587d0 8.41d0 9.058d0 9.344d0 9.758d0 11.485d0 11.367d0 11.088d0 12.572d0 13.424d0 13.805d0 13.268d0 13.341d0 13.653d0 11.754d0 11.685d0 11.771d0 11.521d0 12.492d0 14.031d0 14.462d0 13.52d0 11.225d0 9.988d0 9.134d0 9.011d0 8.469d0 8.877d0 7.676d0 7.147d0 7.396d0 6.757d0 6.624d0 7.127d0 7.054d0 7.242d0 7.018d0 6.933d0 7.964d0 7.074d0 6.745d0 6.621d0 6.092d0 6.079d0 6.394d0 6.237d0 6.673d0 6.529d0 6.04d0 5.65d0 5.899d0 5.886d0 6.825d0 7.624d0 7.302d0 6.792d0 6.948d0 6.3d0 5.856d0 5.313d0 4.857d0 4.842d0 6.024d0 6.097d0 6.813d0 7.263d0 7.672d0 7.763d0 7.985d0 7.908d0 8.49d0 7.69d0 7.498d0 6.872d0 6.124d0 6.202d0 6.531d0 6.52d0 7.283d0 7.466d0 7.731d0 7.325d0 7.678d0 7.382d0 7.282d0 6.954d0 7.101d0 7.53d0 7.554d0 7.799d0 7.463d0 7.637d0 7.839d0 7.752d0 7.945d0 7.758d0 7.836d0 7.964d0 7.724d0 7.415d0 6.834d0 6.645d0 6.573d0 6.472d0 5.976d0 6.247d0 6.407d0 6.896d0 5.716d0 5.501d0 5.646d0 6.114d0 6.297d0 6.588d0 7.247d0 6.913d0 7.337d0 7.006d0 8.135d0 7.819d0 7.889d0 7.628d0 7.447d0 7.207d0 7.148d0 7.136d0 7.157d0 7.712d0 8.082d0 8.151d0 7.769d0 7.99d0 8.041d0 8.557d0 8.994d0 9.226d0 9.59d0 10.026d0 9.15d0 9.539d0 9.679d0 9.908d0 10.332d0 10.774d0 10.86d0 11.291d0 11.362d0 11.502d0 11.723d0 12.356d0 12.624d0 12.99d0 13.054d0 13.456d0 12.311d0 11.188d0 9.754d0 9.227d0 8.608d0 8.272d0 8.007d0 8.098d0 7.324d0 7.416d0 7.543d0 7.692d0 7.445d0 6.741d0 6.699d0 6.604d0 6.398d0 7.01d0 6.6d0 6.518d0 6.667d0 6.226d0 5.586d0 5.582d0 5.692d0 5.882d0 5.804d0 5.066d0 4.655d0 4.494d0 4.616d0 4.564d0 4.125d0 4.12d0 4.162d0 3.888d0 3.948d0 4.11d0 3.76d0 3.632d0 3.668d0 3.458d0 3.378d0 3.926d0 4.294d0 3.828d0 3.72d0 3.964d0 3.792d0 4.128d0 3.872d0 3.8d0 3.41d0 3.462d0 3.688d0 3.582d0 3.896d0 3.448d0 3.026d0 2.916d0 2.752d0 2.965d0 3.524d0 3.8d0 4.528d0 4.9d0 4.634d0 4.968d0 4.694d0 4.77d0 4.48d0 4.43d0 4.828d0 4.638d0 5.088d0 5.572d0 5.713d0 5.77d0 5.818d0 5.61d0 5.625d0 5.35d0 5.448d0 5.37d0 5.228d0 4.816d0 4.664d0 4.49d0 4.26d0 4.034d0 3.943d0 4.086d0 4.08d0 4.054d0 4.13d0 3.99d0 4.246d0 4.21d0 4.172d0 4.54d0 4.768d0 5.068d0 4.808d0 4.685d0 4.513d0 4.432d0 4.566d0 4.762d0 4.63d0 4.314d0 4.206d0 3.89d0 3.816d0 3.828d0 3.998d0 3.922d0 3.85d0 3.722d0 3.626d0 3.436d0 3.578d0 3.868d0 4.016d0 3.974d0 4.3d0 4.27d0 4.47d0 4.204d0 4.133d0 4.274d0 4.528d0 4.455d0 4.604d0 4.436d0 4.37d0 4.016d0 3.913d0 3.891d0 3.863d0 3.888d0 4.024d0 4.279d0 4.344d0 4.153d0 4.153d0 4.281d0 4.484d0 4.487d0 4.204d0 4.204d0 4.383d0 4.699d0 4.787d0 4.508d0 4.289d0 4.323d0 4.23d0 4.39d0 4.475d0 4.303d0 4.063d0 4.02d0 3.944d0 3.933d0 3.948d0 3.943d0 3.918d0 3.753d0 3.756d0 3.581d0 3.576d0 3.617d0 3.66d0 3.805d0 3.665d0 3.386d0 3.454d0 3.556d0 3.429d0 3.185d0 3.132d0 3.053d0 3.033d0 2.819d0 2.406d0 2.618d0 2.53d0 2.485d0 2.528d0 2.61d0 2.506d0 2.322d0 2.291d0 2.318d0 2.18d0 2.142d0 2.017d0 1.95d0 2.054d0 2.306d0 2.438d0 2.577d0 2.654d0 2.399d0 2.371d0 2.319d0 2.581d0 2.756d0 2.861d0 2.844d0 2.93d0 3.098d0 3.078d0 2.904d0 2.751d0 2.776d0 2.69d0 2.777d0 2.969d0 2.816d0 3.08d0 3.442d0 3.512d0 3.519d0 3.454d0 3.621d0 3.572d0 3.712d0 3.839d0 3.681d0 3.609d0 3.383d0 3.402d0 3.39d0 3.267d0 3.223d0 3.465d0 3.501d0 3.298d0 3.338d0 3.226d0 3.272d0 3.443d0 3.548d0 3.732d0 3.935d0 3.983d0 3.991d0 4.109d0 4.264d0 4.198d0 4.225d0 3.96d0 4.001d0 4.193d0 4.082d0 3.929d0 3.77d0 3.878d0 3.648d0 3.635d0 3.667d0 3.716d0 3.663d0 3.414d0 3.282d0 3.345d0 3.479d0 3.558d0 3.614d0 3.614d0 3.721d0 3.535d0 3.543d0 3.705d0 3.78d0 3.641d0 3.556d0 3.497d0 3.604d0 3.663d0 3.864d0 4.034d0 4.313d0 4.339d0 4.43d0 4.321d0 4.176d0 4.335d0 4.672d0 5.078d0 5.003d0 4.932d0 5.975d0 4.903d0 4.592d0 4.511d0 4.432d0 4.432d0 4.384d0 4.574d0 4.6d0 4.704d0 4.767d0 4.666d0 4.408d0 4.452d0 4.556d0 4.658d0 4.637d0 4.652d0 4.469d0 4.42d0 4.173d0 4.054d0 3.802d0 3.796d0 3.9d0 3.89d0 3.844d0 3.983d0 3.837d0 3.899d0 3.937d0 3.906d0 4.054d0 3.883d0 3.819d0 3.657d0 3.728d0 4.237d0 4.137d0 4.342d0 4.219d0 3.827d0 3.676d0 3.629d0 3.088d0 3.044d0 2.913d0 3.051d0 2.907d0 2.828d0 2.655d0 2.718d0 2.844d0 2.821d0 2.772d0 2.739d0 2.818d0 2.701d0 2.651d0 2.598d0 2.594d0 2.556d0 2.628d0 2.798d0 2.932d0 2.942d0 2.746d0 2.639d0 2.803d0 2.846d0 2.768d0 2.811d0 2.731d0 2.871d0 2.839d0 2.796d0 2.794d0 2.841d0 2.716d0 2.676d0 2.684d0 2.684d0 2.681d0 2.575d0 2.511d0 2.479d0 2.475d0 2.399d0 2.153d0 2.301d0 2.31d0 2.305d0 2.205d0 2.2d0 2.041d0 1.806d0 1.953d0 2.288d0 2.356d0 2.232d0 2.122d0 2.201d0 2.05d0 2.049d0 1.875d0 1.777d0 1.687d0 1.753d0 1.876d0 1.823d0 1.932d0 1.974d0 1.965d0 2.061d0 2.069d0 2.089d0 2.136d0 2.036d0 2.032d0 2.356d0 2.516d0 2.597d0 2.71d0 2.881d0 2.782d0 2.731d0 2.715d0 2.776d0 2.79d0 2.612d0 2.617d0 2.791d0 2.83d0 2.749d0 2.918d0 2.997d0 2.962d0 3.034d0 3.268d0 3.162d0 2.841d0 2.851d0 2.693d0 2.754d0 2.986d0 3.368d0 3.667d0 3.484d0 3.479d0 3.804d0 3.288d0 3.282d0 3.322d0 3.325d0 3.153d0 3.096d0 2.892d0 2.6d0 2.779d0 2.922d0 2.962d0 3.054d0 3.141d0 3.256d0 3.201d0 3.151d0 3.153d0 3.218d0 3.298d0 3.242d0 3.236d0 3.056d0 3.022d0 3.003d0 2.903d0 3.042d0 2.886d0 2.98d0 3.037d0 2.935d0 2.8d0 2.895d0 2.921d0 2.934d0 2.987d0 2.961d0 3.021d0 3.053d0 2.967d0 2.907d0 2.942d0 2.91d0 2.905d0 2.935d0 3.165d0 3.1d0 3.011d0 3.053d0 2.871d0 2.703d0 2.668d0 2.812d0 2.938d0 2.99d0 3.187d0 3.426d0 3.105d0 2.698d0 2.574d0 2.618d0 2.676d0 2.744d0 2.733d0 2.634d0 2.695d0 2.695d0 2.689d0 2.726d0 2.78d0 2.751d0 2.766d0 2.84d0 2.902d0 2.923d0 2.907d0 2.968d0 2.947d0 2.944d0 2.859d0 2.799d0 2.749d0 2.766d0 2.801d0 2.921d0 2.937d0 2.952d0 2.883d0 2.816d0 2.809d0 2.922d0 3.041d0 3.16d0 3.24d0 3.25d0 3.181d0 3.231d0 3.588d0 4.207d0 4.487d0 4.497d0 4.416d0 4.208d0 3.698d0 3.484d0 2.965d0 2.993d0 3.474d0 3.156d0 2.853d0 2.624d0 2.621d0 2.667d0 2.832d0 2.863d0 2.805d0 2.824d0 2.716d0 2.675d0 2.686d0 2.532d0 2.504d0 2.589d0 2.577d0 2.63d0 2.601d0 2.563d0 2.372d0 2.371d0 2.272d0 2.307d0 2.301d0 2.428d0 2.311d0 2.249d0 2.167d0 2.102d0 2.165d0 2.182d0 2.253d0 2.404d0 2.581d0 2.612d0 2.473d0 2.308d0 2.251d0 2.312d0 2.282d0 2.616d0 2.811d0 2.639d0 2.573d0 2.457d0 2.386d0 2.273d0 2.309d0 2.202d0 2.163d0 2.161d0 2.114d0 1.924d0 1.877d0 1.854d0 1.812d0 1.92d0 1.786d0 1.773d0 1.86d0 1.681d0 1.638d0 1.618d0 1.766d0 1.682d0 1.849d0 1.864d0 1.958d0 1.698d0 1.765d0 1.798d0 1.795d0 1.776d0 1.646d0 1.575d0 1.72d0 1.823d0 1.741d0 1.718d0 1.803d0 2.178d0 2.203d0 2.396d0 2.54d0 2.544d0 2.35d0 2.206d0 2.036d0 2.431d0 2.622d0 2.784d0 2.942d0 3.139d0 3.036d0 2.962d0 2.669d0 2.794d0 2.725d0 2.478d0 2.675d0 2.653d0 2.433d0 2.686d0 2.726d0 2.506d0 2.649d0 2.856d0 2.882d0 3.125d0 2.847d0 2.776d0 2.657d0 2.518d0 2.547d0 2.614d0 2.507d0 2.627d0 2.729d0 2.886d0 2.951d0 2.958d0 2.983d0 2.945d0 3.079d0 3.154d0 3.262d0 3.339d0 3.652d0 3.649d0 3.679d0 3.935d0 4.018d0 4.08d0 4 3.863d0 4.058d0 4.53d0 4.863d0 5.278d0 4.942d0 5.702d0 5.799d0 5.548d0 5.128d0 5.838d0 5.526d0 5.045d0 4.995d0 4.941d0 4.373d0 3.784d0 3.76d0 3.853d0 3.886d0 3.828d0 4.343d0 4.029d0 4.652d0 4.917d0 4.078d0 4.427d0 4.54d0 4.695d0 4.648d0 4.765d0 5.258d0 5.562d0 6.082d0 6.905d0 7.085d0 6.984d0 8.134d0 7.491d0 8.204d0 8.829d0 8.462d0 9.025d0 7.525d0 6.531d0 6.141d0 5.841d0 6.579d0 7.796d0 8.554d0 8.088d0 8.253d0 9.165d0 9.375d0 9.114d0 7.975d0 8.347d0 7.433d0 6.812d0 6.791d0 6.532d0 5.505d0 5.458d0 6.142d0 6.213d0 6.168d0 6.972d0 6.779d0 5.795d0 6.704d0 5.317d0 4.756d0 3.898d0 3.667d0 3.337d0 3.165d0 2.539d0 2.476d0 2.421d0 2.253d0 2.813d0 2.557d0 2.494d0 2.222d0 2.086d0 2.092d0 2.114d0 2.269d0 2.292d0 2.188d0 2.23d0
(mean (column energy_prices 'NG))
4\.054103853690407d0

Author: Matt Brigida, Ph.D.

Created: 2023-07-14 Fri 16:23

Validate