zoukankan      html  css  js  c++  java
  • 插值和空间分析(一)_探索性数据分析(R语言)

    > library(lattice)
    > library(sp)
    > data(meuse)
    > coordinates(meuse) <- c("x","y")
    > spplot(meuse, "zinc", do.log=T)
    > bubble(meuse, "zinc", do.log=T, key.space="bottom")



    > xyplot(log(meuse$zinc)~sqrt(meuse$dist), meuse, main="", xlab="dist", ylab="Zn")

    > meuse$fitted.s <- predict(zn.lm, meuse) - mean(predict(zn.lm,meuse))
    > meuse$residuals <- residuals(zn.lm)
    > spplot(meuse, c("fitted.s", "residuals"))
    > spplot(meuse, c("fitted.s", "residuals"))

    > library(gstat)
    > idw.out <- idw(zinc~1, meuse, meuse.grid, idp=1)
    [inverse distance weighted interpolation]
    > spplot(idw.out)
    > spplot(idw.out, c("var1.pred"))

      

    3、使用线性回归:
    > zn.lm <- lm(log(zinc) ~ sqrt(dist), meuse) > meuse.grid$pred <- predict(zn.lm, meuse.grid) > meuse.grid$se.fit <- predict(zn.lm, meuse.grid, se.fit=TRUE)$se.fit
    > spplot(meuse.lm)

    方式一、采用krige函数
    > meuse.lm <- krige(log(zinc) ~ sqrt(dist), meuse, meuse.grid)
    [ordinary or weighted least squares prediction]
    > spplot(meuse.lm)
         
    > meuse.lm <- krige(log(zinc)~1, meuse, meuse.grid, degree=2)
    > spplot(meuse.lm)
    方式二:采用lm函数

    > lm(log(zinc)~I(x^2)+I(y^2)+I(x*y)+x+y, meuse)
    > lm(log(zinc)~poly(x,y,degree=2), meuse)
    
    


     
  • 相关阅读:
    今天过节提前下班
    作控件也挺郁闷啊!
    使用Windows XP的主题
    这几天关心加密的人很多
    多普达515,好爽啊!
    515看电影
    我要定计划
    龙芯II发布了,好事儿!
    转:关于星际与XP的结对编程
    昨天参加了一个微软的会
  • 原文地址:https://www.cnblogs.com/takeaction/p/4122670.html
Copyright © 2011-2022 走看看