Re: [R] GAM with binary predictors

2023-02-21 Thread varin sacha via R-help
Dear Thierry, Dear all, Many thanks for your replies. Le jeudi 16 février 2023 à 10:39:34 UTC+1, Thierry Onkelinx a écrit : Dear Sacha, use glm() in this case. I'd rather code the covariable as TRUE / FALSE or as a factor. Best regards, ir. Thierry Onkelinx Statisticus /

Re: [R] GAM with binary predictors

2023-02-16 Thread Thierry Onkelinx via R-help
Dear Sacha, use glm() in this case. I'd rather code the covariable as TRUE / FALSE or as a factor. Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team

[R] GAM with binary predictors

2023-02-11 Thread varin sacha via R-help
Dear R-experts, I am trying to fit a GAM with 2 binary predictors (variables coded 0,1). I guess I cannot just smooth binary variables. By the way I code them as 0=no,1=yes, then mgcv will think those variables are numeric.  I have tried to change 0 and 1 in no and yes. It does not work. How to

[R] GAM

2021-01-22 Thread devlin.chloe via R-help
Hi, I’m currently using R studio to analyse data - I have 3 data sets consisting of months beginning in 02/2005-02/2020 with numbers of internet searches for 3 different countries. I have used a GAM to analyse this data and see if there are any significant differences or trends, but I am unsure

Re: [R] GAM P value (package mgcv)

2019-06-30 Thread Abby Spurdle
> I try to build a model for five parameters > But, We found these five parameters have multicollinearity. We observed a significant correlation between these parameters. So, we performed a PCA to convert the set of five correlated air pollution variables into a set of linearly uncorrelated main

[R] GAM P value (package mgcv)

2019-06-27 Thread Jason 林俊
Dear R-helpers, My system: R 3.5.3 osx, mgcv 1.8-28 I try to build a model for five parameters Model = gam( Y ~ s(x1) + s(x2) + s(x3) + s(x4) + s(x5)) But, We found these five parameters have multicollinearity. We observed a significant correlation between these parameters. So, we

[R] Gam with mrf smoother (mgcv)

2018-02-26 Thread Giulia Carella
Hallo, I want to use gam from the mgcv package with a mrf smoother. This is my data set (`x`)    y  id     1  0.6684496  1     2  0.6684496  2     3  0.6684496  3     4  0.6684496  4     5  0.6684496  5     6  0.6684496  6     7  0.6684496  7     8  0.5879492  8     9  0.5879492  9

[R] GAM: mismatch between nb/polys supplied area names and data area names

2018-01-26 Thread Susan Elias
Hello, I am new to R and running R version 3.4.3 (2017-11-30), x86_64-apple-darwin15.6.0 (64-bit), macOS High Sierra 10.13.2. I am running the gam package to model disease incidence (negative binomial distribution) as a function of two covariates, and wish to incorporate spatial correlation among

Re: [R] GAM Poisson

2018-01-11 Thread Simon Wood
Not exactly, as by default you are using a log link in the Poisson model, but not the Gaussian model. Simon On 14/12/17 22:57, Miluji Sb wrote: Dear all, I apologize as this may not be a strictly R question. I am running GAM models using the mgcv package. I was wondering if the

[R] GAM Poisson

2017-12-14 Thread Miluji Sb
Dear all, I apologize as this may not be a strictly R question. I am running GAM models using the mgcv package. I was wondering if the interpretation of the smooth splines of the 'x' variable is the same in the following two cases: # Linear probability model m1 <- gam(count ~ factor(city) +

