In a recent blog post I used something like this (for use in a call to optim()):
obj_fun_expr <- expression((x^4 + 4 * x^2 * y^2 - 12 * x^2 * a + 144 * x^2 - 48 * x * y * a + 144 * x * y - 4320 * x + 36 * y^2 - 2160 * y + 180 * a^2 + 32400)/16) f_expr <- function(par) { x <- par[1] y <- par[2] a <- par[3] val <- eval(obj_fun_expr, list(x = x, y = y, a = a)) return(val) } I have been wondering what the cost of eval(expr, .

Let \(\rho_{XY}\) be the correlation between the stochastic variables \(X\) and \(Y\) and similarly for \(\rho_{XZ}\) and \(\rho_{YZ}\). If we know two of these, can we say anything about the third?
In a recent blog post I dealt with the problem mathematically and I used the concept of a partial correlation coefficient. Here I will take a simulation approach.
First z is simulated. Then x and y is simulated based on z in a regression context with a slope between \(-1\) and \(1\).

It is important to test software. One approach is unit-testing, and for R packages this can e.g. be done using testthat.
It is also important to document software. For R packages roxygen2 is really helpful: It enables you to write documentation in the code file in the R/ folder where the function is implemented. And then roxygen2 takes care of handling the Rd files in the man/ folder.
I have made a new R package that combines these approaches: roxytest.

Update Aug 10, 2019: I wrote a new blog post about the same as below but using a simulation approach.
Update Aug 27, 2019: Minor change in how equations are solved (from version 0.9.0.9122).
Let \(\rho_{XY}\) be the correlation between the stochastic variables \(X\) and \(Y\) and similarly for \(\rho_{XZ}\) and \(\rho_{YZ}\). If we know two of these, can we say anything about the third?
Yes, sometimes, but not always.

Update Aug 27, 2019: I wrote a new blog post showing that Ryacas can now solve the system of equations directly without using optim().
As you may know, I am maintaining the Ryacas package (with online documentation) for doing symbolic mathematics (and other stuff) in R using the yacas software (with online documentation).
Søren Højsgaard and I have been preparing a new major release of Ryacas (see blog post on it).

I am learning how to play piano. In that process, I needed charts with piano chords. I know it is good practise to construct the chords manually, figure out the inversions and so on, but I found that some aspects of learning were improved with a chord chart. I searched the (entire!) internet, and struggled to find good, customisable charts.
Thus I had to make something myself: pichor, an R package for making and working with piano chords in R.

Update Aug 27, 2019: Minor change in how equations are solved (from version 0.9.0.9122).
We (Søren Højsgaard and I) are preparing a new major release of Ryacas (GitHub). It will have a new interface to yacas that is thinner, cleaner and more robust. It relies on yacas’s RForm() function rather than an OpenMath XML interface.
It also means that the API has changed in Ryacas: new functions are introduced and old ones deprecated.

© 2021 · Powered by the Academic theme for Hugo.