I'm looking to save an expression like this:
expression <- c(beta_a*a + beta_b*b + beta_d*d)
And I want to return this expression:
expression
> beta_a*a + beta_b*b + beta_d*d
But when I try to run the first line, it just says the error "Object 'beta_a' not found".
Ultimately, I'm using this for Apollo for an ordered logit model, where I have to make 60 different utility specifications. I thought it would be easier bundle the specifications into a short expression, so I can rerun the same code only changing the specification. A specification both consists of defining the beta variables and the utility functions. I was able to use this method for the beta values that have a structure like this:
betas = c(beta_a = 0, beta_b = 0, beta_d = 0)
To turn it into this:
b_specification1 <- c(beta_a = 0, beta_b = 0, beta_d = 0)
betas = b_specification1
But doing the utility function:
u_specification1 <- c(beta_a*a + beta_b*b + beta_d*d)
utility = u_specification1
Gives the error "object 'beta_a' not found". Both b_specification1 and u_specification1 are run before betas and utility.