Symbolic operations in R

2

I need to multiply two arrays in R , one has symbolic ( beta ) and the other is a numeric array ( X ), % and Ryacas , but I could not get it to work. After that, I need to derive the f function in relation to beta0 and then in relation to beta1 . below is the code:

library(Deriv)
library(Ryacas)
#library(rSymPy)
n=2
#Vetor de 1's
const1 <- rep(1,n);
const <- cbind(const1);
#Vetor de cováriavel com distribuição unif(0,1)
X1=matrix(runif(n, 0, 1),nrow=n,ncol=1)
#Matriz de covariáveis
X <-matrix(c(const,X1),nrow=n,ncol=ncol(X1)+1)
p=ncol(X)
beta0 <- Sym("beta0")
beta1 <- Sym("beta1")
alpha <- Sym("alpha")
y <- Sym("y")
beta=matrix(c(beta0,beta1),nrow=2,ncol=1)
mu1=exp(X%*%beta)
f <- quote(mu1*y^2+mu1*alpha)
f1 <- Deriv(f,"beta0")
f2 <- Deriv(f,"beta1")

Does anyone have any suggestions on how I can do these calculations?

    
asked by anonymous 03.11.2016 / 03:18

0 answers