小编imt*_*iky的帖子

如何在R中预测具有随机效应的gam模型?

我正在研究gam具有随机效应的预测模型,以通过plot_ly.

这是我的代码;

x <- runif(100)
y <- runif(100)
z <- x^2 + y + rnorm(100)
r <- rep(1,times=100) # random effect
r[51:100] <- 2 # replace 1 into 2, making two groups
df <- data.frame(x, y, z, r)

gam_fit <- gam(z ~ s(x) + s(y) + s(r,bs="re"), data = df) # fit

#create matrix data for `add_surface` function in `plot_ly`
newx <- seq(0, 1, len=20)
newy <- seq(0, 1, len=30)
newxy <- expand.grid(x = newx, y …
Run Code Online (Sandbox Code Playgroud)

r predict gam random-effects plotly

3
推荐指数
1
解决办法
1637
查看次数

标签 统计

gam ×1

plotly ×1

predict ×1

r ×1

random-effects ×1