similar to: Factor variables with GAM models

Displaying 20 results from an estimated 8000 matches similar to: "Factor variables with GAM models"

2007 Jun 22
1
two basic question regarding model selection in GAM
Qusetion #1 ********* Model selection in GAM can be done by using: 1. step.gam {gam} : A directional stepwise search 2. gam {mgcv} : Smoothness estimation using GCV or UBRE/AIC criterion Suppose my model starts with a additive model (linear part + spline part). Using gam() {mgcv} i got estimated degrees of freedom(edf) for the smoothing splines. Now I want to use the functional form of my model
2007 Oct 05
2
question about predict.gam
I'm fitting a Poisson gam model, say model<-gam(a65tm~as.factor(day.week )+as.factor(week)+offset(log(pop65))+s(time,k=10,bs="cr",fx=FALSE,by=NA,m=1),sp=c( 0.001),data=dati1,family=poisson) Currently I've difficulties in obtaining right predictions by using gam.predict function with MGCV package in R version 2.2.1 (see below my syntax).
2008 Jun 11
1
mgcv::gam error message for predict.gam
Sometimes, for specific models, I get this error from predict.gam in library mgcv: Error in complete.cases(object) : negative length vectors are not allowed Here's an example: model.calibrate <- gam(meansalesw ~ s(tscore,bs="cs",k=4), data=toplot, weights=weight, gam.method="perf.magic") > test <- predict(model.calibrate,newdata) Error in
2007 Dec 13
1
Two repeated warnings when runing gam(mgcv) to analyze my dataset?
Dear all, I run the GAMs (generalized additive models) in gam(mgcv) using the following codes. m.gam <-gam(mark~s(x)+s(y)+s(lstday2004)+s(ndvi2004)+s(slope)+s(elevation)+disbinary,family=binomial(logit),data=point) And two repeated warnings appeared. Warnings$B!'(B 1: In gam.fit(G, family = G$family, control = control, gamma = gamma, ... : Algorithm did not converge 2: In gam.fit(G,
2008 Nov 14
2
GAM and Poisson distribution
Hi -I'm running a GAM with 7 explanatory variables with a Poisson error structure. All of the variables are continuous so I'm getting error messages in R. cod.fall.full.gam.model<-gam(Kept.CPUE~s(HOUR)+s(LAT_dec)+s(LONG_dec)+s(meantemp_C)+s(meandepth_fa)+s(change_depth)+s(seds), data=cod.fall.version2,family=poisson) In dpois(y, mu, log = TRUE) ... : non-integer x = 5.325517
2009 Nov 22
1
GAM plots
Hello all... I'm attempting to write my own GAM plot function, so I can overlay it on top of an already existing plot. Problem is that after I do the gam, e.g. m<-gam(...), I cannot match the graph that gam.plot outputs when I attempt to plot the values from m$residuals, m$linear.predictors or m$fitted.values. Kind of at a loss what variables to use or if I need to do something
2013 Jul 08
1
error in "predict.gam" used with "bam"
Hello everyone. I am doing a logistic gam (package mgcv) on a pretty large dataframe (130.000 cases with 100 variables). Because of that, the gam is fitted on a random subset of 10000. Now when I want to predict the values for the rest of the data, I get the following error: > gam.basis_alleakti.1.pr=predict(gam.basis_alleakti.1, +
2010 Aug 05
1
plot points using vis.gam
Hello, I'm trying to illustrate the relationships between various trait and environment data gathered from a number of sites. I've created a GAM to do this: gam1=gam(trait~s(env1)+s(env2)+te(env1,env2)) and I know how to create a 3D plot using vis.gam. I want to be able to show points on the 3D plot indicating the sites that the data came from. I can do this on a 2D plot when there is one
2007 Dec 13
1
Probelms on using gam(mgcv)
Dear all, Following the help from gam(mgcv) help page, i tried to analyze my dataset with all the default arguments. Unfortunately, it can't be run successfully. I list the errors below. #m.gam<-gam(mark~s(x,y)+s(lstday2004)+s(slope)+s(ndvi2004)+s(elevation)+s(disbinary),family=binomial(logit),data=point)
2011 Feb 16
1
retrieving partial residuals of gam fit (mgcv)
Dear list, does anybody know whether there is a way to easily retrieve the so called "partial residuals" of a gam fit with package mgcv? The partial residuals are the residuals you would get if you would "leave out" a particular predictor and are the dots in the plots created by plot(gam.object,residuals=TRUE) residuals.gam() gives me whole model residuals and
2010 May 13
1
GAM, GAMM and numerical integration, help please
I am trying to apply methods used by Chaloupka & Limpus (1997) ( http://www.int-res.com/articles/meps/146/m146p001.pdf) to my own turtle growth data. I am having trouble with two things... 1) After the GAM is fit, the residuals are skewed. >m1 <- gam(growth~s(mean.size, bs="cr")+s(year,bs="cr",k=7)+s(cohort,bs="cr")+s(age,bs="cr"), data=grow,
2008 Jan 08
3
GAM, GLM, Logit, infinite or missing values in 'x'
Hi, I'm running gam (mgcv version 1.3-29) and glm (logit) (stats R 2.61) on the same models/data, and I got error messages for the gam() model and warnings for the glm() model. R-help suggested that the glm() warning messages are due to the model perfectly predicting binary output. Perhaps the model overfits the data? I inspected my data and it was not immediately obvious to me (though I
2013 Mar 23
1
Time trends with GAM
Hi all, I am using GAM to model time trends in a logistic regression. Yet I would like to extract the the fitted spline from it to add it to another model, that cannot be fitted in GAM or GAMM. Thus I have 2 questions: 1) How can I fit a smoother over time so that I force one knot to be at a particular location while letting the model to find the other knots? 2) how can I extract the matrix
2007 Apr 16
1
Does the smooth terms in GAM have a functional form?
Hi, all, Does anyone know how to get the functional form of the smooth terms in GAM? eg. I fit y=a+b*s(x) where s is the smooth function. After fitting this model with GAM in R, I want to know the form of the s(x). Any suggestion is appreciated. Thanks, Jin --------------------------------- Ahhh...imagining that irresistible "new car" smell?
2007 Oct 08
2
variance explained by each term in a GAM
Hello fellow R's, I do apologize if this is a basic question. I'm doing some GAMs using the mgcv package, and I am wondering what is the most appropriate way to determine how much of the variability in the dependent variable is explained by each term in the model. The information provided by summary.gam() relates to the significance of each term (F, p-value) and to the
2008 May 06
1
mgcv::gam shrinkage of smooths
In Dr. Wood's book on GAM, he suggests in section 4.1.6 that it might be useful to shrink a single smooth by adding S=S+epsilon*I to the penalty matrix S. The context was the need to be able to shrink the term to zero if appropriate. I'd like to do this in order to shrink the coefficients towards zero (irrespective of the penalty for "wiggliness") - but not necessarily all the
2009 Sep 20
1
How to choose knots for GAM?
Hi, all I want to choose same knots in GAM for 10 different studies so that they has the same basis function. Even though I choose same knots and same dimensions of basis smoothing, the basis representations are still not same. My command is as follows: data.gam<-gam(y~s(age,bs='cr',k=10)+male,family=binomial,knots=list(age=seq(45,64,length=10))) What is my mistake for choice of
2007 Nov 25
1
GAM with constraints
Hi, I am trying to build GAM with linear constraints, for a general link function, not only identity. If I understand it correctly, the function pcls() can solve the problem, if the smoothness penalties are given. What I need is to incorporate the constraints before calculating the penalties. Can this be done in R? Any help would be greately appreciated. -- View this message in context:
2007 Aug 08
1
prediction using gam
I am fitting a two dimensional smoother in gam, say junk = gam(y~s(x1,x2)), to a response variable y that is always positive and pretty well behaved, both x1 and x2 are contained within [0,1]. I then create a new dataset for prediction with values of (x1,x2) within the range of the original data. predict(junk,newdata,type="response") My predicted values are a bit strange
2006 Jun 18
1
GAM selection error msgs (mgcv & gam packages)
Hi all, My question concerns 2 error messages; one in the gam package and one in the mgcv package (see below). I have read help files and Chambers and Hastie book but am failing to understand how I can solve this problem. Could you please tell me what I must adjust so that the command does not generate error message? I am trying to achieve model selection for a GAM which is required for