I am trying to pass a numpy array to the GAMLSS package in R.
import numpy as np
import rpy2.robjects as robjects
from rpy2.robjects import numpy2ri
numpy2ri.activate()
r = robjects.r
r.library("gamlss")
r.library("gamlss.mx")
L = r['data.frame'](np.array(np.random.normal(size=1000),
dtype=([('x', np.float), ('y', np.float), ('z', np.float)])))
r.gamlssMX(robjects.Formula('z~1'), data=L)
Running this returns
Error in y0 - f0 : non-conformable arrays
Yet I can pass the data frame to the linear model R function.
lm = r.lm(robjects.Formula('x~y'), data=L)
print r.summary(lm.rx())
I have got a load of code that reads a binary file in Python but would like to use the R package, hence the need for rpy2.
-- EDIT --
As an example in R:
x <- data.frame(z=c(rnorm(1000), rnorm(1000, mean=4)))
gamlssMX(z~1, K=1, data=x)