noamross / gams-in-r-course Goto Github PK
View Code? Open in Web Editor NEWGeneralized Additive Models in R: A Free Interactive Course
Home Page: https://noamross.github.io/gams-in-r-course
License: Other
Generalized Additive Models in R: A Free Interactive Course
Home Page: https://noamross.github.io/gams-in-r-course
License: Other
hi there,
perhaps i've missed something, but where does the mpg dataset come from? there's one in ggplot2, but it's different than the one here. i don't see one available in mgcv or base r...
Here, the value of the intercept is 0.733. We can use the plogis() logistic function to convert it to a probability.
Converted, the intercept is about 0.67.
This means that the model predicts a 67 percent baseline chance of a positive outcome. This is what we would expect if x1 and x2 were at their average values.
-> But, when I predict the model with average value of predictor variable, it is different from intercept. Followings are reproducible example.
> csale=readRDS("csale.RDS")
> log_mod <- gam(purchase ~ s(n_acts),data=csale,family=binomial,method="REML")
> coef(log_mod)[1]
(Intercept)
-1.593984
> predict(log_mod,newdata=data.frame(n_acts=mean(csale$n_acts)))
1
-1.194276
I attempted to add MathJax to the header here: 5f9dfcd, and in the rendered site it does appear in the <script>
tag in the header, but MathJax, like $\lambda$
in Chapter 1.7 (https://noamross.github.io/gams-in-r-course/chapter1), does not render.
What is the expected purchase probability of a person with 20 accounts (n_acts = 20) if all other values are average? Answer : 0.55
That's correct! Correct! When n_acts is 20 the predicted probability of purchase is about 0.55, all else being equal.
But, When I predict the expected purchase probability of a person with 20 accounts (n_acts = 20) if all other values are average, the answer is 0.4419 with the following code
newdata=data.frame(n_acts=20,
bal_crdt_ratio=mean(csale$bal_crdt_ratio),
avg_prem_balance=mean(csale$avg_prem_balance),
retail_crdt_ratio=mean(csale$retail_crdt_ratio),
avg_fin_balance=mean(csale$avg_fin_balance),
mortgage_age=mean(csale$mortgage_age),
cred_limit=mean(csale$cred_limit)
)
result=predict(log_mod2,newdata=newdata)
plogis(result)
0.4419715
plogis(result+coef(log_mod2)[1])
0.1331066
Multiple Choice: Which two variables have the greatest worst-case concurvity?
height and ≤n>h
height and weight
≤n>h and wh
weight and wh
Submission give "weight and wh" as correct answer.
I'm having trouble locating the csale.rds file. I used the code as described on the web page and it resulted in this error: Error in gzfile(file, "rb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "rb") :
Any help would be appreciated. Thanks!
Hi! I am a newbie in GAM. It would be great to add in these tutorials how to do bootstrapping. Also include on how to generate plots with bootstrapped CI. Thank you
Hello Noam,
Very nice you made a course on GAM and mgcv. It seems to me it is only possible to navigate with the mouse using the scrollbar. Would it be possible to add navigation with arrow keys and Page up and down? That would be very convenient!
Alternatively it would be very convenient to have the course in PDF format.
Thank you very much.
Marcel
PS: I already opened and closed this issue. It seems the issue occurs on some pages of the course and at other pages there is no issue.
Most slide decks end with a "Let's Practice" or similar sllide but in the current format this isn't really necessary - it's a holdover from the old platform. It would make sense to delete these from the slides
markdown files.
I ran the codes on my R but it returned error due to failure to read in the csale dataset.
dear Noam,
im dealing with data of nest sites (nido=0/1) and wanted to explore the spatial component. When running the spatial GAM i got the result that Rsq is 1.
Im not sure if im running something. At the momment my response variable (nido=0/1) is set as factor to able to use the binomail-logit function.
any toughts?
thanks so much, your post/site is amazing!!
mod4
Family: binomial
Link function: logit
Formula:
nido ~ te(x, y)
Estimated degrees of freedom:
7.63 total = 8.63
UBRE score: -0.3558566
summary(mod4)
Family: binomial
Link function: logit
Formula:
nido ~ te(x, y)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 26.03 97.69 0.266 0.79
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
te(x,y) 7.626 7.94 0.267 1
R-sq.(adj) = 1 Deviance explained = 99.6%
UBRE = -0.35586 Scale est. = 1 n = 27
Hello Noam,
Thank you very much for the GAM and mgcv course.
I am in chapter 2 and When I run codes for sections 8 and 9 in my R studio I only get response vs fitted plot. But when it is run in your platform I see 4 graphs. Am I missing something?
Kind regards
Buddhi
[email protected]
Hi, the formula in this section is not the one that shows in the first output (summary(mod_hwy)), it does not count the cylinders at the end. So the results are not the same
When try to plot factor-smooths, vis.gam() function results in an error.
model4c <- gam(hw.mpg ~ s(weight, fuel, bs = "fs"),data = mpg, method = "REML")
vis.gam(model4c, theta=125)
Error in persp.default(m1, m2, z, col = col, zlim = c(min.z, max.z), xlab = view[1], :
increasing 'x' and 'y' values expected
Hi Noam,
I've been running through the course (which is beautiful, by the way) with no difficulties until now. When trying to run csale <- readRDS("csale.rds")
in Chapter 4.2, I receive the error pasted below. R is up-to-date and the "Information" package is loaded (just in case).
Cheers, Brendan
Error message:
Error in gzfile(file, "rb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "rb") :
cannot open compressed file 'csale.rds', probable reason 'No such file or directory'
Hello Noam,
Very nice you made a course on GAM and mgcv. It seems to me it is only possible to navigate with the mouse using the scrollbar. Would it be possible to add navigation with arrow keys and Page up and down? That would be very convenient!
Alternatively it would be very convenient to have the course in PDF format.
Thank you very much.
Marcel
In chapter 3, section 11 you give the following example of using tensor interaction terms:
gam(y ~ s(x1) + s(x2) + ti(x1, x2), data = data, method = "REML")
However, that (appears to??) conflict with the recommendation from Simon Wood in A Toolbox of Smooths(see page 28, "Miscellanea"):
However, nested models make most sense if the bases arestrictly nested. To ensure this, smooth interactions shouldbe constructed using marginal bases identical to thoseused for the main effects.
gam(y~te(x)+te(z)+te(x,z))
would achieve this, for example
Maybe (surely??) I'm missing something here, but if there's a clear explanation it might be worth adding to the course.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.