[R] predictNLS {propagate} bug for multiple predictors?
Patrick Gauthier
pgauthi1 at lakeheadu.ca
Wed Sep 3 15:15:35 CEST 2014
Many R users have requested means to generate prediction/confidence
intervals
for their non-linear models in R. The propagate packages offers this
service. However, I'm having issues when applying predictNLS to my model.
Has anyone else had issues with predictNLS?
Here is my simple problem.
t <- c(194.84, 95.62, 40.87, 31.64, 0.00)
m <- c(0.00, 2.29, 4.72, 10.95, 28.36)
t0 <- t[1]
m0 <- m[5]
dat <- data.frame(t = t, m = m)
nlls <- nls(m ~ (m0 ^ (1 / lambda) - (t * m0 / t0) ^ (1 / lambda)) ^ lambda,
start=list(lambda = 1), data = dat)
xv <- seq(0,t0, length.out = 100)
library(propagate)
predictNLS forces me to redefine m0 and t0, which are constants in the
model.
predictNLS(nlls, newdata = data.frame(t = xv))
/Error in predictNLS(nlls, newdata = data.frame(t = xv, t0 = t0, m0 = m0)) :
newdata should have name(s) m0tt0!/
OK, predict.nls doesn't have this issue. But, let's just give it what it
wants. Notice the predictors needs to be defined in the right order as
well. .
predictNLS(nlls, newdata = data.frame(m0 = m0, t = xv, t0 = t0))
/Propagating predictor value #1 ...
Error in propagate(expr = EXPR, data = DF, use.cov = COV, alpha = alpha, :
Names of input dataframe and var-cov matrix do not match!/
I'm not sure what else I can do here to fix the problem, as the issue seems
to be related to names, which predictNLS has accepted until it's internal
use of propagate(). My model is quite simple (i.e., plot the data and see).
The predictNLS works fine on the example provided in the packages
documentation which has only one predictor. Could this be where
the error is being generated (i.e., multiple predictors)? What am I doing
wrong here?
Thanks for any help/advice,
--
Patrick Gauthier
PhD Candidate
Faculty of Natural Resources Management
Lakehead University
Office: BB-1007-D (tel. 807 766-7127)
Lab: BB-1071-A (tel. 807 343-8739)
http://abel.lakeheadu.ca/index.shtml
http://forward.lakeheadu.ca/gradstudents.htm
[[alternative HTML version deleted]]
More information about the R-help
mailing list