Displaying 1 result from an estimated 1 matches for "fo0".
Did you mean:
f0
2007 Jun 01
1
object not found inside function
...running the following code I get the message: Error in eval(expr,
envir, enclos) : object "A" not found
fm <- function(p,ydata, env = parent.frame()) {
#fit model y ~ (b0+b1x1+...+bpxp)*exp(g2plus*z2plus) where bi and g2plus
are parameters
#create design matrix for linear part
fo00 <- paste("~",paste(paste("x",1:p,sep=""),collapse="+"),sep="")
fo0 <- as.formula(fo00)
A <- model.matrix(fo0,data=ydata)
# create z variable
z2plus <- ifelse(totx>1,1,0)
ydata <- data.frame(ydata,z2plus)
#run model
t...