search for: varindex

Displaying 8 results from an estimated 8 matches for "varindex".

2008 Jun 26
3
bug in nls?
...) Error in parse(text = x) : unexpected end of input in "~ " coef(nls(DF[,2]~a*DF[,1]^b, start=list(a=3, b=.7))) Error in parse(text = x) : unexpected end of input in "~ " # but this does not Browse[1]> debug: mf$formula <- as.formula(paste("~", paste(varNames[varIndex], collapse = "+")), env = environment(formula)) Browse[1]> Error in parse(text = x) : unexpected end of input in "~ " > Actually the problem is that with calling nls with DF[,n]~... varNames and varIndex is not correctly specified. I am not sure if this behaviour...
2008 Aug 05
1
Fix for nls bug???
...ils nls(y ~ Myfunc(cbind(x1, x2), bMat, aVec), DF, start=list(aVec=c(1,2))) # # pass in the same matrix other than by name and it works nls(y ~ Myfunc(cbind(x1, x2), matrix(c(1,1,0,0), 2, 2), aVec), DF, start=list(aVec=c(1,2))) I think the problem lies in this line in nls for (var in varNames[!varIndex]) mf[[var]] <- eval(as.name(var), data, env) This adds values for some named arguments (bMat) as columns of the data frame. The problem is that generally they don't have the same number of rows. I've made it work for my example by replacing that line with this line, which adds value...
2012 Jul 03
1
nls problem
...===================================== # purpose: to demonstrate an apparent problem with `nls' which occurs, # if the model is specified by passing th lhs as an evaled 'call' # object. The problem is related to the way `nls' tries to compute # its internal variable `varIndex' which rests on the assumption that # the dependent ("y") and, possibly, the independent ("x") variable # are identified by having a length equal to the `nls' variable # `respLength'. the problem arises when there are `varNames' # components accid...
2006 Sep 15
1
Formula aruguments with NLS and model.frame()
...subset, weights, na.action, model = FALSE, lower = -Inf, upper = Inf)); mWeights<-F;#missing(weights); start=list(w=.5,a=.1,p=.5,b=init.y$coef[2],int=init.y$coef[1] ); pnames <- names(start); varNames <- varNames[is.na(match(varNames, pnames, nomatch = NA))] varIndex <- sapply(varNames, function(varName, data, respLength) { length(eval(as.name(varName), data))%%respLength == 0}, data, length(eval(formula[[2]], data)) ); mf$formula <- as.formula(paste("~", paste(varNames[varIndex], collapse = "+&...
2006 Sep 07
0
Help understanding how nls parses the formula argument to estimate the model
...E, subset, weights, na.action, model = FALSE, lower = -Inf, upper = Inf)); mWeights<-F;#missing(weights); start=list(w=.5,a=.1,p=.5,b=init.y$coef[2],int=init.y$coef[1] ); pnames <- names(start); varNames <- varNames[is.na(match(varNames, pnames, nomatch = NA))] varIndex <- sapply(varNames, function(varName, data, respLength) { length(eval(as.name(varName), data))%%respLength == 0}, data, length(eval(formula[[2]], data)) ); mf$formula <- as.formula(paste("~", paste(varNames[varIndex], collapse = "+&quot...
2006 Sep 21
0
Help understanding how nls parses the formula argument to estimate the model
...subset, weights, na.action, model = FALSE, lower = -Inf, upper = Inf)); mWeights<-F;#missing(weights); start=list(w=.5,a=.1,p=.5,b=init.y$coef[2],int=init.y$coef[1] ); pnames <- names(start); varNames <- varNames[is.na(match(varNames, pnames, nomatch = NA))] varIndex <- sapply(varNames, function(varName, data, respLength) { length(eval(as.name(varName), data))%%respLength == 0}, data, length(eval(formula[[2]], data)) ); mf$formula <- as.formula(paste("~", paste(varNames[varIndex], collapse = "+&...
2001 Feb 19
2
problems sourcing in vs interactive
If I source in the function (see below) calib(), I get: > source("papers/helle/threshold.r") > calib() Error in eval(expr, envir, enclos) : Object "energy" not found But if I cut and paste the code for calib() one line at a time into the R window it works fine. calib<-function() { contrast<-c(.01,.02,.0325,.055,.0775,.1,.125,.15,.175,.2)
2003 Aug 07
2
model.frame() call from inside a function (PR#3671)
R version: 1.7.1 OS: Red Hat Linux 7.2 Hi all, The formula object in model.frame() is not retrieved properly when model.frame() is called from within a function and the "subset" argument is supplied. foo <- function(formula,data,subset=NULL) { cat("\n*****Does formula[-3] == ~y ?**** TRUE *****\n") print(formula[-3] == ~y) cat("\n*****Result of model.frame()