[R-pkg-devel] Errors in my package

2018-05-24 Thread Steven Spiriti
To Whom It May Concern:

I have created a package called "freeknotsplines" in R, and I need to
make a few updates to it.  I resubmitted the package, and received the
following error message:

checking examples ... ERROR
Running examples in ‘freeknotsplines-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: coef.freekt
> ### Title: Compute Coefficients of B-Splines For Free-Knot Splines
> ### Aliases: coef.freekt
> ### Keywords: nonparametric regression smooth
>
> ### ** Examples
>
> x <- 0:30/30
> truey <- x*sin(10*x)
> set.seed(10556)
> y <- truey + rnorm(31, 0, 0.2)
> xy.freekt <- freelsgen(x, y, degree = 2, numknot = 2, 555)
> coef(xy.freekt)
Error: $ operator not defined for this S4 class
Execution halted

 This error occurs in one of the examples in the documentation.   It is
platform dependent, and does not occur on the machine I am using to create
the package.  freekt is a new class, which is intended to be a S3 class,
not a S4 class.

 Here is the code for coef.freekt:

coef.freekt <- function(object, ...)
{
  xdat <- object@x
  ydat <- object@y
  optknot <- object@optknot
  ord <- object@degree + 1
  lambda <- object@lambda
  fulloptknot <- c(rep(min(xdat), ord), optknot, rep(max(xdat), ord))  #
includes endpoints
  Xmat <- splineDesign(fulloptknot, xdat, ord)
  if ((lambda == 0) | (length(optknot) == 0))
coef <- solve(t(Xmat)%*%Xmat, t(Xmat)%*%ydat)
  else
{
  numknots <- length(optknot)
  Amat <- chgbasismat(fulloptknot, ord)
  Istar <- diag(c(rep(0, times = ord), rep(1, times = numknots)))
  coef <- solve(t(Xmat)%*%Xmat + lambda*t(Amat)%*%Istar%*%Amat,
t(Xmat)%*%ydat)
    }
  return(coef)
}

Can someone please help me figure out what I am doing that is causing this
error?

Sincerely,

Steven Spiriti

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Errors in R package - Updated

2018-05-25 Thread Steven Spiriti
quot;genetic"))
funcname <- "freelsgen"
  if ((alg == "LS") && (search == "golden"))
funcname <- "freelsgold"
  if ((alg == "PS") && (search == "genetic"))
funcname <- "freepsgen"
  if ((alg == "PS") && (search == "golden"))
funcname <- "freepsgold"
  for (numknot in seq(from = minknot, to = maxknot))
  {
  currcall <- call(funcname, x, y, degree, numknot, seed, stream)
  currfit <- eval(currcall)
  currcrit <- switch(knotnumcrit, GCV = currfit@GCV,
  AIC = AIC(currfit, k = k), adjAIC = adjAIC.freekt(currfit),
  AICc = AICc.freekt(currfit), BIC = BIC(currfit),
  adjGCV = adjGCV.freekt(currfit, d))
  print(paste("Number of knots = ", numknot, ", ", knotnumcrit,
  " = ", currcrit, sep = ""), quote = FALSE)
  if (currcrit < bestcrit)
  {
  bestcrit <- currcrit
  answer <- currfit
  }
  }
  return(answer)
}

 I am still not clear on what is causing this error.

Sincerely,

Steven Spiriti

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel