On Aug 16, 2014, at 1:54 AM, Lotte de Vries wrote:
snipped all of your and my earlier material because you have included 
everything needed for an answer in your current question..

> > 
> 
> Hi David, 
> 
> Let me try this again, apologies. 
> 
> I'm trying to run the package posum
> (http://www.maths.bath.ac.uk/~sw283/simon/posum.html), 
> which is an old package and therefore relies on an old version 
> of the package mgcv (version 0.8-7). 
> 
> I'm trying to run these packages using R version 3.1.0 on 
> windows 8 computer( x86_64-w64-mingw32/x64 (64-bit)). 
> 
> When I run the example code given in the posum package I get 
> an error. The code I'm trying to run is: 
> 
> data<-population.data(fam="p",adult=TRUE) #simulate data
> b<-posum(data,fam="p")
> 
> The second line gives an error and a warning: 
> 
> Error in .C("spline_coef", method = as.integer(method), 
> n = n, x = as.double(x),  : 
>   "spline_coef" not available for .C() for package "stats"
> In addition: Warning message:
> In if (d < 0) stop("d can not be negative in call to 
> null.space.dimension().") :
>   the condition has length > 1 and only the first element 
> will be used
> 
> The part of the posum code that this error refers to is the 
> following:
> 
> 
> cm.splinefun<-function(x, y = NULL, method = "fmm",gulim=0) 
> 
> # modification of base package splinefun to produce co-monotonic 
> #interpolant
> # by Hyman Filtering. if gulim!=0 then it is taken as the upper 
> # limit on the gradient. 
> {   x <- xy.coords(x, y)
>     y <- x$y
>     x <- x$x
>     n <- length(x)
>     method <- match(method, c("periodic", "natural", "fmm"))
>     if (is.na(method)) 
>         stop("splinefun: invalid interpolation method")
>     if (any(diff(x) < 0)) {
>         z <- order(x)
>         x <- x[z]
>         y <- y[z]
>     }
>     if (method == 1 && y[1] != y[n]) {
>         warning("first and last y values differ in spline - 
> using y[1] for both")
>         y[n] <- y[1]
>     }
>     z <- .C("spline_coef", method = as.integer(method), n = n, 
>         x = as.double(x), y = as.double(y), b = double(n), 
> c = double(n), d = double(n), 
>         e = double(if (method == 1) n else 0), PACKAGE = "stats")
>     
>     z$y<-z$y-z$x*gulim # trick to impose upper
>     z$b<-z$b-gulim     # limit on interpolator gradient
>     
>     z<-hyman.filter(z) # filter gradients for co-monotonicity
>     
>     z$y<-z$y+z$x*gulim # undo trick 
>     z$b<-z$b+gulim     # transformation
>     
>     z<-spl.coef.conv(z) # force other coefficients to consistency
>    
>     rm(x, y, n, method)
>     function(x) {
>         .C("spline_eval", z$method, length(x), x = as.double(x), 
>             y = double(length(x)), z$n, z$x, z$y, z$b, z$c, z$d, 
>             PACKAGE = "stats")$y
>     }
> }
> 
> 
> And finally: 
> 
> > sessionInfo()
> R version 3.1.0 (2014-04-10)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> 
> locale:
> [1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=
> English_United Kingdom.1252   
> [3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                      
>      
> [5] LC_TIME=English_United Kingdom.1252    
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods  base     
> 
> other attached packages:
> [1] posum_2.0-0 mgcv_0.8-7 
> 
> loaded via a namespace (and not attached):
> [1] tools_3.1.0
> 
> 
> I hope this is a more acceptable formulation of the problem! 

Yes, it is, although the answer will not be to your liking. You cannot mix old 
packages that are written in older versions of R with a current version of R. 
That is an ancient version of mgcv. The current version is 1.8-2. (I'm 
surprised you were able to install it, much less get it to load.) The usual 
advice in such instances is to figure out a combination of R, and all of the 
packages that existed at a particular time.

I was able to find : www.maths.bath.ac.uk/~sw283/simon/posum.html

If you look at the archives:

http://cran.r-project.org/src/contrib/Archive

....   to get an idea when mgcv 0.8-7 was current you find:

        mgcv_0.8-7.tar.gz       06-Nov-2002 09:12       155K     

The version of R that corresponds to that date might be:

        R-1.6.1.tgz     01-Nov-2002 12:22       8.2M     

The problem you may face however is that your operating system may not be 
compatible and you may need to find a machine that corresponds to that era of 
R-history. .... say Windows XP?

Might be easier to remedy the defects that exist in posum that prevent it from 
being a current package and working with the current mgcv. (I also checked to 
see if it had been submitted to CRAN in that era:

http://cran.r-project.org/bin/windows/contrib/1.7/

But it's not there.)

 I looked at the code and it does not require compilation. You can probably 
find current functions that can substitute for some of functionality 
implemented by broken code using the .C calls. For instance the current version 
of `cm.splinefun` in package:demography simply calls splinefun with method = 
'hyman'


> cm.splinefun
function (x, y = NULL, ...) 
{
    splinefun(x, y, method = "hyman")
}
<bytecode: 0x2e7bbd158>
<environment: namespace:demography>



--- 
David Winsemius
Alameda, CA, USA

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to