R - Extending Linear Model beyond scatterplot3d

跟風遠走 提交于 2021-01-28 05:02:37

问题


I have created a scatterplot3d with a linear model applied.

Unfortunately the results of the LM are subtle and need to be emphasised, my question is how can I extend the LM grid outside of the 'cube'.

Plot:

enter image description here

Code:

Plot1 <-scatterplot3d(

              d$MEI,   
              d$YYYYMM,     
              d$AOELog10,
              pch=20,
              grid = FALSE,
              color = "black",
              xlab="MEI",
              ylab="Date",
              zlab="AOE Log(10)"

                       )


fit <- lm(d$AOELog10 ~ d$MEI+d$Rank) 
Plot1$plane3d(fit)

Now I guess it might be a variable within lm(), but I cant find anything....


回答1:


To see a larger region, or region of interest, specify the x, y, and z limits in the scatterplot command.

library(scatterplot3d)
d<-data.frame(MEI=runif(200,-3,3),
              YYYYMM=runif(200,1,300),
              AOELog10=runif(200,1,20),
              Rank=runif(200,1,5))
fit <- lm(d$AOELog10 ~ d$MEI+d$Rank) 
Plot1 <-scatterplot3d(
  d$MEI, d$YYYYMM, d$AOELog10,
  pch=20, grid = FALSE, color = "black",
  xlab="MEI", ylab="Date", zlab="AOE Log(10)",
  main="baseline"
)
Plot1$plane3d(fit)

Plot2 <-scatterplot3d(
  x=d$MEI, y=d$YYYYMM, z=d$AOELog10,
  pch=20, grid = FALSE, color = "black",
  xlab="MEI", ylab="Date", zlab="AOE Log(10)",
  xlim = c(-5,5), ylim = c(-50,400), zlim = c(-10,50),  # Specify the plot range
  main="larger region"
)
Plot2$plane3d(fit)


来源:https://stackoverflow.com/questions/26317538/r-extending-linear-model-beyond-scatterplot3d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!