certifiedwaif / phd

5 stars 0 forks source link

Something is going wrong in ZOSull, but it fails silently. The warnings are only visible when you explicitly check for them. #9

Closed certifiedwaif closed 9 years ago

certifiedwaif commented 9 years ago

I've been trying to get the splines code working for two weeks.

> source("splines.R")
> n <- 100
> vx <- matrix(sort(runif(n, -pi / 2, pi  / 2)))
> numIntKnots <- 10
> intKnots <- quantile(unique(vx), seq(0, 1, length=(numIntKnots + 2))[-c(1, (numIntKnots + 2))])
> mZ <- ZOSull(vx, range.x=c(-1.1 * pi / 2, 1.1 * pi / 2), intKnots=intKnots, drv=0)
> warnings()
Warning messages:
1: In rep(allKnots, each = 3)[-c(1, (L - 1), L)] + rep(allKnots,  ... :
  longer object length is not a multiple of shorter object length
2: In rep(diff(allKnots), each = 3) * rep(c(1, 4, 1)/6, K +  ... :
  longer object length is not a multiple of shorter object length
3: In Bdd * wts : longer object length is not a multiple of shorter object length
4: In sqrt(eigOmega$values[indsZ]) : NaNs produced

I've thought something was off with the Z matrix for a while. This is very suspect, and I don't believe for a minute that what's currently in the Z matrix is right. Yet I've looked at the relevant code, and don't see what's wrong yet.

certifiedwaif commented 9 years ago

Seems to be a false alarm.

markg@markg-OptiPlex-9020:~$ cd phd/code
markg@markg-OptiPlex-9020:~/phd/code$ R

R version 3.2.0 (2015-04-16) -- "Full of Ingredients"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> source("splines.R")
> n <- 100
> vx <- matrix(sort(runif(n, -pi / 2, pi  / 2)))
> numIntKnots <- 10
> intKnots <- quantile(unique(vx), seq(0, 1, length=(numIntKnots + 2))[-c(1, (numIntKnots + 2))])
> mZ <- ZOSull(vx, range.x=c(-1.1 * pi / 2, 1.1 * pi / 2), intKnots=intKnots, drv=0)
Called from: ZOSull(vx, range.x = c(-1.1 * pi/2, 1.1 * pi/2), intKnots = intKnots, 
    drv = 0)
Browse[1]> c
> warnings()
NULL

warnings() will show warnings from previous runs, which is confusing.

certifiedwaif commented 9 years ago

I think perhaps ZOSull is sensitive to the range of its input values? I'll try using numbers more in the range that were used in the O'Sullivan splines paper.

certifiedwaif commented 9 years ago

Yes, that seems to be right. I set the range to between 10 and 100, rather than between -pi/2 and pi/2, and Stan is suddenly behaving much better.

certifiedwaif commented 9 years ago

Actually, that's not it either. So I'll admit I don't know what the problem is. I don't understand why the same code that fits random slope models perfectly well is unable to fit spline models.

JohnOrmerod commented 9 years ago

Maybe we can touch base first think tomorrow, if you are free.


From: Mark Greenaway [notifications@github.com] Sent: Tuesday, May 05, 2015 5:52 PM To: certifiedwaif/phd Subject: Re: [phd] Something is going wrong in ZOSull, but it fails silently. The warnings are only visible when you explicitly check for them. (#9)

Actually, that's not it either. So I'll admit I don't know what the problem is.

— Reply to this email directly or view it on GitHubhttps://github.com/certifiedwaif/phd/issues/9#issuecomment-98986070.