Re: [R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-02-03 Thread Simon Wood



I suppose there may be an error of sorts,  but have you considered
the fact that solving the error might not gain you admittance into
heaven? Look at the RHS of the model:

sensor2 + s(site, bs = re)

... and think about the fact that you are smoothing a factor
variable.

- Actually this is ok. mgcv exploits the duality between quadratically
penalized smooths and Gaussian random effects to allow random effects to
be specified this way. bs=re specifies a Gaussian random effect with 
corresponding model matrix given by model.matrix(~site-1). (More 
generally s(x,y,z,bs=re) specifies a gaussian random effect with model 
matrix given by model.matrix(~x:y:z-1), with obvious generalization to 
more or fewer variables). See mgcv help file ?random.effects for more.


best,
Simon




str(gapData)

'data.frame':   2304 obs. of  5 variables: $ sensor1: num  NA NA NA
NA NA NA NA NA NA NA ... $ site   : Factor w/ 9 levels
KRB,NP.FOR,..: 3 3 3 3 3 3 3 3 3 3 ... $ NthSampling: int  7489
7490 7491 7492 7493 7494 7495 7496 7497 7498 ... $ YDay   : num
53 53 53 53 53 53 53 53 53 53 ... $ sensor2: num  0.567 0.566
0.567 0.567 0.569 ...

I'm having trouble making any sense of how that might work. It is, of
course, possible to just do this:

xylemRohWeekXnnSite.fit - predict.gam(xylemRohWeekXnn.fit.bam,
type=response, se=F)

That gives predictions for the original dataset.

But I think the error might be helpful in alerting one to the
problems with the model.




--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603   http://people.bath.ac.uk/sw283

__
R-help@r-project.org 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.


Re: [R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-02-03 Thread Simon Wood

Hi Katharina,

Thanks for sending this.

The problem is that the prediction data for site contain levels not
available in the (useable non-NA) fit data...

 levels(m$model$site)
[1] KRB NP.FOR  WKS.FRE WKS.KRE WKS.RIE WKS.WUE
 levels(gapData$site)
[1] KRB NP.FOR  RIE.2   WKS.BBR WKS.FRE WKS.HOE WKS.KRE
[8] WKS.RIE WKS.WUE

predict.lm has a check for this, and so fails with a rather more 
informative error message. e.g.


m0 - lm(sensor1 ~ sensor2 + site + site:NthSampling, 
data=xylemRohWeekXnn2011,na.action=na.omit)

predict(m0,gapData)
... factor site has new levels RIE.2, WKS.BBR

I'll add a better check to predict.gam.

best,
Simon

ps. if you want predictions with the random effects for site set to zero 
then one trick is to use terms like s(site,bs=re,by=dum) in fitting 
with dum set to 1. Then in prediction you can set 'site' to any existing 
level, and dum to zero, in order to get a prediction for the missing 
level, with the 'site' effect set to zero.



On 02/02/14 17:52, Katharina May wrote:

Hi Simon,

thank you for your reply, I really appreciate any help to understand
the problem here...
Unluckily the package upgrade didn't help with this issue.
An example reproducing the error, and a current sessionInfo() Output
can be found below.

Many thanks once again,

Katharina


R Code Example
snip
  library(RCurl)
  library(mgcv)
  #retrieve xylemRohWeekXnn2011 test data frame
  eval( expr = parse( text =
getURL(https://webdisk.ads.mwn.de/Handlers/AnonymousDownload.ashx?folder=1a7cbaa4path=xylemRohWeekXnn2011.R;)
))

  xylemRohWeekXnn.fit.bam  - bam(sensor1 ~ sensor2 + s(site, bs=re)
+ s(site, NthSampling, bs=re) ,  data=xylemRohWeekXnn2011,
na.action=na.omit)

  #subset data containing gaps for predicting
  gapData - xylemRohWeekXnn2011[is.na(xylemRohWeekXnn2011[,2]) 
!is.na(xylemRohWeekXnn2011[,11]),c(2:3,6:7, 11)]

  xylemRohWeekXnnSite.fit -
predict.gam(xylemRohWeekXnn.fit.bam,gapData, type=response, se=F)
/snap



My current Session Information (sessionInfo() Output - also confirming
that the problem exists on both Windows and Mac OS X):
snip
R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] mgcv_1.7-28nlme_3.1-113   RCurl_1.95-4.1 bitops_1.0-6

loaded via a namespace (and not attached):
[1] grid_3.0.2  lattice_0.20-24 Matrix_1.1-2tools_3.0.2
/snap




On 31/01/14 12:57, Simon Wood wrote:


Hi Katharina,

Could you try upgrading to mgcv_1.7-28, please? There was an occasional
problem to do with matching factor levels, which is fixed, but I'm not
very confident that is what is going on.

If upgrading doesn't work, is there any chance you could send me a small
example dataset and code that produces the error, and I'll look at it?

best,
Simon

--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603   http://people.bath.ac.uk/sw283



--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603   http://people.bath.ac.uk/sw283

__
R-help@r-project.org 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.


Re: [R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-02-03 Thread Katharina May
Hi Simon,

many thanks for looking into this and making me understand the problem!
I'll adjust my factor levels right away...

Best, Katharina

On 3 February 2014 12:42, Simon Wood s.w...@bath.ac.uk wrote:
 Hi Katharina,

 Thanks for sending this.

 The problem is that the prediction data for site contain levels not
 available in the (useable non-NA) fit data...

 levels(m$model$site)
 [1] KRB NP.FOR  WKS.FRE WKS.KRE WKS.RIE WKS.WUE
 levels(gapData$site)
 [1] KRB NP.FOR  RIE.2   WKS.BBR WKS.FRE WKS.HOE WKS.KRE
 [8] WKS.RIE WKS.WUE

 predict.lm has a check for this, and so fails with a rather more informative
 error message. e.g.

 m0 - lm(sensor1 ~ sensor2 + site + site:NthSampling,
 data=xylemRohWeekXnn2011,na.action=na.omit)
 predict(m0,gapData)
 ... factor site has new levels RIE.2, WKS.BBR

 I'll add a better check to predict.gam.

 best,
 Simon

 ps. if you want predictions with the random effects for site set to zero
 then one trick is to use terms like s(site,bs=re,by=dum) in fitting with
 dum set to 1. Then in prediction you can set 'site' to any existing level,
 and dum to zero, in order to get a prediction for the missing level, with
 the 'site' effect set to zero.



 On 02/02/14 17:52, Katharina May wrote:

 Hi Simon,

 thank you for your reply, I really appreciate any help to understand
 the problem here...
 Unluckily the package upgrade didn't help with this issue.
 An example reproducing the error, and a current sessionInfo() Output
 can be found below.

 Many thanks once again,

 Katharina


 R Code Example
 snip
   library(RCurl)
   library(mgcv)
   #retrieve xylemRohWeekXnn2011 test data frame
   eval( expr = parse( text =

 getURL(https://webdisk.ads.mwn.de/Handlers/AnonymousDownload.ashx?folder=1a7cbaa4path=xylemRohWeekXnn2011.R;)
 ))

   xylemRohWeekXnn.fit.bam  - bam(sensor1 ~ sensor2 + s(site, bs=re)
 + s(site, NthSampling, bs=re) ,  data=xylemRohWeekXnn2011,
 na.action=na.omit)

   #subset data containing gaps for predicting
   gapData - xylemRohWeekXnn2011[is.na(xylemRohWeekXnn2011[,2]) 
 !is.na(xylemRohWeekXnn2011[,11]),c(2:3,6:7, 11)]

   xylemRohWeekXnnSite.fit -
 predict.gam(xylemRohWeekXnn.fit.bam,gapData, type=response, se=F)
 /snap



 My current Session Information (sessionInfo() Output - also confirming
 that the problem exists on both Windows and Mac OS X):
 snip
 R version 3.0.2 (2013-09-25)
 Platform: x86_64-apple-darwin10.8.0 (64-bit)

 locale:
 [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base

 other attached packages:
 [1] mgcv_1.7-28nlme_3.1-113   RCurl_1.95-4.1 bitops_1.0-6

 loaded via a namespace (and not attached):
 [1] grid_3.0.2  lattice_0.20-24 Matrix_1.1-2tools_3.0.2
 /snap




 On 31/01/14 12:57, Simon Wood wrote:


 Hi Katharina,

 Could you try upgrading to mgcv_1.7-28, please? There was an occasional
 problem to do with matching factor levels, which is fixed, but I'm not
 very confident that is what is going on.

 If upgrading doesn't work, is there any chance you could send me a small
 example dataset and code that produces the error, and I'll look at it?

 best,
 Simon

 --
 Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
 +44 (0)1225 386603   http://people.bath.ac.uk/sw283



 --
 Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
 +44 (0)1225 386603   http://people.bath.ac.uk/sw283



-- 
Katharina May
BSc. Forest Science and Resource Management
IT Specialist (CCI)

Prinz-Ludwig-Str. 7
85354 Freising
Germany

Mobile: +49-176-24031809
www: m3y.de

__
R-help@r-project.org 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.


[R] package mgcv - predict with bam: Error in X[ind, ] :, subscript out of bounds

2014-02-03 Thread William Shadish
Dear Simon, your note below says bs=re specifies a Gaussian random 
effect . I have been using bs = re for data modeled with Poisson and 
binomial distributions, or variants thereof (e.g., quasi-Poisson). Have 
I erred in assuming bs =re can be used to obtain random effects for 
such data? Will Shadish


- Actually this is ok. mgcv exploits the duality between quadratically
penalized smooths and Gaussian random effects to allow random effects to
be specified this way. bs=re specifies a Gaussian random effect with
corresponding model matrix given by model.matrix(~site-1). (More
generally s(x,y,z,bs=re) specifies a gaussian random effect with model
matrix given by model.matrix(~x:y:z-1), with obvious generalization to
more or fewer variables). See mgcv help file ?random.effects for more.

best,
Simon


--
William R. Shadish
Distinguished Professor
Founding Faculty

Mailing Address:
William R. Shadish
University of California
School of Social Sciences, Humanities and Arts
5200 North Lake Rd
Merced CA  95343

Physical/Delivery Address:
University of California Merced
ATTN: William Shadish
School of Social Sciences, Humanities and Arts
Facilities Services Building A
5200 North Lake Rd.
Merced, CA 95343

209-228-4372 voice
209-228-4007 fax (communal fax: be sure to include cover sheet)
wshad...@ucmerced.edu
http://faculty.ucmerced.edu/wshadish/index.htm
http://psychology.ucmerced.edu

__
R-help@r-project.org 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.


Re: [R] package mgcv - predict with bam: Error in X[ind, ] :, subscript out of bounds

2014-02-03 Thread Gavin Simpson
The two distributions are different. The random effect is assumed to
be a Gaussian random variable, just as it is with the GLMMs in the
lme4 package. It is fine to use such a random effect within a GAM with
a non-Gaussian error distribution, like the ones you describe using.

HTH

Gavin

On 3 February 2014 15:00, William Shadish wshad...@ucmerced.edu wrote:
 Dear Simon, your note below says bs=re specifies a Gaussian random effect
 . I have been using bs = re for data modeled with Poisson and binomial
 distributions, or variants thereof (e.g., quasi-Poisson). Have I erred in
 assuming bs =re can be used to obtain random effects for such data? Will
 Shadish

 - Actually this is ok. mgcv exploits the duality between quadratically
 penalized smooths and Gaussian random effects to allow random effects to
 be specified this way. bs=re specifies a Gaussian random effect with
 corresponding model matrix given by model.matrix(~site-1). (More
 generally s(x,y,z,bs=re) specifies a gaussian random effect with model
 matrix given by model.matrix(~x:y:z-1), with obvious generalization to
 more or fewer variables). See mgcv help file ?random.effects for more.

 best,
 Simon


 --
 William R. Shadish
 Distinguished Professor
 Founding Faculty

 Mailing Address:
 William R. Shadish
 University of California
 School of Social Sciences, Humanities and Arts
 5200 North Lake Rd
 Merced CA  95343

 Physical/Delivery Address:
 University of California Merced
 ATTN: William Shadish
 School of Social Sciences, Humanities and Arts
 Facilities Services Building A
 5200 North Lake Rd.
 Merced, CA 95343

 209-228-4372 voice
 209-228-4007 fax (communal fax: be sure to include cover sheet)
 wshad...@ucmerced.edu
 http://faculty.ucmerced.edu/wshadish/index.htm
 http://psychology.ucmerced.edu

 __
 R-help@r-project.org 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.



-- 
Gavin Simpson, PhD

__
R-help@r-project.org 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.


Re: [R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-02-02 Thread Katharina May
Hi Simon,

thank you for your reply, I really appreciate any help to understand
the problem here...
Unluckily the package upgrade didn't help with this issue.
An example reproducing the error, and a current sessionInfo() Output
can be found below.

Many thanks once again,

   Katharina


R Code Example
snip
 library(RCurl)
 library(mgcv)
 #retrieve xylemRohWeekXnn2011 test data frame
 eval( expr = parse( text =
getURL(https://webdisk.ads.mwn.de/Handlers/AnonymousDownload.ashx?folder=1a7cbaa4path=xylemRohWeekXnn2011.R;)
))

 xylemRohWeekXnn.fit.bam  - bam(sensor1 ~ sensor2 + s(site, bs=re)
+ s(site, NthSampling, bs=re) ,  data=xylemRohWeekXnn2011,
na.action=na.omit)

 #subset data containing gaps for predicting
 gapData - xylemRohWeekXnn2011[is.na(xylemRohWeekXnn2011[,2]) 
!is.na(xylemRohWeekXnn2011[,11]),c(2:3,6:7, 11)]

 xylemRohWeekXnnSite.fit -
predict.gam(xylemRohWeekXnn.fit.bam,gapData, type=response, se=F)
/snap



My current Session Information (sessionInfo() Output - also confirming
that the problem exists on both Windows and Mac OS X):
snip
R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] mgcv_1.7-28nlme_3.1-113   RCurl_1.95-4.1 bitops_1.0-6

loaded via a namespace (and not attached):
[1] grid_3.0.2  lattice_0.20-24 Matrix_1.1-2tools_3.0.2
/snap




On 31/01/14 12:57, Simon Wood wrote:

Hi Katharina,

Could you try upgrading to mgcv_1.7-28, please? There was an occasional
problem to do with matching factor levels, which is fixed, but I'm not
very confident that is what is going on.

If upgrading doesn't work, is there any chance you could send me a small
example dataset and code that produces the error, and I'll look at it?

best,
Simon

--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603   http://people.bath.ac.uk/sw283

__
R-help@r-project.org 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.


Re: [R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-02-02 Thread David Winsemius

On Feb 2, 2014, at 9:52 AM, Katharina May wrote:

 Hi Simon,
 
 thank you for your reply, I really appreciate any help to understand
 the problem here...
 Unluckily the package upgrade didn't help with this issue.
 An example reproducing the error, and a current sessionInfo() Output
 can be found below.

I suppose there may be an error of sorts,  but have you considered the fact 
that solving the error might not gain you admittance into heaven? Look at the 
RHS of the model:

sensor2 + s(site, bs = re)
 
... and think about the fact that you are smoothing a factor variable. 

 str(gapData)
'data.frame':   2304 obs. of  5 variables:
 $ sensor1: num  NA NA NA NA NA NA NA NA NA NA ...
 $ site   : Factor w/ 9 levels KRB,NP.FOR,..: 3 3 3 3 3 3 3 3 3 3 ...
 $ NthSampling: int  7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 ...
 $ YDay   : num  53 53 53 53 53 53 53 53 53 53 ...
 $ sensor2: num  0.567 0.566 0.567 0.567 0.569 ...

I'm having trouble making any sense of how that might work. It is, of course, 
possible to just do this:

xylemRohWeekXnnSite.fit -
predict.gam(xylemRohWeekXnn.fit.bam, type=response, se=F)

That gives predictions for the original dataset.

But I think the error might be helpful in alerting one to the problems with the 
model.

-- 
David.
 
 Many thanks once again,
 
   Katharina
 
 
 R Code Example
 snip
 library(RCurl)
 library(mgcv)
 #retrieve xylemRohWeekXnn2011 test data frame
 eval( expr = parse( text =
 getURL(https://webdisk.ads.mwn.de/Handlers/AnonymousDownload.ashx?folder=1a7cbaa4path=xylemRohWeekXnn2011.R;)
 ))
 
 xylemRohWeekXnn.fit.bam  - bam(sensor1 ~ sensor2 + s(site, bs=re)
 + s(site, NthSampling, bs=re) ,  data=xylemRohWeekXnn2011,
 na.action=na.omit)
 
 #subset data containing gaps for predicting
 gapData - xylemRohWeekXnn2011[is.na(xylemRohWeekXnn2011[,2]) 
 !is.na(xylemRohWeekXnn2011[,11]),c(2:3,6:7, 11)]
 
 xylemRohWeekXnnSite.fit -
 predict.gam(xylemRohWeekXnn.fit.bam,gapData, type=response, se=F)
 /snap
 
 
 
 My current Session Information (sessionInfo() Output - also confirming
 that the problem exists on both Windows and Mac OS X):
 snip
 R version 3.0.2 (2013-09-25)
 Platform: x86_64-apple-darwin10.8.0 (64-bit)
 
 locale:
 [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 other attached packages:
 [1] mgcv_1.7-28nlme_3.1-113   RCurl_1.95-4.1 bitops_1.0-6
 
 loaded via a namespace (and not attached):
 [1] grid_3.0.2  lattice_0.20-24 Matrix_1.1-2tools_3.0.2
 /snap
 
 
 
 
 On 31/01/14 12:57, Simon Wood wrote:
 
 Hi Katharina,
 
 Could you try upgrading to mgcv_1.7-28, please? There was an occasional
 problem to do with matching factor levels, which is fixed, but I'm not
 very confident that is what is going on.
 
 If upgrading doesn't work, is there any chance you could send me a small
 example dataset and code that produces the error, and I'll look at it?
 
 best,
 Simon
 
 --
 Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
 +44 (0)1225 386603   http://people.bath.ac.uk/sw283
 
 __
 R-help@r-project.org 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.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org 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.


Re: [R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-01-31 Thread Simon Wood

Hi Katharina,

Could you try upgrading to mgcv_1.7-28, please? There was an occasional 
problem to do with matching factor levels, which is fixed, but I'm not 
very confident that is what is going on.


If upgrading doesn't work, is there any chance you could send me a small 
example dataset and code that produces the error, and I'll look at it?


best,
Simon

On 30/01/14 12:20, Katharina May wrote:

Dear R-Community,

I`m trying to apply the mgcv package to fill gaps in sensor data from
different sites (9 sites, 2 sensors per site) and do the filling on a
site-wise level.
Based on 
http://r.789695.n4.nabble.com/mgcv-gamm-predict-to-reflect-random-s-effects-td3622738.html
my model looks like this:
  xylemRohWeekXnn.fit.bam  - bam(sensor1 ~ sensor2 + s(site, bs=re)
+ s(site, NthSampling, bs=re) ,  data=xylemRohWeekXnn2011,
na.action=na.omit)

However, than I try to use predict, I get an error:
gapData - xylemRohWeekXnn2011[is.na(xylemRohWeekXnn2011[,2]) 
!is.na(xylemRohWeekXnn2011[,11]),c(2:3,6:7, 11)]
xylemRohWeekXnnSite.fit -
predict.gam(xylemRohWeekXnn.fit.bam,gapData, type=response, se=F)
Error in X[ind, ] : subscript out of bounds

I was hoping that someone might be able to provide a quick hint on if
there is an obvious problem or mistake  within my model
declaration/approach?
I attached the sessionInfo() Output below and the xylemRohWeekXnn2011
dump can be downloaded here:
https://webdisk.ads.mwn.de/Handlers/AnonymousDownload.ashx?folder=1a7cbaa4path=xylemRohWeekXnn2011.txt
I`m appreciating any help and hints!

Thank you very much, Katharina

-
sessionInfo()
-
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=CLC_TIME=German_Germany.1252

attached base packages:
[1] splines   stats graphics  grDevices utils datasets
methods   base

other attached packages:
  [1] mgcv_1.7-27 plyr_1.8ggplot2_0.9.3.1 lattice_0.20-24
gdata_2.13.2nlme_3.1-113
  [7] zoo_1.7-10  xlsx_0.5.5  xlsxjars_0.5.0  rJava_0.9-6

loaded via a namespace (and not attached):
  [1] colorspace_1.2-4   dichromat_2.0-0digest_0.6.4
grid_3.0.2 gtable_0.1.2
  [6] gtools_3.2.1   labeling_0.2   MASS_7.3-29
Matrix_1.1-2   munsell_0.4.2
[11] proto_0.3-10   RColorBrewer_1.0-5 reshape2_1.2.2
scales_0.2.3   stringr_0.6.2
[16] tools_3.0.2

__
R-help@r-project.org 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.




--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603   http://people.bath.ac.uk/sw283

__
R-help@r-project.org 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.


[R] package mgcv - predict with bam: Error in X[ind, ] : subscript out of bounds

2014-01-30 Thread Katharina May
Dear R-Community,

I`m trying to apply the mgcv package to fill gaps in sensor data from
different sites (9 sites, 2 sensors per site) and do the filling on a
site-wise level.
Based on 
http://r.789695.n4.nabble.com/mgcv-gamm-predict-to-reflect-random-s-effects-td3622738.html
my model looks like this:
 xylemRohWeekXnn.fit.bam  - bam(sensor1 ~ sensor2 + s(site, bs=re)
+ s(site, NthSampling, bs=re) ,  data=xylemRohWeekXnn2011,
na.action=na.omit)

However, than I try to use predict, I get an error:
gapData - xylemRohWeekXnn2011[is.na(xylemRohWeekXnn2011[,2]) 
!is.na(xylemRohWeekXnn2011[,11]),c(2:3,6:7, 11)]
xylemRohWeekXnnSite.fit -
predict.gam(xylemRohWeekXnn.fit.bam,gapData, type=response, se=F)
Error in X[ind, ] : subscript out of bounds

I was hoping that someone might be able to provide a quick hint on if
there is an obvious problem or mistake  within my model
declaration/approach?
I attached the sessionInfo() Output below and the xylemRohWeekXnn2011
dump can be downloaded here:
https://webdisk.ads.mwn.de/Handlers/AnonymousDownload.ashx?folder=1a7cbaa4path=xylemRohWeekXnn2011.txt
I`m appreciating any help and hints!

Thank you very much, Katharina

-
sessionInfo()
-
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=CLC_TIME=German_Germany.1252

attached base packages:
[1] splines   stats graphics  grDevices utils datasets
methods   base

other attached packages:
 [1] mgcv_1.7-27 plyr_1.8ggplot2_0.9.3.1 lattice_0.20-24
gdata_2.13.2nlme_3.1-113
 [7] zoo_1.7-10  xlsx_0.5.5  xlsxjars_0.5.0  rJava_0.9-6

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4   dichromat_2.0-0digest_0.6.4
grid_3.0.2 gtable_0.1.2
 [6] gtools_3.2.1   labeling_0.2   MASS_7.3-29
Matrix_1.1-2   munsell_0.4.2
[11] proto_0.3-10   RColorBrewer_1.0-5 reshape2_1.2.2
scales_0.2.3   stringr_0.6.2
[16] tools_3.0.2

__
R-help@r-project.org 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.