Re: [R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-25 Thread peter dalgaard
ianMean 3rd Qu.Max. >> >> 32.03 61.18 97.20 112.20 165.00 226.00 >> >> >> >> Value range of observed data: >> >> >>> summary(nb_unique) >>> >>Min. 1st Qu. MedianMean 3rd Qu.Max. >> >&g

Re: [R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-23 Thread Simon Wood
nique) > Min. 1st Qu. MedianMean 3rd Qu.Max. > >43.00 67.00 81.00 84.16 92.75 153.00 > > >* By using fitted(mod), I obtain NULL. > I am a novice in GAMs. So, I don�t know why the results are different between > models with offset=argument

Re: [R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-22 Thread Marine Regis
e different between models with offset=argument and offset(). Thanks a lot for your help. Have a nice day Marine De : peter dalgaard <pda...@gmail.com> Envoy� : mardi 22 novembre 2016 23:52 � : Bert Gunter Cc : Marine Regis; r-help@r-project.org Objet : Re: [

Re: [R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-22 Thread peter dalgaard
> On 22 Nov 2016, at 23:07 , Bert Gunter wrote: > > Define "very different." Sounds like a subjective opinion to me, for > which I have no response. Apparently others are similarly flummoxed. > Of course they would not in general be identical. Er? I don't see much

Re: [R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-22 Thread Cade, Brian
Well part of the issue is that the negative binomial estimates are for means and they can differ a fair bit from the raw counts, but I'm also guessing that part of the issue is that the offset may not be accounted for with the predict.gam() function. Brian Brian S. Cade, PhD U. S. Geological

Re: [R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-22 Thread David Winsemius
> On Nov 22, 2016, at 1:29 PM, Marine Regis wrote: > > Hello, > >> From capture data, I would like to assess the effect of longitudinal changes >> in proportion of forests on abundance of skunks. To test this, I built this >> GAM where the dependent variable is the

Re: [R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-22 Thread Bert Gunter
Define "very different." Sounds like a subjective opinion to me, for which I have no response. Apparently others are similarly flummoxed. Of course they would not in general be identical. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and

[R] GAM with the negative binomial distribution: why do predictions no match with original values?

2016-11-22 Thread Marine Regis
Hello, >From capture data, I would like to assess the effect of longitudinal changes >in proportion of forests on abundance of skunks. To test this, I built this >GAM where the dependent variable is the number of unique skunks and the >independent variables are the X coordinates of the

[R] gam mgcv family=scat

2014-12-24 Thread Somers-Yeates, Robin
? Dear R users, I'm currently analysing some data with the gam function from the mgcv package. I'm looking at the relationship between spatially referenced budburst dates (recorded as number of days from January 1st) and two continuous variables, and their interaction, where they are found.

[R] GAM model output error(?)

2014-07-16 Thread Trevor Davies
I have run a quasipoisson spatial model via GAM (NB just wouldn't work) and I am getting the following output of one of my parameters (COR.YEARLY.MEAN). Does this suggest an error in the model fit? The model seems to have converged. Apologies for the lack of reproducible example but it didn't

Re: [R] GAM model output error(?)

2014-07-16 Thread Simon Wood
Trevor, It looks like you've added a parametric COR.YEARLY.MEAN in addition to your s(cxe,cyn,by=COR.YEARLY.MEAN) term. Because the latter includes a linear effect of COR.YEARLY.MEAN, then the parametric COR.YEARLY.MEAN will not be identifiable, so gam has dropped it. I guess from the scale

Re: [R] GAM model output error(?)

2014-07-16 Thread Trevor Davies
Hi Simon, Thank you so much for being active on this list, it really is tremendously helpful. Thanks you for your insights, I was wondering whether both terms were necessary. As for 'NB wouldn't work' it was a convergence problem (and tremendously slow). There were also issues with the models

Re: [R] GAM model output error(?)

2014-07-16 Thread Simon Wood
Trevor, Can I just check - were you using the new 'nb' from mgcv version = 1.8 or the old (and very slow) 'negbin' family? (Not that negative binomial seems needed here, but just to know) best, Simon On 16/07/14 21:16, Trevor Davies wrote: Hi Simon, Thank you so much for being active on

[R] GAM using penalized regression splines with 4 degress o.f.

2014-02-19 Thread Katharina Mersmann
Dear R-Users, I am fairly new to R and got in trouble by understanding how to run a GAM using penalized regression splines with 4 degress of freedom (even by reading the R Documentation). I tried the following: gamreg1.2-gam(num_FCRlong ~ s(GDP,df=4)+s(cupol_GDPpCapita,df=4) +

Re: [R] GAM using penalized regression splines with 4 degress o.f.

2014-02-19 Thread Collin Lynch
Hi Katharina, what gam package are you using? With mgcv you can inspect the results of the output variables to check whether the fixed field is true which would indicate whether the df is fixed or floating. I'm not sure if this is applicable to what you want. My rough translation of your German

[R] gam(mgcv) predicting across random effect and understanding narrow CI

2014-01-25 Thread Anna Hargreaves
Hi everyone, I am new to additive modelling and am surprised by the results of a model I'm working on. I wanted to check with more experienced users to make sure I'm not misunderstanding something basic. *Data:* I have 10 replicated runs from an evolutionary simulation model, measuring the

Re: [R] GAM Assumption Tests

2013-12-09 Thread Mike.lang
it's a pity, but thanks anyway! -- View this message in context: http://r.789695.n4.nabble.com/GAM-Assumption-Tests-tp4681670p4681857.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

[R] GAM Assumption Tests

2013-12-05 Thread Mike.lang
Dear all, currently I set up a GAM for my dataset (~32k records). I assume a normal distribution, constant variance and no correlation effects. With gam.check() it is possible to check those assumptions graphically. But is there also any option to do quantitative tests like the Wald-Test,

Re: [R] GAM Assumption Tests

2013-12-05 Thread Collin Lynch
Hi Mike, I recently had this issue and didn't find any package that implemented these tests directly for the gam object. I found it simplest just to pull the residuals from it and run tests like shapiro.test directly. Best, Collin. On Thu, 5 Dec 2013, Mike.lang wrote: Dear

Re: [R] (gam) formula: Why different results for terms being factor vs. numeric?

2013-11-02 Thread Marius Hofert
Dear Bert, Thanks for helping. Your questions 'answers' why I get the expected behavior if 'group' is a factor. My question was why I don't get the expected behavior if 'group' is not a factor. From a theoretical (non-programming) point of view, there is no difference in a factor with two

[R] (gam) formula: Why different results for terms being factor vs. numeric?

2013-10-29 Thread Marius Hofert
Dear expeRts, If I specify group = as.factor(rep(1:2, each=n)) in the below definition of dat, I get the expected behavior I am looking for. I wonder why I don't get it if group is *not* a factor... My guess was that, internally, factors are treated as natural numbers (and this indeed seems to be

Re: [R] (gam) formula: Why different results for terms being factor vs. numeric?

2013-10-29 Thread Bert Gunter
Think about it. How can one define a smooth term with a factor??? Further discussion is probably offtopic. Post on stats.stackexchange.com if it still isn't obvious. Cheers, Bert On Tue, Oct 29, 2013 at 1:16 PM, Marius Hofert marius.hof...@math.ethz.ch wrote: Dear expeRts, If I specify group

[R] GAM GAMM course

2013-09-24 Thread Highland Statistics Ltd
We would like to announce the following statistics course: Beginner's Guide to MCMC, GAM and GAMM When: 10-14 March 2014 Where: Elche, Alicante, Spain For details, see: http://www.highstat.com/statscourse.htm Course flyer: http://www.highstat.com/Courses/Flyer2014_3ElcheV2.pdf Kind regards,

Re: [R] gam and optim

2013-09-22 Thread Greg Dropkin
just to clarify how I see the error, it was the mis-definition of the penalty term in the function dv. The following code corrects this error. What is actually being minimised at this step is the penalised deviance conditional on the smoothing parameter. A second issue is that the optim default

Re: [R] gam and optim

2013-09-20 Thread Greg Dropkin
please ignore this, I see the error. greg hi probably a silly mistake, but I expected gam to minimise the penalised deviance. thanks greg set.seed(1) library(mgcv) x-runif(100) lp-exp(-2*x)*sin(8*x) y-rpois(100,exp(lp)) plot(x,y) m1-gam(y~s(x),poisson)

[R] gam and optim

2013-09-20 Thread Greg Dropkin
hi probably a silly mistake, but I expected gam to minimise the penalised deviance. thanks greg set.seed(1) library(mgcv) x-runif(100) lp-exp(-2*x)*sin(8*x) y-rpois(100,exp(lp)) plot(x,y) m1-gam(y~s(x),poisson) points(x,exp(lp),pch=16,col=green3) points(x,fitted(m1),pch=16,cex=0.5,col=blue)

[R] gam (mgcv), multiple imputation, f-stats/p-values, and summary(gam)

2013-05-08 Thread Andrew Crane-Droesch
Dear All, I'm using gam for a project that involves multiple imputation, and it has led me to a question about how f-statistics/p-values work in gam. Specifically, how do the values in summary(gam) get generated? As is made clear by the dumb example below, I'm manipul;ating gam objects to

Re: [R] gam (mgcv), multiple imputation, f-stats/p-values, and summary(gam)

2013-05-08 Thread Bert Gunter
?summary.gam ## The Help page Since the Help page is presumably not enough, why don't you look at the code?? R is open source. summary.gam ## at the prompt -- Bert On Wed, May 8, 2013 at 7:12 AM, Andrew Crane-Droesch andre...@gmail.com wrote: Dear All, I'm using gam for a project that

Re: [R] gam (mgcv), multiple imputation, f-stats/p-values, and summary(gam)

2013-05-08 Thread Simon Wood
For smooths the method is described in Wood 2013 On p-values for smooth components of an extended generalized additive model, Biometrika 100(1),221-228 http://biomet.oxfordjournals.org/content/early/2012/10/18/biomet.ass048.full.pdf+html best, Simon On 08/05/13 15:12, Andrew Crane-Droesch

[R] GAM Penalised Splines - Intercept

2013-04-23 Thread Lucas Holland
Hey all, I'm using the gam() function inside the mgcv package to fit a penalised spline to some data. However, I don't quite understand what exactly the intercept it includes by default is / how to interpret it. Ideally I'd like to understand what the intercept is in terms of the B-Spline

Re: [R] GAM Penalised Splines - Intercept

2013-04-23 Thread Gavin Simpson
On Tue, 2013-04-23 at 17:51 +0200, Lucas Holland wrote: Hey all, I'm using the gam() function inside the mgcv package to fit a penalised spline to some data. However, I don't quite understand what exactly the intercept it includes by default is / how to interpret it. Ideally I'd like to

[R] GAM model with interactions between continuous variables and factors

2013-03-25 Thread Antonio P. Ramos
Hi all, I am not sure how to handle interactions with categorical predictors in the GAM models. For example what is the different between these bellow two models. Tests are indicating that they are different but their predictions are essentially the same. Thanks a bunch, gam.1 -

Re: [R] GAM model with interactions between continuous variables and factors

2013-03-25 Thread Antonio P. Ramos
Just to clarify: gam.1 has wealth inside the smooths and as a fixed effect predictor while gam.2 only have wealth inside the smooths. Thanks On Mon, Mar 25, 2013 at 6:09 PM, Antonio P. Ramos ramos.grad.stud...@gmail.com wrote: Hi all, I am not sure how to handle interactions with

Re: [R] GAM model with interactions between continuous variables and factors

2013-03-25 Thread Joshua Wiley
Hi Antonio, If wealth is a factor variable, you should include the main effect in the model, as the smooths will be centered. Cheers, Josh On Mon, Mar 25, 2013 at 6:09 PM, Antonio P. Ramos ramos.grad.stud...@gmail.com wrote: Hi all, I am not sure how to handle interactions with

Re: [R] GAM model with interactions between continuous variables and factors

2013-03-25 Thread Antonio P. Ramos
Just to clarify: I should include wealth - the categorical variable - as a fixed effects *and* within the smooth using the argument by. It that correct? thanks a bunch On Mon, Mar 25, 2013 at 6:18 PM, Joshua Wiley jwiley.ps...@gmail.comwrote: Hi Antonio, If wealth is a factor variable, you

Re: [R] GAM model with interactions between continuous variables and factors

2013-03-25 Thread Joshua Wiley
Yep that's exactly right! :) On Mon, Mar 25, 2013 at 6:22 PM, Antonio P. Ramos ramos.grad.stud...@gmail.com wrote: Just to clarify: I should include wealth - the categorical variable - as a fixed effects *and* within the smooth using the argument by. It that correct? thanks a bunch On Mon,

Re: [R] GAM model with interactions between continuous variables and factors

2013-03-25 Thread Antonio P. Ramos
Thanks! On Mon, Mar 25, 2013 at 6:25 PM, Joshua Wiley jwiley.ps...@gmail.comwrote: Yep that's exactly right! :) On Mon, Mar 25, 2013 at 6:22 PM, Antonio P. Ramos ramos.grad.stud...@gmail.com wrote: Just to clarify: I should include wealth - the categorical variable - as a fixed effects

[R] GAM model to reduce PACF of a model

2012-11-13 Thread PavloEs
I have asked this question on Stackoverflow and was told it does not relate to the sites' mission as it is statistical question, thus I brought it here. I am fitting a gam mode in the mgcv package to study associations of environmental pollutants and mortality. The aim is to choose a model with

[R] [gam] [mgcv] Question in integrating a eiker-white sandwich VCV estimator into GAM

2012-10-27 Thread Andrew Crane-Droesch
Dear List, I'm just teaching myself semi-parametric techniques. Apologies in advance for the long post. I've got observational data and a longitudinal, semi-parametric model that I want to fit in GAM (or potentially something equivalent), and I'm not sure how to do it. I'm posting this to

[R] gam (mgcv) problem: Error in while (mean(ldxx/(ldxx + ldss)) 0.4) { :, missing value where TRUE/FALSE needed

2012-10-16 Thread Andrew Crane-Droesch
Hi All, I'm running into a problem with GAM (in the MGCV package). When I try to estimate the model, I get the following error message: 1 fit - gam(ndvi~s(rain)+s(temp)+s(rainl1)+s(rainl2)+s(rainxY)+s(rainl1xY)+s(rainl2xY)+s(tempxY), data=dsub, weights=wvec) Error in while

Re: [R] gam (mgcv) problem: Error in while (mean(ldxx/(ldxx + ldss)) 0.4) { :, missing value where TRUE/FALSE needed

2012-10-16 Thread Simon Wood
On 16/10/12 07:32, Andrew Crane-Droesch wrote: Hi All, I'm running into a problem with GAM (in the MGCV package). When I try to estimate the model, I get the following error message: 1 fit - gam(ndvi~s(rain)+s(temp)+s(rainl1)+s(rainl2)+s(rainxY)+s(rainl1xY)+s(rainl2xY)+s(tempxY),

Re: [R] gam (mgcv) problem: Error in while (mean(ldxx/(ldxx + ldss)) 0.4) { :, missing value where TRUE/FALSE needed

2012-10-16 Thread Simon Wood
Hi Andrew, Could you send me a bit more information (off list, as this is likely to get into obscure details), please? In particular can you let me know the mgcv and R version numbers, the server operating system and, if possible, what BLAS it has installed? best, Simon On 16/10/12 07:32,

Re: [R] GAM without intercept

2012-10-12 Thread Simon Wood
Smooth terms are constrained to sum to zero over the covariate values. This is an identifiability constraint designed to avoid confounding with the intercept (particularly important if you have more than one smooth). If you remove the intercept from you model altogether (m2) then the smooth

Re: [R] GAM without intercept

2012-10-11 Thread anna freni sterrantino
it helps Anna Anna Freni Sterrantino Department of Statistics University of Bologna, Italy via Belle Arti 41, 40124 BO. Da: SAEC sergio.es...@uach.cl A: r-help@r-project.org Inviato: Giovedì 11 Ottobre 2012 0:22 Oggetto: [R] GAM without intercept Hi everybody, I

[R] GAM without intercept

2012-10-10 Thread SAEC
Hi everybody, I am trying to fit a GAM model without intercept using library mgcv. However, the result has nothing to do with the observed data. In fact the predicted points are far from the predicted points obtained from the model with intercept. For example: #First I generate some simulated

Re: [R] gam error message: matrix not +ve definite

2012-10-08 Thread Simon Wood
Hi Dan, Any chance that you could send me the data offlist and I'll take a look (under the understanding that I'll only use the data for de-bugging of course)? Could you also let me know which linux distribution you are using, whether it's 64bit or 32 bit, and, if possible, what BLAS R is

[R] gam error message: matrix not +ve definite

2012-10-07 Thread garth
Hello, I'm running a multimodel analysis which involves fitting several GAM models as implemented in package mgcv. The issue I'm having is that when I try to fit my model, gam gives me the following error message: 'Error in initial.sp(w * X, S, off) : S[[2]] matrix is not +ve definite.' The

Re: [R] gam error message: matrix not +ve definite

2012-10-07 Thread R. Michael Weylandt
On Sun, Oct 7, 2012 at 3:00 PM, garth dbo...@dal.ca wrote: Hello, I'm running a multimodel analysis which involves fitting several GAM models as implemented in package mgcv. The issue I'm having is that when I try to fit my model, gam gives me the following error message: 'Error in

[R] GAM with shrinkage: how to obtain explained deviance of individual terms?

2012-08-19 Thread Tilen Genov
Dear R users, apologies if this has been debated before, but I was unable to find it anywhere (with respect to shrinkage approach). I am trying to evaluate explained deviance of each model term in a GAM. I am using a the mgcv library for fitting a GAM to binary data. Thin plate regression spline

[R] GAM and interpolation?

2012-08-06 Thread Alex Hotmail
Hello fellow R users, I would need your help on GAM/GAMM models and interpolation on a marked spatial point process (cases and controls). I use the mgcv package to fit a GAMM model with a binary outcome, a parametric part (var1+..+varn), a spline used for the spatial variation, and a random

Re: [R] GAM Chi-Square Difference Test

2012-07-16 Thread Simon Wood
Hi Will, Your edf interpretation is not quite right. The smooths are subject to a centring constraint for identifiability reasons, and this removes a degree of freedom, so EDF=1 corresponds to a straight line fit. On your second point and third points. anova(gamb1.1,gamb1.2, test=Chisq)

[R] GAM Chi-Square Difference Test

2012-07-15 Thread wshadish
We are using GAM in mgcv (Wood), relatively new users, and wonder if anyone can advise us on a problem we are encountering as we analyze many short time series datasets. For each dataset, we have four models, each with intercept, predictor x (trend), z (treatment), and int (interaction between x

Re: [R] GAM interactions, by example

2012-05-30 Thread Simon Wood
Geraldine, They really are the same fit, try... range(fitted(b)-fitted(b1)) [1] -3.333782e-10 4.173699e-10 ... for example. The edf differences are just down to differences in how identifiability constraints are handled in the two cases. For b1 the smooths of x2 do not have centring

[R] GAM interactions, by example

2012-05-29 Thread Mabille, Geraldine
Dear all, I'm using the mgcv library by Simon Wood to fit gam models with interactions and I have been reading (and running) the factor 'by' variable example given on the gam.models help page (see below, output from the two first models b, and b1). The example explains that both b and b1 fits

[R] gam (mgcv) vs. multiple regression breakpoint analysis: inconsistencies?

2012-05-23 Thread Martijn Wieling
Dear useRs, I have a question with respect to fitting a non-linearity using gam (mgcv package, version 1.7-16). In a study I'm currently conducting, I'd like to find out if there is a breakpoint after which the effect of Age of Acquisition (AOA) of the second language changes. I.e. if the slope

Re: [R] GAM, how to set qr=TRUE

2012-05-04 Thread Simon Wood
Which version of gam are you using (i.e. which package and version number?) prediction with fitted gam objects should call predict.gam, and I'm not quite sure why this is not happening here (you do have the mgcv or gam loaded while trying to predict, I suppose?). On 03/05/12 22:56, Ben quant

Re: [R] GAM, how to set qr=TRUE

2012-05-04 Thread Ben quant
Solution: have package mgcv loaded when you predict...not just for the fit. :) Silly mistake... Thanks Simon! Ben On Thu, May 3, 2012 at 3:56 PM, Ben quant ccqu...@gmail.com wrote: Hello, I don't understand what went wrong or how to fix this. How do I set qr=TRUE for gam? When I produce

[R] GAM, how to set qr=TRUE

2012-05-03 Thread Ben quant
Hello, I don't understand what went wrong or how to fix this. How do I set qr=TRUE for gam? When I produce a fit using gam like this: fit = gam(y~s(x),data=as.data.frame(l_yx),family=family,control = list(keepData=T)) ...then try to use predict: (see #1 below in the traceback() ) traceback()

Re: [R] gam - Y axis probability scale with confidence/error lines

2012-03-15 Thread ONKELINX, Thierry
-project.org [mailto:r-help-boun...@r-project.org] Namens Ben quant Verzonden: woensdag 14 maart 2012 19:48 Aan: Patrick Breheny CC: r-help@r-project.org Onderwerp: Re: [R] gam - Y axis probability scale with confidence/error lines Thank you. The binomial()$linkinv() is good to know. Ben On Wed

[R] gam - Y axis probability scale with confidence/error lines

2012-03-14 Thread Ben quant
Hello, How do I plot a gam fit object on probability (Y axis) vs raw values (X axis) axis and include the confidence plot lines? Details... I'm using the gam function like this: l_yx[,2] = log(l_yx[,2] + .0004) fit - gam(y~s(x),data=as.data.frame(l_yx),family=binomial) And I want to plot it so

Re: [R] gam - Y axis probability scale with confidence/error lines

2012-03-14 Thread Patrick Breheny
The predict() function has an option 'se.fit' that returns what you are asking for. If you set this equal to TRUE in your code: pred - predict(fit,data.frame(x=xx),type=response,se.fit=TRUE) will return a list with two elements, 'fit' and 'se.fit'. The pointwise confidence intervals will

Re: [R] gam - Y axis probability scale with confidence/error lines

2012-03-14 Thread Ben quant
That was embarrassingly easy. Thanks again Patrick! Just correcting a little typo to his reply. this is probably what he meant: pred = predict(fit,data.frame(x=xx),type=response,se.fit=TRUE) upper = pred$fit + 1.96 * pred$se.fit lower = pred$fit - 1.96 * pred$se.fit # For people who are

Re: [R] gam - Y axis probability scale with confidence/error lines

2012-03-14 Thread Patrick Breheny
Actually, I responded a bit too quickly last time, without really reading through your example carefully. You're fitting a logistic regression model and plotting the results on the probability scale. The better way to do what you propose is to obtain the confidence interval on the scale of

Re: [R] gam - Y axis probability scale with confidence/error lines

2012-03-14 Thread Ben quant
Thank you. The binomial()$linkinv() is good to know. Ben On Wed, Mar 14, 2012 at 12:23 PM, Patrick Breheny patrick.breh...@uky.eduwrote: Actually, I responded a bit too quickly last time, without really reading through your example carefully. You're fitting a logistic regression model and

Re: [R] GAM (mgcv) warning: matrix not positive definite

2012-02-06 Thread Arnaud Mosnier
Thanks for the explanation ! Happy to know there is no problem with my models. Have a good day, Arnaud 2012/2/3 Simon Wood s.w...@bath.ac.uk It is completely safe to ignore this. Here is what is going on... mgcv routine 'mroot' is calling R routine 'chol' to find the *pivoted* Choleski

[R] GAM (mgcv) warning: matrix not positive definite

2012-02-03 Thread Arnaud Mosnier
Dear list, I fitted the same GAM model using directly the function gam(mgcv) ... then as a parameter of another function that capture the warnings messages (see below). In the first case, there is no warning message printed, but in the last one, the function find two warning messages stating

Re: [R] GAM (mgcv) warning: matrix not positive definite

2012-02-03 Thread Simon Wood
It is completely safe to ignore this. Here is what is going on... mgcv routine 'mroot' is calling R routine 'chol' to find the *pivoted* Choleski factor of a positive semi definite matrix. This is deliberate, and completely ok to do, but 'chol' issues a warning when a matrix is only positive

[R] GAM without intercept reports a huge deviance

2012-01-16 Thread collifu
Hi all, I constructed a GAM model with a linear term and two smooth terms, all of them statistically significant but the intercept was not significant. The adjusted r2 of this model is 0.572 and the deviance 65.3. I decided to run the model again without intercept, so I used in R the following

Re: [R] GAM without intercept reports a huge deviance

2012-01-16 Thread David Winsemius
On Jan 16, 2012, at 9:17 AM, collifu wrote: Hi all, I constructed a GAM model with a linear term and two smooth terms, all of them statistically significant but the intercept was not significant. The adjusted r2 of this model is 0.572 and the deviance 65.3. I decided to run the model

Re: [R] gam() (in mgcv) with multiple interactions

2012-01-01 Thread yanch1985
Dear Simon, I have the same problem. I understand te(a), te(b) are nested in te(a,b) according to your paper on tensor product. I have no enough data to perform te(a,b,d) and only care the interactions a*b and a*d, so I did y=te(a,b)+te(a,d). The resutl is good. I am wondering if this is the

[R] gam, what is the function(s)

2011-12-09 Thread Ben quant
Hello, I'd like to understand 'what' is predicting the response for library(mgcv) gam? For example: library(mgcv) fit - gam(y~s(x),data=as.data.frame(l_yx),family=binomial) xx - seq(min(l_yx[,2]),max(l_yx[,2]),len=101) plot(xx,predict(fit,data.frame(x=xx),type=response),type=l) I want to see

Re: [R] gam, what is the function(s)

2011-12-09 Thread Bert Gunter
There is an extensive list of references given in ?gam, including an R-news article and Simon Woods's (gam's author) website. Would that not be the logical place to start? -- Bert On Fri, Dec 9, 2011 at 7:05 AM, Ben quant ccqu...@gmail.com wrote: Hello, I'd like to understand 'what' is

Re: [R] gam, what is the function(s)

2011-12-09 Thread David Winsemius
On Dec 9, 2011, at 10:05 AM, Ben quant wrote: Hello, I'd like to understand 'what' is predicting the response for library(mgcv) gam? For example: library(mgcv) fit - gam(y~s(x),data=as.data.frame(l_yx),family=binomial) xx - seq(min(l_yx[,2]),max(l_yx[,2]),len=101)

Re: [R] gam, what is the function(s)

2011-12-09 Thread Simon Wood
See help(mgcv-FAQ), item 2. best, Simon On 09/12/11 15:05, Ben quant wrote: Hello, I'd like to understand 'what' is predicting the response for library(mgcv) gam? For example: library(mgcv) fit- gam(y~s(x),data=as.data.frame(l_yx),family=binomial) xx-

Re: [R] gam, what is the function(s)

2011-12-09 Thread Ben quant
Thank you Simon. I already ordered your book. Regards, Ben On Fri, Dec 9, 2011 at 10:49 AM, Simon Wood s.w...@bath.ac.uk wrote: See help(mgcv-FAQ), item 2. best, Simon On 09/12/11 15:05, Ben quant wrote: Hello, I'd like to understand 'what' is predicting the response for

Re: [R] GAM

2011-11-09 Thread Simon Wood
Kilometres has only 5 unique values, while Bonus has only 7, but the default smoothing basis dimension for the s terms is 10, so there is a problem. Solution is to reduce the basis dimension. e.g. amgam - gam(log(Payment) ~ offset(log(Insured))+ + s(as.numeric(Kilometres),k=5) + s(Bonus,k=7) +

Re: [R] GAM

2011-11-09 Thread Patrick Breheny
On 11/08/2011 11:57 AM, Gyanendra Pokharel wrote: Hi R community! I am analyzing the data set motorins in the package faraway by using the generalized additive model. it shows the following error. Can some one suggest me the right way? library(faraway) data(motorins) motori-

[R] GAM

2011-11-08 Thread Gyanendra Pokharel
Hi R community! I am analyzing the data set motorins in the package faraway by using the generalized additive model. it shows the following error. Can some one suggest me the right way? library(faraway) data(motorins) motori - motorins[motorins$Zone==1,] library(mgcv) amgam - gam(log(Payment) ~

Re: [R] GAM

2011-11-08 Thread Jean V Adams
Gyanendra Pokharel wrote on 11/08/2011 10:57:38 AM: Hi R community! I am analyzing the data set motorins in the package faraway by using the generalized additive model. it shows the following error. Can some one suggest me the right way? library(faraway) data(motorins) motori -

[R] gam predictions with negbin model

2011-10-26 Thread Kari Ruohonen
Hi, I wonder if predict.gam is supposed to work with family=negbin() definition? It seems to me that the values returned by type=response are far off the observed values. Here is an example output from the negbin examples: set.seed(3) n-400 dat-gamSim(1,n=n) g-exp(dat$f/5)

Re: [R] gam predictions with negbin model

2011-10-26 Thread Achim Zeileis
On Wed, 26 Oct 2011, Kari Ruohonen wrote: Hi, I wonder if predict.gam is supposed to work with family=negbin() definition? It seems to me that the values returned by type=response are far off the observed values. Here is an example output from the negbin examples: set.seed(3) n-400

Re: [R] gam predictions with negbin model

2011-10-26 Thread Kari Ruohonen
On 26/10/11 12:10, Achim Zeileis wrote: On Wed, 26 Oct 2011, Kari Ruohonen wrote: Hi, I wonder if predict.gam is supposed to work with family=negbin() definition? It seems to me that the values returned by type=response are far off the observed values. Here is an example output from the

[R] GAM Prediction

2011-08-10 Thread Gene Leynes
I'm looking for the best way to do the following: run a set of GAM models, and then make predictions with new data. My problem is the size of the gam model object, I would like to strip it down to the bare minimum of information needed to apply the model to new data. For example, if this

Re: [R] gam confidence interval (package mgcv)

2011-06-28 Thread Simon Wood
not sure if I'm missing something here, but since you are using a log link, isn't the ratio you are looking for given by the `treatmentB' parameter in the summary (independent of X) summary(gfit) [snip] Parametric coefficients: Estimate Std. Error t value Pr(|t|) (Intercept)

[R] gam confidence interval (package mgcv)

2011-06-27 Thread Remko Duursma
Dear R-helpers, I am trying to construct a confidence interval on a prediction of a gam fit. I have the Wood (2006) book, and section 5.2.7 seems relevant but I am not able to apply that to this, different, problem. Any help is appreciated! Basically I have a function Y = f(X) for two different

Re: [R] gam confidence interval (package mgcv)

2011-06-27 Thread David Winsemius
On Jun 27, 2011, at 10:45 PM, Remko Duursma wrote: Dear R-helpers, I am trying to construct a confidence interval on a prediction of a gam fit. I have the Wood (2006) book, and section 5.2.7 seems relevant but I am not able to apply that to this, different, problem. Any help is appreciated!

Re: [R] gam confidence interval (package mgcv)

2011-06-27 Thread Remko Duursma
But that just gives me the prediction of Y for treatment A or B, not the ratio. As I stated: # I am interested in the relationship: # Y(treatment ==B) / Y(treatment==A) as a function of X, with a confidence interval! I can get the SE for either of them using predict.gam without a problem, but

Re: [R] gam() (in mgcv) with multiple interactions

2011-06-10 Thread Ben Haller
...@bath.ac.uk Date: June 9, 2011 11:35:11 AM EDT To: r-help@r-project.org, rh...@sticksoftware.com Subject: Re: [R] gam() (in mgcv) with multiple interactions I think that the main problem here is that smooths are not constrained to pass through the origin, so the covariate taking the value zero

Re: [R] gam() (in mgcv) with multiple interactions

2011-06-09 Thread Simon Wood
I think that the main problem here is that smooths are not constrained to pass through the origin, so the covariate taking the value zero doesn't correspond to no effect in the way that you would like it to. Another way of putting this is that smooths are translation invariant, you get

[R] gam() (in mgcv) with multiple interactions

2011-06-07 Thread Ben Haller
Hi! I'm learning mgcv, and reading Simon Wood's book on GAMs, as recommended to me earlier by some folks on this list. I've run into a question to which I can't find the answer in his book, so I'm hoping somebody here knows. My outcome variable is binary, so I'm doing a binomial fit with

  1   2   >