similar to: Moving window regressions - how can I improve this code?

Displaying 20 results from an estimated 200 matches similar to: "Moving window regressions - how can I improve this code?"

2008 Aug 18
1
"nested" getInitial calls; variable scoping problems
Hi All, Another nls related problem (for background, I'm migrating a complicated modelling package from S-plus to R). Below I've reduced this to the minimum necessary to demonstrate my problem (I think); the real situation is more complicated. Two similar selfStart functions, ssA and ssB. The 'initial' function for ssB modifies its arguments a little and then calls getInital
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 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 "x" in the call to mCall by the actual
2006 May 24
1
problem-nlme
Hi, I have great problems with my work in R. I look for to model the growth of fish. I have "Longitudinal data", a serie of repeated measures for each individual. Using the corresponding packages "nlme" in R. I treat to fit to the data different growth functions, wich were entered by me. Unfortunately for no it was arrived at the convergence, several error messages appeared. I
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
2005 Sep 01
1
making self-starting function for nls
Hello. Following pages 342-347 of Pinheiro & Bates, I am trying to write a self-starting nonlinear function (a non-rectagular hyperbola) to be used in nonlinear least squares regression (and eventually for a mixed model). When I use the getInitial function for my self-starting function I get the following error message: > getInitial(photo~NRhyperbola(Irr,theta,Am,alpha,Rd),dat) Error
2002 Jul 19
1
selfStart function problem
Hello, list, I am making a self-starting nonlinear function to model the relation of tree height (H) and diameter (D) in a forest stand. The function I am trying is H=a*exp[b*(D+5.8)^(-c)]. To calculate the initial estimates of the parameters, I linearized the formula by taking logarithms and fixing the parameter c=1. Then I calculated the initial estimates of a and b using lm() on the
2008 Aug 29
1
nls() fails on a simple exponential fit, when lm() gets it right?
Dear R-help, Here's a simple example of nonlinear curve fitting where nls seems to get the answer wrong on a very simple exponential fit (my R version 2.7.2). Look at this code below for a very basic curve fit using nls to fit to (a) a logarithmic and (b) an exponential curve. I did the fits using self-start functions and I compared the results with a more simple fit using a straight lm()
2007 Apr 20
1
nlme trouble
I am not certain how nlme works so I followed an example from the web ( http://www.menne-biomed.de/gastempt/gastempt1.html). I was able to successfully reproduce the example. However, when I modified my the example to use my data and with my formula, I get a set of errors having to do with the log() function. I get 10 of them (all exactly the same) and there are 10 levels in my factor variable.
2004 Oct 30
1
Destructive str(...)?
I have encountered a strange behavior of the str function - it seems to modify the object that is displayed. Probably I'm using something 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
2009 Sep 21
1
How to use nls when [selfStart] function returns NA or Inf??
Hi Everyone, I posted this a couple of weeks ago with no responses. My interface (via gmane) seemed a bit flakey at the time, so I'm venturing to repost with some additional information. I'm trying to write selfStart non-linear models for use with nls. In these models some combinations of parameter values are illegal; the function value is undefined. That's OK when calling the
2009 Oct 17
1
custom selfStart model works with getInitial but not nls
Hello, I'm having problems creating and using a selfStart model with nlme. Briefly, I've defined the model, a selfStart object, and then combined them to make a selfStart.default model. If I apply getInitial to the selfStart model, I get results. However, if I try usint it with nls or nlsList, these routines complain about a lack of initial conditions. If someone could point out
2003 Jan 30
1
as.formula(string) and augPred in lme
Using formulas constructed from strings only partially works for me in lme: library(nlme) data(Orthodont) fm2<-lme(as.formula("distance~age"),data=Orthodont,random=~1|Subject) summary(fm2) # works augPred(fm2) # fails #Error in inherits(object, "formula") : #Argument "object" is missing, with no default I assume that my use of as.formula is wrong, but
2009 Sep 04
1
How should a SelfStart function handle illegal parameter values?
Hi Everyone, I'm trying to write selfStart non-linear models for use with nls. In these models some combinations of parameter values are illegal; the function value is undefined. That's OK when calling the function directly [e.g. SSmodel(x, pars...)]; I return an appropriate non-value such as NA or Inf. However, when called from nls [e.g. nls(y~SSmodel(x, pars...), ...)] those
2001 Nov 19
1
scope of data in groupedData
I'm trying to write a function that has a dataframe as an argument. Within the function, I call groupedData to create a grouped-data object from the dataframe argument. However, the groupedData function doesn't seem to see the data. I'm guessing it's getting the argument name rather than its value, but I'm not positive. My system: R 1.3.1 on WinNT 4.0 (Pentium II), nlme
2011 Jun 17
2
Non-linear Regression best-fit line
I am trying to fit a curve to a cumulative mortality curve (logistic) where y is the cumulative proportion of mortalities, and t is the time in hours (see below). Asym. at 0 and 1 > y [1] 0.00000000 0.04853859 0.08303777 0.15201970 0.40995074 0.46444992 0.62862069 0.95885057 1.00000000 [10] 1.00000000 1.00000000 > t [1] 0 13 20 24 37 42 48 61 72 86 90 I tried to find starting values for
2006 Mar 24
1
predict.glmmPQL Problem
Dear all, for a cross-validation I have to use predict.glmmPQL() , where the formula of the corresponding glmmPQL call is not given explicitly, but constructed using as.formula. However, this does not work as expected: x1<-rnorm(100); x2<-rbinom(100,3,0.5); y<-rpois(100,2) mydata<-data.frame(x1,x2,y) library(MASS) # works as expected model1<-glmmPQL(y~x1, ~1 | factor(x2),
2001 May 30
2
environments
I would like to be able, inside a function, to create a new function, and use it as part of a formula as an argument to, say, gnls or nlme. for example: MyTop <- function(data=dta) { Cexp <- function(dose,A,B,m){...} Model <- as.formula(paste("y","~ Cexp(",paste(formals(Cexp),collapse =", "),")")) MyCall <-
2009 Jun 09
1
Non-linear regression/Quantile regression
Hi, I'm relatively new to R and need to do a quantile regression. Linear quantile regression works, but for my data I need some quadratic function. So I guess, I have to use a nonlinear quantile regression. I tried the example on the help page for nlrq with my data and it worked. But the example there was with a SSlogis model. Trying to write dat.nlrq <- nlrq(BM ~ I(Regen100^2),
2013 Dec 03
2
[PATCH 1/2] ppc64: Add ppc64le support
Add PowerPC 64bit little endian support. Signed-off-by: Anton Blanchard <anton at samba.org> --- Makefile | 7 +++++-- usr/klibc/arch/ppc64/MCONFIG | 4 ++-- usr/klibc/arch/ppc64/crt0.S | 34 ++++++++++++++++++++----------- usr/klibc/arch/ppc64/setjmp.S | 40 ++++++++++++++++++++++++++---------- usr/klibc/arch/ppc64/sysstub.ph | 45