search for: mcall

Displaying 20 results from an estimated 51 matches for "mcall".

Did you mean: call
2008 Aug 18
1
"nested" getInitial calls; variable scoping problems
...d getInitial calls, but it doesn't seem helpful, and I certainly couldn't trust my understanding of it. I'm considering making up the matched call and calling the 'initial' function of ssA directly, in the same manner as getInitial.selfStart attr(ssA, "initial"))(mCall = mCall, data = data, LHS = LHS) or perhaps if I call getInitial thus... getInitial(ssA, data, mCall, LHS = NULL, ...) it will call getInitial.selfStart without calling getInitial.formula. In that case perhaps eval(... parent.frame()) will find the argument? Or, at least I could attach the arg...
2005 Sep 07
1
summary of problem with mCall function.
Last week I posted a question concerning the mCall function, which is used to create self-starting functions and is described in the book by Pinheiro, J.C. and Bates, D.M. (Mixed-effects models in S and S-PLUS). On page 345 one finds the following call: xy<-sortedXyData(mCall[["x"]], LHS,data) It is necessary to replace the &qu...
2012 Mar 06
2
[LLVMdev] Performance degradation when repeatedly exchanging JITted functions
...ructions. Another drawback is that the memory of old function memory can never be freed, since it is still used in the jump chain. To measure the performance impact of this, I wrote a small example program, where each second the function is recompiled and the number of method calls is printed (Mcalls = million calls). The performance degradation is quite impressive: After 0 replacements: 335.724 Mcalls/sec After 1 replacements: 274.735 Mcalls/sec ( 82.010% of initial) After 2 replacements: 232.640 Mcalls/sec ( 69.445% of initial) After 3 replacements: 201.898 Mcalls/sec (...
2006 May 24
1
problem-nlme
...# differents growth function #vonBertlalanffy vonBert<- function(x, Linf, K, t0) Linf*(1-exp(-K*(x-t0))) size ~ vonBert(age, Linf, K,t0) vonBert <-deriv(~ Linf*(1-exp(-K*(x-t0))), c("Linf","K","t0"),function(x,Linf,K,t0){}) vonBertInit <- function(mCall, LHS, data) { xy <- sortedXyData(mCall[["x"]], LHS, data) Linf <- 900 if (Linf != max(xy[,"y"])) Linf <- -Linf K <- 0.3 t0<-0 value <- c(Linf, K, t0) names(value) <- mCall[c("Linf", "K","t0")] value...
2008 Aug 04
0
Unexpected nls behaviour: Solved
Hi Everyone, I'd omitted the non-optional 'parameters' argument to selfStart. Making this change to SSbatch gives the same (successful) result from the two calls to nls. SSbatch<-selfStart( model=function(Batch, Coeffs) { Coeffs[Batch] } ,initial=function(mCall, data, LHS) { # Estimate coefficients as mean of each batch xy <- sortedXyData(mCall[["Batch"]], LHS, data) Batch <- data[[as.character(mCall[["Batch"]])]] # check Batch is successive integers starting at 1 if ((min(xy$x) !=1) | (any(diff(xy$x)!=1))) stop( &...
2000 Jul 24
1
How to use groupedData() within a function?
Dear Group: I have been trying to write an R function within which the function groupedData() would be used. The following is a sample program: ####################### sid<-rep(1:6,times=2) time<-c(1:12) trt<-rep(letters[1:3],times=4) tem<-data.frame(sid,time,trt) test1.fun<- function(dat=dat) { groupedData(time ~ trt|sid, data=dat) } test1.fun(dat=tem)
2005 Sep 01
1
making self-starting function for nls
...ta,Am,alpha,Rd),dat) Error in tapply(y, x, mean, na.rm = TRUE) : arguments must have same length Since I do not explicitly call tapply in my function that makes NRhyperbola a self-starting function (called NRhyperbolaInit, see below), I assume that the error is coming from within the mCall function but I can't figure out where or how. Would someone who has successfully done this be willing to look at my code and see where the problem arises? > NRhyperbolaInit function(mCall,LHS,data) { xy<-sortedXyData(mCall[["x"]],LHS,data) if(nrow(xy)<3){ stop(...
2009 Nov 12
0
writing selfStart models that can deal with treatment effects
...ype treatments using selfStart models Following Ritz and Streibig (2009), I wrote the following routines: ##Selfstart expDecayAndConstantInflowModel <- function(Tb0, time, aL, aN, T0){ exp(-time*aL)*(T0*aL+(-1+exp(time * aL))*Tb0 * aN)/aL } expDecayAndConstantInflowModelInit <- function(mCall, LHS, data){ print(paste("SelfStart mCall:", mCall)); print(attributes(mCall)); print(mCall[["aN"]]); xy <- sortedXyData(mCall[["time"]], LHS, data); lmFit <- lm(log(xy[, "y"]) ~ xy[, "x"]); coefs <- coef(lmFit); T0 &l...
2008 Aug 29
1
nls() fails on a simple exponential fit, when lm() gets it right?
...,12.0,12.1,14.9,15.1,15.2,15.5) height=c(5.770089,5.154794,4.888847,6.356770,14.849109,14.973146,15.423816,14.865038,21.335985,20.477624,20.915823,21.886004,23.714724,24.182210,23.954929,23.784659,25.334360,25.411320,26.218614,25.612478) #&#&#height=5*exp(0.03*dbh) logarithmicInit=function(mCall,LHS,data) { xy=sortedXyData(mCall[["x"]],LHS,data) aaa=0.01 #Just guess aaa=0.01 to start the fit bbb=min(xy$y) #Use the minimum y value as an initial guess for bbb value=c(aaa,bbb) names(value)=mCall[c("aaa","bbb")] return(value) } fmla=as.formula("~(aaa...
2002 Jul 19
1
selfStart function problem
...ot;, but I have not found how to get the program handle it correctly. Has someone any idea? I am using R1.5.1 on Windows NT. Lauri My code is > dhexp <- deriv(~ a*exp(b*(D+5.8)^(-c)), c("a","b","c"), function(D,a,b,c) {} ) > > dhexpInit <- function(mCall, LHS, data) { + equation <- paste('log(',LHS,') ~ I((',mCall[["D"]],'+5.8)^-1.0)') + print(equation) + linear <- lm(as.formula(equation),data=data) + value <- c(exp(coef(linear)[1]), coef(linear)[2], 1.0) + names(value) <- mCall[c(&q...
2007 Apr 20
1
nlme trouble
...you will recreate what I did. If you think that the data is at fault and want to see it, I can provide it. Also, under the code is the errors that I get when I run the nlsList function. Also, can nlme handle more than one independent at a time? And I was wondering what the "model=as.character(mCall[[1]])" line in the code did. Removing it does not seem to change the error that I receive. My OS is WinXP. Thank You in advance, Chris ###########List of the code that I modified with comments########## library(nlme) BiLinInit0= function(mCall,LHS,data) { model=as.character(mCall[[1]]...
2005 Oct 26
0
self starting function for nonlinear least squares.
...# Am is the maximum gross photosynthetic rate # Rd is the dark resiration rate (positive value) # theta is the shape parameter # alpha is the initial quantum yeild # (1/(2*theta))* (alpha*Irr + Am - sqrt((alpha*Irr + Am)^2 -4*alpha*theta*Am*Irr))- Rd } attr(,"initial") function (mCall, LHS, data) { xy <- sortedXyData(mCall[["Irr"]], LHS, data) if (nrow(xy) < 3) stop("Too few unique irradiance values") fit <- smooth.spline(xy[, "x"], xy[, "y"]) alpha <- predict(fit, x = 0, deriv = 1)$y if(min(x...
2008 Sep 26
0
The 'data' argument and scoping in nls
...use? Can someone point me in the right direction? I'm using nls to fit models where some non-optimised parameters are different lengths from the data, often matrices, something like this ... ---------- SSfunc <- selfStart( model = function(x, Coeff, A) { }, initial = function(mCall, data, LHS) { }, parameters = c("Coeff") ) y <- ... x <-... A <- ... nls(y ~ SSfunc(x, Coeff, A), data=...) -------------------- ... where A may be a matrix. This means that A cannot be stored in a data.frame with y and x, so I can't use (for exampl...
2012 Sep 09
1
Sum of column from another df based of row values of df1
Dear All, I need to sum a column from another dataframe based on the row values of one dataframe. I am stuck in a loop trying to accomplish it and at current speed it will take more than 80 hours to complete. Needless to say I am looking for a more elegant/quicker solution. Really need some help here. Here is the issue: I have a dataframe CALL (the dput of head is given below) which has close to
2010 Apr 15
0
nlsList {nlme} - control arguments problem
...irng an nlsList fit. He suggested using optim to optimize the parameters prior to each fit. This worked well for me as I had a customized selfStart function that then optimized the parameters for each individual separately. if you rewrote your selfStart function as: powrDpltInit <- function(mCall, LHS, data) { xy <- sortedXyData(mCall[["x"]],LHS,data) min.s <- min(y) dif.s <- max(y)-min(y) dplt.s <- 0.5 p.s <- -.20 value <- c(min.s, dplt.s, dif.s, p.s) #function to optimize func1 <- function(value) { min.s <- value[1]...
2004 Apr 24
4
Moving window regressions - how can I improve this code?
I wrote a function which does "moving window" regressions. E.g. if there are 100 observations and the window width is 50, then I first run the regression for observations 1..50, then for 2..51, and so on. I am extremely pleased with R in my experience with writing this, since I was able to pass the model as an argument into the function :-) Forgive me if I sound naive, but that's
2008 Aug 01
0
Unexpected nls behaviour
...should be exactly equivalent > nls(Aform, DF) > nls(Aform, DF, start=getInitial(Aform, DF)) but in this example that is not the case in R (although it is in S-plus V6.2) ------------------------------ SSbatch<-selfStart( model=function(Batch, Coeffs) { Coeffs[Batch] } ,initial=function(mCall, data, LHS) { # Estimate coefficients as mean of each batch xy <- sortedXyData(mCall[["Batch"]], LHS, data) Batch <- data[[as.character(mCall[["Batch"]])]] # check Batch is successive integers starting at 1 if ((min(xy$x) !=1) | (any(diff(xy$x)!=1))) stop( &...
2004 Oct 30
1
Destructive str(...)?
...ng unsupported (objects consisting just of an external reference), but still I'm curious as of why this happens. I create (in C code) EXTPTRSXP and associate a class to it via SET_CLASS. Such objects works fine until it's passed to str as the following output demonstrates: > c<-.MCall("RController","getRController") > c [1] "<RController: 0x3be5d0>" > str(c) Class 'ObjCid' length 1 <pointer: 0x3be5d0> > c <pointer: 0x3be5d0> > str(c) length 1 <pointer: 0x3be5d0> The .MCall basically produces an extern...
2009 Sep 21
1
How to use nls when [selfStart] function returns NA or Inf??
...ribute) Error in qr.default(.swts * attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call (arg 1) A toy example demonstrating my problem (legal values of param are >1): #----------- SSexample<-selfStart( model=function(x, param) x^log(param-1), initial = function(mCall, data, LHS){ val<- 1.001 names(val) <- mCall[c("param")] val }, parameters=c("param") ) #---------------- nls(y~SSexample(x, par), data=data.frame(x=1:10,y=rnorm(10))) #--------- (repeat the last line a few times and you'll get the error). I can't se...
2009 Oct 17
1
custom selfStart model works with getInitial but not nls
...ppreciate it. Details: ## Nonlinear model I want to fit to the data const.PBMC.tcell.model <- function(B0, t, aL, aN, T0){ Tb0 = B0; x = exp(-log(aL) + log(T0*aL+(-1+exp(t * aL))*Tb0 * aN) - t * aL); return(x); } ##Define selfStart routine const.PBMC.tcell.selfStart<- function(mCall, LHS, data){ t0 = 0; t1 = 24; t2 = 48; ##Get B0 Value B0 = data[1, "B0"]; T0 = mean(data[data$Time==t0, "Count"]); T1 = mean(data[data$Time==t1, "Count"]); T2 = mean(data[data$Time==t2, "Count"]); if(T0 < T2){ ##increase --...