Giter Club home page Giter Club logo

Comments (6)

szcf-weiya avatar szcf-weiya commented on June 5, 2024

LOESS

Figure 6.9 has been reproduced in https://esl.hohoweiya.xyz/rmds/lattice.html. It shows that

  • given wind and temp, ozone tends to increase along radiation, which can be observed from almost every panels, except that the ozone can decrease a little when radiation is highest, such as panel (4, 3).
  • given wind, i.e., for each row, the increasing magnitude and baseline of ozone along radiation would be increasing for the increasing temp. Or in other words, further given radiation, say the two extreme points, ozone tends to increase along temp.
  • given temp, i.e., for each column, the baseline (or say the minimum and maximum) of ozone along radiation decreases along wind

from esl-cn.

szcf-weiya avatar szcf-weiya commented on June 5, 2024

GAM

# GAM
library(gam)
fit = gam(I(ozone^(1/3))~s(temperature) + s(wind) + s(radiation), data = data)
par(mfrow=c(1, 3))
plot(fit, se = T)

image
It is clear that the contribution of each feature captures the same pattern as concluded for Fig. 6.9.

  • the contribution of temp increases along temp
  • the contribution of wind decreases along wind
  • the contribution of radiation increases along radiation

from esl-cn.

szcf-weiya avatar szcf-weiya commented on June 5, 2024

Tree

library(rpart)
library(rpart.plot)
fit.tree = rpart(I(ozone^(1/3))~ temperature + wind + radiation, data = data)
rpart.plot(fit.tree)

image
Note that the response value in the leaf node increases from left to right, then we can observe that

  • small radiation goes to the left, i.e., ozone tends to increase along radiation.
  • small temp goes to the left, i.e., ozone tends to increase along temp.
  • small wind goes to the right, i.e. ozone tends to decrease along wind.

from esl-cn.

szcf-weiya avatar szcf-weiya commented on June 5, 2024

MARS

> # MARS
> library(earth)
> fit.mars = earth(I(ozone^(1/3))~ temperature + wind + radiation, data = data)
> summary(fit.mars)
Call: earth(formula=I(ozone^(1/3))~temperature+wind+radiation, data=data)

                  coefficients
(Intercept)         2.72035983
h(temperature-73)   0.07721326
h(temperature-90)  -0.11780995
h(9.7-wind)         0.17106469
h(225-radiation)   -0.00317888

Selected 5 of 14 terms, and 3 of 3 predictors
Termination condition: Reached nk 21
Importance: temperature, wind, radiation
Number of terms at each degree of interaction: 1 4 (additive model)
GCV 0.2185924    RSS 20.48861    GRSq 0.7267643    RSq 0.7650625

Note the basis function and the sign of coefficients,

  • for temp, positive coef in [73, 90], and then negative coef in [90, ~], which indicates that ozone tends to increase along temp, but a little decrease for higher temp. The tail decreasing pattern has also been shown in the lower confidence curve in GAM
  • for wind, positive coef in [9.7, ~], which indicates that ozone tends to decrease along wind
  • for radition, negative coef in [225, ~], which indicates that ozone tends to increase along radiation

Interestingly, the reflection pairs do not return as in https://github.com/szcf-weiya/ESL-CN/blob/3aefb0bc171e272ca87af159e1d665d1d56b4c9f/code/MARS/simulation.R

from esl-cn.

szcf-weiya avatar szcf-weiya commented on June 5, 2024

PRIM

library(prim)
fit.prim = prim.box(as.matrix(data[,-1]), as.numeric(data[, 1]))
summary(fit.prim, print.box = T)
plotprim = function(x, y, box = box, ...) {
  plot(x, y, ...)
  rect(box[1, 1], box[1, 2], box[2, 1], box[2, 2], border = "red")
}
colname = colnames(data)
par(mfrow = c(1, 3))
for (i in 2:3)
  for (j in (i+1):4)
    plotprim(data[,i], data[, j], fit.prim$box[[1]][,c(i-1, j-1)], 
             xlab = colname[i], ylab = colname[j])

It seems that plot.prim does not plot the box, and also cannot superimpose on the original observation points, so I wrote the plot function by myself.
image
Note that the box indicates large ozone, so it reveals that

  • from the first two panels, large radiation tends to have large ozone, i.e., increase
  • from the last two panels, small wind tends to have large ozone, i.e., decrease
  • from panel 1 and 3, large temp tends to have large ozone, i.e., increase

from esl-cn.

szcf-weiya avatar szcf-weiya commented on June 5, 2024

Conclusion: all these methods obtain similar results in terms of the trend of every single variable.

from esl-cn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.